]> CyberLeo.Net >> Repos - FreeBSD/releng/10.0.git/blob - usr.bin/csup/fattr.h
- Copy stable/10 (r259064) to releng/10.0 as part of the
[FreeBSD/releng/10.0.git] / usr.bin / csup / fattr.h
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
31 #include <sys/types.h>
32
33 #include <fcntl.h>
34 #include <time.h>
35
36 /*
37  * File types.
38  */
39 #define FT_UNKNOWN      0                       /* Unknown file type. */
40 #define FT_FILE         1                       /* Regular file. */
41 #define FT_DIRECTORY    2                       /* Directory. */
42 #define FT_CDEV         3                       /* Character device. */
43 #define FT_BDEV         4                       /* Block device. */
44 #define FT_SYMLINK      5                       /* Symbolic link. */
45 #define FT_MAX          FT_SYMLINK              /* Maximum file type number. */
46 #define FT_NUMBER       (FT_MAX + 1)            /* Number of file types. */
47
48 /*
49  * File attributes.
50  */
51 #define FA_FILETYPE     0x0001          /* True for all supported file types. */
52 #define FA_MODTIME      0x0002          /* Last file modification time. */
53 #define FA_SIZE         0x0004          /* Size of the file. */
54 #define FA_LINKTARGET   0x0008          /* Target of a symbolic link. */
55 #define FA_RDEV         0x0010          /* Device for a device node. */
56 #define FA_OWNER        0x0020          /* Owner of the file. */
57 #define FA_GROUP        0x0040          /* Group of the file. */
58 #define FA_MODE         0x0080          /* File permissions. */
59 #define FA_FLAGS        0x0100          /* 4.4BSD flags, a la chflags(2). */
60 #define FA_LINKCOUNT    0x0200          /* Hard link count. */
61 #define FA_DEV          0x0400          /* Device holding the inode. */
62 #define FA_INODE        0x0800          /* Inode number. */
63
64 #define FA_MASK         0x0fff
65
66 #define FA_NUMBER       12              /* Number of file attributes. */
67
68 /* Attributes that we might be able to change. */
69 #define FA_CHANGEABLE   (FA_MODTIME | FA_OWNER | FA_GROUP | FA_MODE | FA_FLAGS)
70
71 /*
72  * Attributes that we don't want to save in the "checkouts" file
73  * when in checkout mode.
74  */
75 #define FA_COIGNORE     (FA_MASK & ~(FA_FILETYPE|FA_MODTIME|FA_SIZE|FA_MODE))
76
77 /* These are for fattr_frompath(). */
78 #define FATTR_FOLLOW    0
79 #define FATTR_NOFOLLOW  1
80
81 struct stat;
82 struct fattr;
83
84 typedef int     fattr_support_t[FT_NUMBER];
85
86 extern const struct fattr *fattr_bogus;
87
88 void             fattr_init(void);
89 void             fattr_fini(void);
90
91 struct fattr    *fattr_new(int, time_t);
92 struct fattr    *fattr_default(int);
93 struct fattr    *fattr_fromstat(struct stat *);
94 struct fattr    *fattr_frompath(const char *, int);
95 struct fattr    *fattr_fromfd(int);
96 struct fattr    *fattr_decode(char *);
97 struct fattr    *fattr_forcheckout(const struct fattr *, mode_t);
98 struct fattr    *fattr_dup(const struct fattr *);
99 char            *fattr_encode(const struct fattr *, fattr_support_t, int);
100 int              fattr_type(const struct fattr *);
101 void             fattr_maskout(struct fattr *, int);
102 int              fattr_getmask(const struct fattr *);
103 nlink_t          fattr_getlinkcount(const struct fattr *);
104 char            *fattr_getlinktarget(const struct fattr *);
105 void             fattr_umask(struct fattr *, mode_t);
106 void             fattr_merge(struct fattr *, const struct fattr *);
107 void             fattr_mergedefault(struct fattr *);
108 void             fattr_override(struct fattr *, const struct fattr *, int);
109 int              fattr_makenode(const struct fattr *, const char *);
110 int              fattr_delete(const char *path);
111 int              fattr_install(struct fattr *, const char *, const char *);
112 int              fattr_equal(const struct fattr *, const struct fattr *);
113 void             fattr_free(struct fattr *);
114 int              fattr_supported(int);
115 off_t            fattr_filesize(const struct fattr *);
116
117
118 #endif /* !_FATTR_H_ */