@@ -1066,19 +1066,22 @@ ecryptfs_listxattr(struct dentry *dentry, char *list, size_t size)
10661066 return rc ;
10671067}
10681068
1069- static int ecryptfs_removexattr (struct dentry * dentry , const char * name )
1069+ static int ecryptfs_removexattr (struct dentry * dentry , struct inode * inode ,
1070+ const char * name )
10701071{
10711072 int rc = 0 ;
10721073 struct dentry * lower_dentry ;
1074+ struct inode * lower_inode ;
10731075
10741076 lower_dentry = ecryptfs_dentry_to_lower (dentry );
1075- if (!d_inode (lower_dentry )-> i_op -> removexattr ) {
1077+ lower_inode = ecryptfs_inode_to_lower (inode );
1078+ if (!lower_inode -> i_op -> removexattr ) {
10761079 rc = - EOPNOTSUPP ;
10771080 goto out ;
10781081 }
1079- inode_lock (d_inode ( lower_dentry ) );
1080- rc = d_inode ( lower_dentry ) -> i_op -> removexattr (lower_dentry , name );
1081- inode_unlock (d_inode ( lower_dentry ) );
1082+ inode_lock (lower_inode );
1083+ rc = lower_inode -> i_op -> removexattr (lower_dentry , name );
1084+ inode_unlock (lower_inode );
10821085out :
10831086 return rc ;
10841087}
@@ -1089,10 +1092,10 @@ const struct inode_operations ecryptfs_symlink_iops = {
10891092 .permission = ecryptfs_permission ,
10901093 .setattr = ecryptfs_setattr ,
10911094 .getattr = ecryptfs_getattr_link ,
1092- .setxattr = ecryptfs_setxattr ,
1093- .getxattr = ecryptfs_getxattr ,
1095+ .setxattr = generic_setxattr ,
1096+ .getxattr = generic_getxattr ,
10941097 .listxattr = ecryptfs_listxattr ,
1095- .removexattr = ecryptfs_removexattr
1098+ .removexattr = generic_removexattr
10961099};
10971100
10981101const struct inode_operations ecryptfs_dir_iops = {
@@ -1107,18 +1110,49 @@ const struct inode_operations ecryptfs_dir_iops = {
11071110 .rename = ecryptfs_rename ,
11081111 .permission = ecryptfs_permission ,
11091112 .setattr = ecryptfs_setattr ,
1110- .setxattr = ecryptfs_setxattr ,
1111- .getxattr = ecryptfs_getxattr ,
1113+ .setxattr = generic_setxattr ,
1114+ .getxattr = generic_getxattr ,
11121115 .listxattr = ecryptfs_listxattr ,
1113- .removexattr = ecryptfs_removexattr
1116+ .removexattr = generic_removexattr
11141117};
11151118
11161119const struct inode_operations ecryptfs_main_iops = {
11171120 .permission = ecryptfs_permission ,
11181121 .setattr = ecryptfs_setattr ,
11191122 .getattr = ecryptfs_getattr ,
1120- .setxattr = ecryptfs_setxattr ,
1121- .getxattr = ecryptfs_getxattr ,
1123+ .setxattr = generic_setxattr ,
1124+ .getxattr = generic_getxattr ,
11221125 .listxattr = ecryptfs_listxattr ,
1123- .removexattr = ecryptfs_removexattr
1126+ .removexattr = generic_removexattr
1127+ };
1128+
1129+ static int ecryptfs_xattr_get (const struct xattr_handler * handler ,
1130+ struct dentry * dentry , struct inode * inode ,
1131+ const char * name , void * buffer , size_t size )
1132+ {
1133+ return ecryptfs_getxattr (dentry , inode , name , buffer , size );
1134+ }
1135+
1136+ static int ecryptfs_xattr_set (const struct xattr_handler * handler ,
1137+ struct dentry * dentry , struct inode * inode ,
1138+ const char * name , const void * value , size_t size ,
1139+ int flags )
1140+ {
1141+ if (value )
1142+ return ecryptfs_setxattr (dentry , inode , name , value , size , flags );
1143+ else {
1144+ BUG_ON (flags != XATTR_REPLACE );
1145+ return ecryptfs_removexattr (dentry , inode , name );
1146+ }
1147+ }
1148+
1149+ const struct xattr_handler ecryptfs_xattr_handler = {
1150+ .prefix = "" , /* match anything */
1151+ .get = ecryptfs_xattr_get ,
1152+ .set = ecryptfs_xattr_set ,
1153+ };
1154+
1155+ const struct xattr_handler * ecryptfs_xattr_handlers [] = {
1156+ & ecryptfs_xattr_handler ,
1157+ NULL
11241158};
0 commit comments