2222#include "xattr.h"
2323#include "acl.h"
2424#include "v9fs_vfs.h"
25+ #include "v9fs.h"
2526
2627static struct posix_acl * __v9fs_get_acl (struct p9_fid * fid , char * name )
2728{
@@ -55,7 +56,14 @@ int v9fs_get_acl(struct inode *inode, struct p9_fid *fid)
5556{
5657 int retval = 0 ;
5758 struct posix_acl * pacl , * dacl ;
59+ struct v9fs_session_info * v9ses ;
5860
61+ v9ses = v9fs_inode2v9ses (inode );
62+ if ((v9ses -> flags & V9FS_ACCESS_MASK ) != V9FS_ACCESS_CLIENT ) {
63+ set_cached_acl (inode , ACL_TYPE_DEFAULT , NULL );
64+ set_cached_acl (inode , ACL_TYPE_ACCESS , NULL );
65+ return 0 ;
66+ }
5967 /* get the default/access acl values and cache them */
6068 dacl = __v9fs_get_acl (fid , POSIX_ACL_XATTR_DEFAULT );
6169 pacl = __v9fs_get_acl (fid , POSIX_ACL_XATTR_ACCESS );
@@ -85,7 +93,18 @@ static struct posix_acl *v9fs_get_cached_acl(struct inode *inode, int type)
8593
8694int v9fs_check_acl (struct inode * inode , int mask )
8795{
88- struct posix_acl * acl = v9fs_get_cached_acl (inode , ACL_TYPE_ACCESS );
96+ struct posix_acl * acl ;
97+ struct v9fs_session_info * v9ses ;
98+
99+ v9ses = v9fs_inode2v9ses (inode );
100+ if ((v9ses -> flags & V9FS_ACCESS_MASK ) != V9FS_ACCESS_CLIENT ) {
101+ /*
102+ * On access = client mode get the acl
103+ * values from the server
104+ */
105+ return 0 ;
106+ }
107+ acl = v9fs_get_cached_acl (inode , ACL_TYPE_ACCESS );
89108
90109 if (IS_ERR (acl ))
91110 return PTR_ERR (acl );
@@ -204,15 +223,41 @@ int v9fs_acl_mode(struct inode *dir, mode_t *modep,
204223
205224}
206225
226+ static int v9fs_remote_get_acl (struct dentry * dentry , const char * name ,
227+ void * buffer , size_t size , int type )
228+ {
229+ char * full_name ;
230+
231+ switch (type ) {
232+ case ACL_TYPE_ACCESS :
233+ full_name = POSIX_ACL_XATTR_ACCESS ;
234+ break ;
235+ case ACL_TYPE_DEFAULT :
236+ full_name = POSIX_ACL_XATTR_DEFAULT ;
237+ break ;
238+ default :
239+ BUG ();
240+ }
241+ return v9fs_xattr_get (dentry , full_name , buffer , size );
242+ }
243+
207244static int v9fs_xattr_get_acl (struct dentry * dentry , const char * name ,
208245 void * buffer , size_t size , int type )
209246{
247+ struct v9fs_session_info * v9ses ;
210248 struct posix_acl * acl ;
211249 int error ;
212250
213251 if (strcmp (name , "" ) != 0 )
214252 return - EINVAL ;
215253
254+ v9ses = v9fs_inode2v9ses (dentry -> d_inode );
255+ /*
256+ * We allow set/get/list of acl when access=client is not specified
257+ */
258+ if ((v9ses -> flags & V9FS_ACCESS_MASK ) != V9FS_ACCESS_CLIENT )
259+ return v9fs_remote_get_acl (dentry , name , buffer , size , type );
260+
216261 acl = v9fs_get_cached_acl (dentry -> d_inode , type );
217262 if (IS_ERR (acl ))
218263 return PTR_ERR (acl );
@@ -224,16 +269,47 @@ static int v9fs_xattr_get_acl(struct dentry *dentry, const char *name,
224269 return error ;
225270}
226271
272+ static int v9fs_remote_set_acl (struct dentry * dentry , const char * name ,
273+ const void * value , size_t size ,
274+ int flags , int type )
275+ {
276+ char * full_name ;
277+
278+ switch (type ) {
279+ case ACL_TYPE_ACCESS :
280+ full_name = POSIX_ACL_XATTR_ACCESS ;
281+ break ;
282+ case ACL_TYPE_DEFAULT :
283+ full_name = POSIX_ACL_XATTR_DEFAULT ;
284+ break ;
285+ default :
286+ BUG ();
287+ }
288+ return v9fs_xattr_set (dentry , full_name , value , size , flags );
289+ }
290+
291+
227292static int v9fs_xattr_set_acl (struct dentry * dentry , const char * name ,
228293 const void * value , size_t size ,
229294 int flags , int type )
230295{
231296 int retval ;
232297 struct posix_acl * acl ;
298+ struct v9fs_session_info * v9ses ;
233299 struct inode * inode = dentry -> d_inode ;
234300
235301 if (strcmp (name , "" ) != 0 )
236302 return - EINVAL ;
303+
304+ v9ses = v9fs_inode2v9ses (dentry -> d_inode );
305+ /*
306+ * set the attribute on the remote. Without even looking at the
307+ * xattr value. We leave it to the server to validate
308+ */
309+ if ((v9ses -> flags & V9FS_ACCESS_MASK ) != V9FS_ACCESS_CLIENT )
310+ return v9fs_remote_set_acl (dentry , name ,
311+ value , size , flags , type );
312+
237313 if (S_ISLNK (inode -> i_mode ))
238314 return - EOPNOTSUPP ;
239315 if (!is_owner_or_cap (inode ))
0 commit comments