@@ -212,96 +212,68 @@ static int squashfs_xattr_get(struct inode *inode, int name_index,
212
212
}
213
213
214
214
215
- /*
216
- * User namespace support
217
- */
218
- static size_t squashfs_user_list (const struct xattr_handler * handler ,
219
- struct dentry * d , char * list , size_t list_size ,
220
- const char * name , size_t name_len )
215
+ static size_t squashfs_xattr_handler_list (const struct xattr_handler * handler ,
216
+ struct dentry * d , char * list ,
217
+ size_t list_size , const char * name ,
218
+ size_t name_len )
221
219
{
222
- if (list && XATTR_USER_PREFIX_LEN <= list_size )
223
- memcpy (list , XATTR_USER_PREFIX , XATTR_USER_PREFIX_LEN );
224
- return XATTR_USER_PREFIX_LEN ;
220
+ int len = strlen (handler -> prefix );
221
+
222
+ if (list && len <= list_size )
223
+ memcpy (list , handler -> prefix , len );
224
+ return len ;
225
225
}
226
226
227
- static int squashfs_user_get (const struct xattr_handler * handler ,
228
- struct dentry * d , const char * name , void * buffer ,
229
- size_t size )
227
+ static int squashfs_xattr_handler_get (const struct xattr_handler * handler ,
228
+ struct dentry * d , const char * name ,
229
+ void * buffer , size_t size )
230
230
{
231
231
if (name [0 ] == '\0' )
232
232
return - EINVAL ;
233
233
234
- return squashfs_xattr_get (d_inode (d ), SQUASHFS_XATTR_USER , name ,
234
+ return squashfs_xattr_get (d_inode (d ), handler -> flags , name ,
235
235
buffer , size );
236
236
}
237
237
238
+ /*
239
+ * User namespace support
240
+ */
238
241
static const struct xattr_handler squashfs_xattr_user_handler = {
239
242
.prefix = XATTR_USER_PREFIX ,
240
- .list = squashfs_user_list ,
241
- .get = squashfs_user_get
243
+ .flags = SQUASHFS_XATTR_USER ,
244
+ .list = squashfs_xattr_handler_list ,
245
+ .get = squashfs_xattr_handler_get
242
246
};
243
247
244
248
/*
245
249
* Trusted namespace support
246
250
*/
247
- static size_t squashfs_trusted_list (const struct xattr_handler * handler ,
248
- struct dentry * d , char * list ,
249
- size_t list_size , const char * name ,
250
- size_t name_len )
251
+ static size_t squashfs_trusted_xattr_handler_list (const struct xattr_handler * handler ,
252
+ struct dentry * d , char * list ,
253
+ size_t list_size , const char * name ,
254
+ size_t name_len )
251
255
{
252
256
if (!capable (CAP_SYS_ADMIN ))
253
257
return 0 ;
254
-
255
- if (list && XATTR_TRUSTED_PREFIX_LEN <= list_size )
256
- memcpy (list , XATTR_TRUSTED_PREFIX , XATTR_TRUSTED_PREFIX_LEN );
257
- return XATTR_TRUSTED_PREFIX_LEN ;
258
- }
259
-
260
- static int squashfs_trusted_get (const struct xattr_handler * handler ,
261
- struct dentry * d , const char * name ,
262
- void * buffer , size_t size )
263
- {
264
- if (name [0 ] == '\0' )
265
- return - EINVAL ;
266
-
267
- return squashfs_xattr_get (d_inode (d ), SQUASHFS_XATTR_TRUSTED , name ,
268
- buffer , size );
258
+ return squashfs_xattr_handler_list (handler , d , list , list_size , name ,
259
+ name_len );
269
260
}
270
261
271
262
static const struct xattr_handler squashfs_xattr_trusted_handler = {
272
263
.prefix = XATTR_TRUSTED_PREFIX ,
273
- .list = squashfs_trusted_list ,
274
- .get = squashfs_trusted_get
264
+ .flags = SQUASHFS_XATTR_TRUSTED ,
265
+ .list = squashfs_trusted_xattr_handler_list ,
266
+ .get = squashfs_xattr_handler_get
275
267
};
276
268
277
269
/*
278
270
* Security namespace support
279
271
*/
280
- static size_t squashfs_security_list (const struct xattr_handler * handler ,
281
- struct dentry * d , char * list ,
282
- size_t list_size , const char * name ,
283
- size_t name_len )
284
- {
285
- if (list && XATTR_SECURITY_PREFIX_LEN <= list_size )
286
- memcpy (list , XATTR_SECURITY_PREFIX , XATTR_SECURITY_PREFIX_LEN );
287
- return XATTR_SECURITY_PREFIX_LEN ;
288
- }
289
-
290
- static int squashfs_security_get (const struct xattr_handler * handler ,
291
- struct dentry * d , const char * name ,
292
- void * buffer , size_t size )
293
- {
294
- if (name [0 ] == '\0' )
295
- return - EINVAL ;
296
-
297
- return squashfs_xattr_get (d_inode (d ), SQUASHFS_XATTR_SECURITY , name ,
298
- buffer , size );
299
- }
300
-
301
272
static const struct xattr_handler squashfs_xattr_security_handler = {
302
273
.prefix = XATTR_SECURITY_PREFIX ,
303
- .list = squashfs_security_list ,
304
- .get = squashfs_security_get
274
+ .flags = SQUASHFS_XATTR_SECURITY ,
275
+ .list = squashfs_xattr_handler_list ,
276
+ .get = squashfs_xattr_handler_get
305
277
};
306
278
307
279
static const struct xattr_handler * squashfs_xattr_handler (int type )
0 commit comments