mntent.h 3.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495
  1. /* Utilities for reading/writing fstab, mtab, etc.
  2. Copyright (C) 1995-2020 Free Software Foundation, Inc.
  3. This file is part of the GNU C Library.
  4. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Lesser General Public
  6. License as published by the Free Software Foundation; either
  7. version 2.1 of the License, or (at your option) any later version.
  8. The GNU C Library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Lesser General Public License for more details.
  12. You should have received a copy of the GNU Lesser General Public
  13. License along with the GNU C Library; if not, see
  14. <https://www.gnu.org/licenses/>. */
  15. #ifndef _MNTENT_H
  16. #define _MNTENT_H 1
  17. #include <features.h>
  18. #include <paths.h>
  19. #include <bits/types/FILE.h>
  20. /* File listing canonical interesting mount points. */
  21. #define MNTTAB _PATH_MNTTAB /* Deprecated alias. */
  22. /* File listing currently active mount points. */
  23. #define MOUNTED _PATH_MOUNTED /* Deprecated alias. */
  24. /* General filesystem types. */
  25. #define MNTTYPE_IGNORE "ignore" /* Ignore this entry. */
  26. #define MNTTYPE_NFS "nfs" /* Network file system. */
  27. #define MNTTYPE_SWAP "swap" /* Swap device. */
  28. /* Generic mount options. */
  29. #define MNTOPT_DEFAULTS "defaults" /* Use all default options. */
  30. #define MNTOPT_RO "ro" /* Read only. */
  31. #define MNTOPT_RW "rw" /* Read/write. */
  32. #define MNTOPT_SUID "suid" /* Set uid allowed. */
  33. #define MNTOPT_NOSUID "nosuid" /* No set uid allowed. */
  34. #define MNTOPT_NOAUTO "noauto" /* Do not auto mount. */
  35. __BEGIN_DECLS
  36. /* Structure describing a mount table entry. */
  37. struct mntent
  38. {
  39. char *mnt_fsname; /* Device or server for filesystem. */
  40. char *mnt_dir; /* Directory mounted on. */
  41. char *mnt_type; /* Type of filesystem: ufs, nfs, etc. */
  42. char *mnt_opts; /* Comma-separated options for fs. */
  43. int mnt_freq; /* Dump frequency (in days). */
  44. int mnt_passno; /* Pass number for `fsck'. */
  45. };
  46. /* Prepare to begin reading and/or writing mount table entries from the
  47. beginning of FILE. MODE is as for `fopen'. */
  48. extern FILE *setmntent (const char *__file, const char *__mode) __THROW;
  49. /* Read one mount table entry from STREAM. Returns a pointer to storage
  50. reused on the next call, or null for EOF or error (use feof/ferror to
  51. check). */
  52. extern struct mntent *getmntent (FILE *__stream) __THROW;
  53. #ifdef __USE_MISC
  54. /* Reentrant version of the above function. */
  55. extern struct mntent *getmntent_r (FILE *__restrict __stream,
  56. struct mntent *__restrict __result,
  57. char *__restrict __buffer,
  58. int __bufsize) __THROW;
  59. #endif
  60. /* Write the mount table entry described by MNT to STREAM.
  61. Return zero on success, nonzero on failure. */
  62. extern int addmntent (FILE *__restrict __stream,
  63. const struct mntent *__restrict __mnt) __THROW;
  64. /* Close a stream opened with `setmntent'. */
  65. extern int endmntent (FILE *__stream) __THROW;
  66. /* Search MNT->mnt_opts for an option matching OPT.
  67. Returns the address of the substring, or null if none found. */
  68. extern char *hasmntopt (const struct mntent *__mnt,
  69. const char *__opt) __THROW;
  70. __END_DECLS
  71. #endif /* mntent.h */