ispageio.c 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283
  1. /*
  2. * CDE - Common Desktop Environment
  3. *
  4. * Copyright (c) 1993-2012, The Open Group. All rights reserved.
  5. *
  6. * These libraries and programs are free software; you can
  7. * redistribute them and/or modify them under the terms of the GNU
  8. * Lesser General Public License as published by the Free Software
  9. * Foundation; either version 2 of the License, or (at your option)
  10. * any later version.
  11. *
  12. * These libraries and programs are distributed in the hope that
  13. * they will be useful, but WITHOUT ANY WARRANTY; without even the
  14. * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
  15. * PURPOSE. See the GNU Lesser General Public License for more
  16. * details.
  17. *
  18. * You should have received a copy of the GNU Lesser General Public
  19. * License along with these libraries and programs; if not, write
  20. * to the Free Software Foundation, Inc., 51 Franklin Street, Fifth
  21. * Floor, Boston, MA 02110-1301 USA
  22. */
  23. /*%% (c) Copyright 1993, 1994 Hewlett-Packard Company */
  24. /*%% (c) Copyright 1993, 1994 International Business Machines Corp. */
  25. /*%% (c) Copyright 1993, 1994 Sun Microsystems, Inc. */
  26. /*%% (c) Copyright 1993, 1994 Novell, Inc. */
  27. /*%% $XConsortium: ispageio.c /main/3 1995/10/23 11:42:51 rswiston $ */
  28. /*
  29. * Copyright (c) 1988 by Sun Microsystems, Inc.
  30. */
  31. /*
  32. * ispageio.c
  33. *
  34. * Description:
  35. * I/O functions for file pages.
  36. *
  37. *
  38. */
  39. #include "isam_impl.h"
  40. #include <unistd.h>
  41. /*
  42. * _isseekpg(fd, pgno)
  43. *
  44. * Set current file pointer to the page pgno.
  45. */
  46. void
  47. _isseekpg(int fd, Blkno pgno)
  48. {
  49. long offset = pgno * ISPAGESIZE;
  50. if (lseek(fd, offset, 0) != offset)
  51. _isfatal_error("lseek failed");
  52. }
  53. /*
  54. * _isreadpg(fd, buf)
  55. *
  56. * Read eon block from UNIX file into a buffer.
  57. */
  58. void
  59. _isreadpg(int fd, char *buf)
  60. {
  61. if (read(fd, buf, ISPAGESIZE) != ISPAGESIZE)
  62. _isfatal_error("read failed");
  63. }
  64. /*
  65. * _iswritepg(fd, buf)
  66. *
  67. * Write one block to UNIX file.
  68. */
  69. void
  70. _iswritepg(int fd, char *buf)
  71. {
  72. if (write(fd, buf, ISPAGESIZE) != ISPAGESIZE)
  73. _isfatal_error("write failed");
  74. }