/usr.bin/csup/fattr.h

https://bitbucket.org/freebsd/freebsd-head/ · C++ Header · 118 lines · 63 code · 16 blank · 39 comment · 0 complexity · ede34946c6299fe9ddb487e9dda208df MD5 · raw file

  1. /*-
  2. * Copyright (c) 2003-2006, Maxime Henrion <mux@FreeBSD.org>
  3. * All rights reserved.
  4. *
  5. * Redistribution and use in source and binary forms, with or without
  6. * modification, are permitted provided that the following conditions
  7. * are met:
  8. * 1. Redistributions of source code must retain the above copyright
  9. * notice, this list of conditions and the following disclaimer.
  10. * 2. Redistributions in binary form must reproduce the above copyright
  11. * notice, this list of conditions and the following disclaimer in the
  12. * documentation and/or other materials provided with the distribution.
  13. *
  14. * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND
  15. * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  16. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
  17. * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE
  18. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  19. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
  20. * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
  21. * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
  22. * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
  23. * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
  24. * SUCH DAMAGE.
  25. *
  26. * $FreeBSD$
  27. */
  28. #ifndef _FATTR_H_
  29. #define _FATTR_H_
  30. #include <sys/types.h>
  31. #include <fcntl.h>
  32. #include <time.h>
  33. /*
  34. * File types.
  35. */
  36. #define FT_UNKNOWN 0 /* Unknown file type. */
  37. #define FT_FILE 1 /* Regular file. */
  38. #define FT_DIRECTORY 2 /* Directory. */
  39. #define FT_CDEV 3 /* Character device. */
  40. #define FT_BDEV 4 /* Block device. */
  41. #define FT_SYMLINK 5 /* Symbolic link. */
  42. #define FT_MAX FT_SYMLINK /* Maximum file type number. */
  43. #define FT_NUMBER (FT_MAX + 1) /* Number of file types. */
  44. /*
  45. * File attributes.
  46. */
  47. #define FA_FILETYPE 0x0001 /* True for all supported file types. */
  48. #define FA_MODTIME 0x0002 /* Last file modification time. */
  49. #define FA_SIZE 0x0004 /* Size of the file. */
  50. #define FA_LINKTARGET 0x0008 /* Target of a symbolic link. */
  51. #define FA_RDEV 0x0010 /* Device for a device node. */
  52. #define FA_OWNER 0x0020 /* Owner of the file. */
  53. #define FA_GROUP 0x0040 /* Group of the file. */
  54. #define FA_MODE 0x0080 /* File permissions. */
  55. #define FA_FLAGS 0x0100 /* 4.4BSD flags, a la chflags(2). */
  56. #define FA_LINKCOUNT 0x0200 /* Hard link count. */
  57. #define FA_DEV 0x0400 /* Device holding the inode. */
  58. #define FA_INODE 0x0800 /* Inode number. */
  59. #define FA_MASK 0x0fff
  60. #define FA_NUMBER 12 /* Number of file attributes. */
  61. /* Attributes that we might be able to change. */
  62. #define FA_CHANGEABLE (FA_MODTIME | FA_OWNER | FA_GROUP | FA_MODE | FA_FLAGS)
  63. /*
  64. * Attributes that we don't want to save in the "checkouts" file
  65. * when in checkout mode.
  66. */
  67. #define FA_COIGNORE (FA_MASK & ~(FA_FILETYPE|FA_MODTIME|FA_SIZE|FA_MODE))
  68. /* These are for fattr_frompath(). */
  69. #define FATTR_FOLLOW 0
  70. #define FATTR_NOFOLLOW 1
  71. struct stat;
  72. struct fattr;
  73. typedef int fattr_support_t[FT_NUMBER];
  74. extern const struct fattr *fattr_bogus;
  75. void fattr_init(void);
  76. void fattr_fini(void);
  77. struct fattr *fattr_new(int, time_t);
  78. struct fattr *fattr_default(int);
  79. struct fattr *fattr_fromstat(struct stat *);
  80. struct fattr *fattr_frompath(const char *, int);
  81. struct fattr *fattr_fromfd(int);
  82. struct fattr *fattr_decode(char *);
  83. struct fattr *fattr_forcheckout(const struct fattr *, mode_t);
  84. struct fattr *fattr_dup(const struct fattr *);
  85. char *fattr_encode(const struct fattr *, fattr_support_t, int);
  86. int fattr_type(const struct fattr *);
  87. void fattr_maskout(struct fattr *, int);
  88. int fattr_getmask(const struct fattr *);
  89. nlink_t fattr_getlinkcount(const struct fattr *);
  90. char *fattr_getlinktarget(const struct fattr *);
  91. void fattr_umask(struct fattr *, mode_t);
  92. void fattr_merge(struct fattr *, const struct fattr *);
  93. void fattr_mergedefault(struct fattr *);
  94. void fattr_override(struct fattr *, const struct fattr *, int);
  95. int fattr_makenode(const struct fattr *, const char *);
  96. int fattr_delete(const char *path);
  97. int fattr_install(struct fattr *, const char *, const char *);
  98. int fattr_equal(const struct fattr *, const struct fattr *);
  99. void fattr_free(struct fattr *);
  100. int fattr_supported(int);
  101. off_t fattr_filesize(const struct fattr *);
  102. #endif /* !_FATTR_H_ */