nfs-ganesha 1.4

fsal_attrs.c

Go to the documentation of this file.
00001 /*
00002  * vim:expandtab:shiftwidth=8:tabstop=8:
00003  */
00004 
00014 #ifdef HAVE_CONFIG_H
00015 #include "config.h"
00016 #endif
00017 
00018 #include "fsal.h"
00019 #include "fsal_internal.h"
00020 #include "fsal_convert.h"
00021 
00043 fsal_status_t FSAL_getattrs(fsal_handle_t * filehandle, /* IN */
00044                             fsal_op_context_t * p_context,      /* IN */
00045                             fsal_attrib_list_t * object_attributes      /* IN/OUT */
00046     )
00047 {
00048 
00049   int rc;
00050   fsal_status_t status;
00051 
00052   /* sanity checks.
00053    * note : object_attributes is mandatory in FSAL_getattrs.
00054    */
00055   if(!filehandle || !p_context || !object_attributes)
00056     Return(ERR_FSAL_FAULT, 0, INDEX_FSAL_getattrs);
00057 
00058   TakeTokenFSCall();
00059 
00060   /* >> get attributes from your filesystem << */
00061 
00062   ReleaseTokenFSCall();
00063 
00064   /* >> convert error code, and return on error << */
00065 
00066   /* >> convert your filesystem attributes to FSAL attributes << */
00067 
00068   Return(ERR_FSAL_NO_ERROR, 0, INDEX_FSAL_getattrs);
00069 
00070 }
00071 
00105 fsal_status_t FSAL_setattrs(fsal_handle_t * filehandle, /* IN */
00106                             fsal_op_context_t * p_context,      /* IN */
00107                             fsal_attrib_list_t * attrib_set,    /* IN */
00108                             fsal_attrib_list_t * object_attributes      /* [ IN/OUT ] */
00109     )
00110 {
00111 
00112   int rc;
00113   fsal_status_t status;
00114   fsal_attrib_list_t attrs;
00115 
00116   /* sanity checks.
00117    * note : object_attributes is optional.
00118    */
00119   if(!filehandle || !p_context || !attrib_set)
00120     Return(ERR_FSAL_FAULT, 0, INDEX_FSAL_setattrs);
00121 
00122   /* local copy of attributes */
00123   attrs = *attrib_set;
00124 
00125   /* First, check that FSAL attributes changes are allowed. */
00126 
00127   /* Is it allowed to change times ? */
00128 
00129   if(!global_fs_info.cansettime)
00130     {
00131 
00132       if(attrs.asked_attributes
00133          & (FSAL_ATTR_ATIME | FSAL_ATTR_CREATION | FSAL_ATTR_CTIME | FSAL_ATTR_MTIME))
00134         {
00135 
00136           /* handled as an unsettable attribute. */
00137           Return(ERR_FSAL_INVAL, 0, INDEX_FSAL_setattrs);
00138         }
00139 
00140     }
00141 
00142   /* apply umask, if mode attribute is to be changed */
00143 
00144   if(FSAL_TEST_MASK(attrs.asked_attributes, FSAL_ATTR_MODE))
00145     {
00146       attrs.mode &= (~global_fs_info.umask);
00147     }
00148 
00149   /* >> Then, convert the attribute set to your FS format << */
00150 
00151   TakeTokenFSCall();
00152 
00153   /* >> Call your fs setattr function << */
00154 
00155   ReleaseTokenFSCall();
00156 
00157   /* >> convert error code, and return on error << */
00158 
00159   /* >> Optionaly fill output attributes.
00160    * If your filesystem setattr call doesn't
00161    * return object attributes, you may do something
00162    * like that : << */
00163 
00164   if(object_attributes)
00165     {
00166 
00167       status = FSAL_getattrs(filehandle, p_context, object_attributes);
00168 
00169       /* on error, we set a special bit in the mask. */
00170       if(FSAL_IS_ERROR(status))
00171         {
00172           FSAL_CLEAR_MASK(object_attributes->asked_attributes);
00173           FSAL_SET_MASK(object_attributes->asked_attributes, FSAL_ATTR_RDATTR_ERR);
00174         }
00175 
00176     }
00177 
00178   Return(ERR_FSAL_NO_ERROR, 0, INDEX_FSAL_setattrs);
00179 
00180 }
00181 
00201 fsal_status_t FSAL_getextattrs(fsal_handle_t * p_filehandle, /* IN */
00202                                fsal_op_context_t * p_context,        /* IN */
00203                                fsal_extattrib_list_t * p_object_attributes /* OUT */
00204     )
00205 {
00206   Return(ERR_FSAL_NOTSUPP, 0, INDEX_FSAL_getextattrs);
00207 } /* FSAL_getextattrs */