4 * (C) 2003 Ardis Technologies <roman@ardistech.com>
6 * Export hfs data via xattr
11 #include <linux/xattr.h>
16 int hfs_setxattr(struct dentry
*unused
, struct inode
*inode
,
17 const char *name
, const void *value
,
18 size_t size
, int flags
)
20 struct hfs_find_data fd
;
22 struct hfs_cat_file
*file
;
25 if (!S_ISREG(inode
->i_mode
) || HFS_IS_RSRC(inode
))
28 res
= hfs_find_init(HFS_SB(inode
->i_sb
)->cat_tree
, &fd
);
31 fd
.search_key
->cat
= HFS_I(inode
)->cat_key
;
32 res
= hfs_brec_find(&fd
);
35 hfs_bnode_read(fd
.bnode
, &rec
, fd
.entryoffset
,
36 sizeof(struct hfs_cat_file
));
39 if (!strcmp(name
, "hfs.type")) {
41 memcpy(&file
->UsrWds
.fdType
, value
, 4);
44 } else if (!strcmp(name
, "hfs.creator")) {
46 memcpy(&file
->UsrWds
.fdCreator
, value
, 4);
52 hfs_bnode_write(fd
.bnode
, &rec
, fd
.entryoffset
,
53 sizeof(struct hfs_cat_file
));
59 ssize_t
hfs_getxattr(struct dentry
*unused
, struct inode
*inode
,
60 const char *name
, void *value
, size_t size
)
62 struct hfs_find_data fd
;
64 struct hfs_cat_file
*file
;
67 if (!S_ISREG(inode
->i_mode
) || HFS_IS_RSRC(inode
))
71 res
= hfs_find_init(HFS_SB(inode
->i_sb
)->cat_tree
, &fd
);
74 fd
.search_key
->cat
= HFS_I(inode
)->cat_key
;
75 res
= hfs_brec_find(&fd
);
78 hfs_bnode_read(fd
.bnode
, &rec
, fd
.entryoffset
,
79 sizeof(struct hfs_cat_file
));
83 if (!strcmp(name
, "hfs.type")) {
85 memcpy(value
, &file
->UsrWds
.fdType
, 4);
88 res
= size
? -ERANGE
: 4;
89 } else if (!strcmp(name
, "hfs.creator")) {
91 memcpy(value
, &file
->UsrWds
.fdCreator
, 4);
94 res
= size
? -ERANGE
: 4;
103 #define HFS_ATTRLIST_SIZE (sizeof("hfs.creator")+sizeof("hfs.type"))
105 ssize_t
hfs_listxattr(struct dentry
*dentry
, char *buffer
, size_t size
)
107 struct inode
*inode
= d_inode(dentry
);
109 if (!S_ISREG(inode
->i_mode
) || HFS_IS_RSRC(inode
))
112 if (!buffer
|| !size
)
113 return HFS_ATTRLIST_SIZE
;
114 if (size
< HFS_ATTRLIST_SIZE
)
116 strcpy(buffer
, "hfs.type");
117 strcpy(buffer
+ sizeof("hfs.type"), "hfs.creator");
119 return HFS_ATTRLIST_SIZE
;
This page took 0.033308 seconds and 6 git commands to generate.