• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 #ifndef XATTR_H
2 #define XATTR_H
3 /*
4  * Create a squashfs filesystem.  This is a highly compressed read only
5  * filesystem.
6  *
7  * Copyright (c) 2010, 2012, 2013, 2014
8  * Phillip Lougher <phillip@squashfs.org.uk>
9  *
10  * This program is free software; you can redistribute it and/or
11  * modify it under the terms of the GNU General Public License
12  * as published by the Free Software Foundation; either version 2,
13  * or (at your option) any later version.
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU General Public License
21  * along with this program; if not, write to the Free Software
22  * Foundation, 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23  *
24  * xattr.h
25  */
26 
27 #define XATTR_VALUE_OOL		SQUASHFS_XATTR_VALUE_OOL
28 #define XATTR_PREFIX_MASK	SQUASHFS_XATTR_PREFIX_MASK
29 
30 #define XATTR_VALUE_OOL_SIZE	sizeof(long long)
31 
32 /* maximum size of xattr value data that will be inlined */
33 #define XATTR_INLINE_MAX 	128
34 
35 /* the target size of an inode's xattr name:value list.  If it
36  * exceeds this, then xattr value data will be successively out of lined
37  * until it meets the target */
38 #define XATTR_TARGET_MAX	65536
39 
40 #define IS_XATTR(a)		(a != SQUASHFS_INVALID_XATTR)
41 
42 struct xattr_list {
43 	char			*name;
44 	char			*full_name;
45 	int			size;
46 	int			vsize;
47 	void			*value;
48 	int			type;
49 	long long		ool_value;
50 	unsigned short		vchecksum;
51 	struct xattr_list	*vnext;
52 };
53 
54 struct dupl_id {
55 	struct xattr_list	*xattr_list;
56 	int			xattrs;
57 	int			xattr_id;
58 	struct dupl_id		*next;
59 };
60 
61 struct prefix {
62 	char			*prefix;
63 	int			type;
64 };
65 
66 extern int generate_xattrs(int, struct xattr_list *);
67 
68 #ifdef XATTR_SUPPORT
69 extern int get_xattrs(int, struct squashfs_super_block *);
70 extern int read_xattrs(void *);
71 extern long long write_xattrs();
72 extern void save_xattrs();
73 extern void restore_xattrs();
74 extern unsigned int xattr_bytes, total_xattr_bytes;
75 extern void write_xattr(char *, unsigned int);
76 extern int read_xattrs_from_disk(int, struct squashfs_super_block *);
77 extern struct xattr_list *get_xattr(int, unsigned int *, int);
78 extern void free_xattr(struct xattr_list *, int);
79 #else
get_xattrs(int fd,struct squashfs_super_block * sBlk)80 static inline int get_xattrs(int fd, struct squashfs_super_block *sBlk)
81 {
82 	if(sBlk->xattr_id_table_start != SQUASHFS_INVALID_BLK) {
83 		fprintf(stderr, "Xattrs in filesystem! These are not "
84 			"supported on this version of Squashfs\n");
85 		return 0;
86 	} else
87 		return SQUASHFS_INVALID_BLK;
88 }
89 
90 
read_xattrs(void * dir_ent)91 static inline int read_xattrs(void *dir_ent)
92 {
93 	return SQUASHFS_INVALID_XATTR;
94 }
95 
96 
write_xattrs()97 static inline long long write_xattrs()
98 {
99 	return SQUASHFS_INVALID_BLK;
100 }
101 
102 
save_xattrs()103 static inline void save_xattrs()
104 {
105 }
106 
107 
restore_xattrs()108 static inline void restore_xattrs()
109 {
110 }
111 
112 
write_xattr(char * pathname,unsigned int xattr)113 static inline void write_xattr(char *pathname, unsigned int xattr)
114 {
115 }
116 
117 
read_xattrs_from_disk(int fd,struct squashfs_super_block * sBlk)118 static inline int read_xattrs_from_disk(int fd, struct squashfs_super_block *sBlk)
119 {
120 	if(sBlk->xattr_id_table_start != SQUASHFS_INVALID_BLK) {
121 		fprintf(stderr, "Xattrs in filesystem! These are not "
122 			"supported on this version of Squashfs\n");
123 		return 0;
124 	} else
125 		return SQUASHFS_INVALID_BLK;
126 }
127 
128 
get_xattr(int i,unsigned int * count,int j)129 static inline struct xattr_list *get_xattr(int i, unsigned int *count, int j)
130 {
131 	return NULL;
132 }
133 #endif
134 
135 #ifdef XATTR_SUPPORT
136 #ifdef XATTR_DEFAULT
137 #define NOXOPT_STR
138 #define XOPT_STR " (default)"
139 #define XATTR_DEF 0
140 #else
141 #define NOXOPT_STR " (default)"
142 #define XOPT_STR
143 #define XATTR_DEF 1
144 #endif
145 #else
146 #define NOXOPT_STR " (default)"
147 #define XOPT_STR " (unsupported)"
148 #define XATTR_DEF 1
149 #endif
150 #endif
151