xattr.c (017f8da43e92ddd9989884720b694a512e09ccce) | xattr.c (bf29e886b242cebf6a96ca0e43873abc777e0b50) |
---|---|
1/* 2 * linux/fs/hfsplus/xattr.c 3 * 4 * Vyacheslav Dubeyko <slava@dubeyko.com> 5 * 6 * Logic of processing extended attributes 7 */ 8 --- 792 unchanged lines hidden (view full) --- 801end_removexattr: 802 hfs_find_exit(&cat_fd); 803 return err; 804} 805 806static int hfsplus_osx_getxattr(struct dentry *dentry, const char *name, 807 void *buffer, size_t size, int type) 808{ | 1/* 2 * linux/fs/hfsplus/xattr.c 3 * 4 * Vyacheslav Dubeyko <slava@dubeyko.com> 5 * 6 * Logic of processing extended attributes 7 */ 8 --- 792 unchanged lines hidden (view full) --- 801end_removexattr: 802 hfs_find_exit(&cat_fd); 803 return err; 804} 805 806static int hfsplus_osx_getxattr(struct dentry *dentry, const char *name, 807 void *buffer, size_t size, int type) 808{ |
809 char xattr_name[HFSPLUS_ATTR_MAX_STRLEN + 810 XATTR_MAC_OSX_PREFIX_LEN + 1] = {0}; 811 size_t len = strlen(name); | 809 char *xattr_name; 810 int res; |
812 813 if (!strcmp(name, "")) 814 return -EINVAL; 815 | 811 812 if (!strcmp(name, "")) 813 return -EINVAL; 814 |
816 if (len > HFSPLUS_ATTR_MAX_STRLEN) 817 return -EOPNOTSUPP; 818 | |
819 /* 820 * Don't allow retrieving properly prefixed attributes 821 * by prepending them with "osx." 822 */ 823 if (is_known_namespace(name)) 824 return -EOPNOTSUPP; | 815 /* 816 * Don't allow retrieving properly prefixed attributes 817 * by prepending them with "osx." 818 */ 819 if (is_known_namespace(name)) 820 return -EOPNOTSUPP; |
821 xattr_name = kmalloc(NLS_MAX_CHARSET_SIZE * HFSPLUS_ATTR_MAX_STRLEN 822 + XATTR_MAC_OSX_PREFIX_LEN + 1, GFP_KERNEL); 823 if (!xattr_name) 824 return -ENOMEM; 825 strcpy(xattr_name, XATTR_MAC_OSX_PREFIX); 826 strcpy(xattr_name + XATTR_MAC_OSX_PREFIX_LEN, name); |
|
825 | 827 |
826 return hfsplus_getxattr(dentry, xattr_name, buffer, size); | 828 res = hfsplus_getxattr(dentry, xattr_name, buffer, size); 829 kfree(xattr_name); 830 return res; |
827} 828 829static int hfsplus_osx_setxattr(struct dentry *dentry, const char *name, 830 const void *buffer, size_t size, int flags, int type) 831{ | 831} 832 833static int hfsplus_osx_setxattr(struct dentry *dentry, const char *name, 834 const void *buffer, size_t size, int flags, int type) 835{ |
832 char xattr_name[HFSPLUS_ATTR_MAX_STRLEN + 833 XATTR_MAC_OSX_PREFIX_LEN + 1] = {0}; 834 size_t len = strlen(name); | 836 char *xattr_name; 837 int res; |
835 836 if (!strcmp(name, "")) 837 return -EINVAL; 838 | 838 839 if (!strcmp(name, "")) 840 return -EINVAL; 841 |
839 if (len > HFSPLUS_ATTR_MAX_STRLEN) 840 return -EOPNOTSUPP; 841 | |
842 /* 843 * Don't allow setting properly prefixed attributes 844 * by prepending them with "osx." 845 */ 846 if (is_known_namespace(name)) 847 return -EOPNOTSUPP; | 842 /* 843 * Don't allow setting properly prefixed attributes 844 * by prepending them with "osx." 845 */ 846 if (is_known_namespace(name)) 847 return -EOPNOTSUPP; |
848 xattr_name = kmalloc(NLS_MAX_CHARSET_SIZE * HFSPLUS_ATTR_MAX_STRLEN 849 + XATTR_MAC_OSX_PREFIX_LEN + 1, GFP_KERNEL); 850 if (!xattr_name) 851 return -ENOMEM; 852 strcpy(xattr_name, XATTR_MAC_OSX_PREFIX); 853 strcpy(xattr_name + XATTR_MAC_OSX_PREFIX_LEN, name); |
|
848 | 854 |
849 return hfsplus_setxattr(dentry, xattr_name, buffer, size, flags); | 855 res = hfsplus_setxattr(dentry, xattr_name, buffer, size, flags); 856 kfree(xattr_name); 857 return res; |
850} 851 852static size_t hfsplus_osx_listxattr(struct dentry *dentry, char *list, 853 size_t list_size, const char *name, size_t name_len, int type) 854{ 855 /* 856 * This method is not used. 857 * It is used hfsplus_listxattr() instead of generic_listxattr(). 858 */ 859 return -EOPNOTSUPP; 860} 861 862const struct xattr_handler hfsplus_xattr_osx_handler = { 863 .prefix = XATTR_MAC_OSX_PREFIX, 864 .list = hfsplus_osx_listxattr, 865 .get = hfsplus_osx_getxattr, 866 .set = hfsplus_osx_setxattr, 867}; | 858} 859 860static size_t hfsplus_osx_listxattr(struct dentry *dentry, char *list, 861 size_t list_size, const char *name, size_t name_len, int type) 862{ 863 /* 864 * This method is not used. 865 * It is used hfsplus_listxattr() instead of generic_listxattr(). 866 */ 867 return -EOPNOTSUPP; 868} 869 870const struct xattr_handler hfsplus_xattr_osx_handler = { 871 .prefix = XATTR_MAC_OSX_PREFIX, 872 .list = hfsplus_osx_listxattr, 873 .get = hfsplus_osx_getxattr, 874 .set = hfsplus_osx_setxattr, 875}; |