nfs-ganesha 1.4
|
00001 /* 00002 * vim:expandtab:shiftwidth=4:tabstop=4: 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 00053 fsal_status_t LUSTREFSAL_access(fsal_handle_t * p_object_handle, /* IN */ 00054 fsal_op_context_t * p_context, /* IN */ 00055 fsal_accessflags_t access_type, /* IN */ 00056 fsal_attrib_list_t * p_object_attributes /* [ IN/OUT ] */ 00057 ) 00058 { 00059 00060 fsal_status_t status; 00061 00062 /* sanity checks. 00063 * note : object_attributes is optionnal in FSAL_getattrs. 00064 */ 00065 if(!p_object_handle || !p_context) 00066 Return(ERR_FSAL_FAULT, 0, INDEX_FSAL_access); 00067 00068 /* 00069 * If an error occures during getattr operation, 00070 * it is returned, even though the access operation succeeded. 00071 */ 00072 00073 if(p_object_attributes) 00074 { 00075 00076 FSAL_SET_MASK(p_object_attributes->asked_attributes, 00077 FSAL_ATTR_OWNER | FSAL_ATTR_GROUP | FSAL_ATTR_ACL | FSAL_ATTR_MODE); 00078 status = LUSTREFSAL_getattrs(p_object_handle, p_context, p_object_attributes); 00079 00080 /* on error, we set a special bit in the mask. */ 00081 if(FSAL_IS_ERROR(status)) 00082 { 00083 FSAL_CLEAR_MASK(p_object_attributes->asked_attributes); 00084 FSAL_SET_MASK(p_object_attributes->asked_attributes, FSAL_ATTR_RDATTR_ERR); 00085 Return(status.major, status.minor, INDEX_FSAL_access); 00086 } 00087 00088 status = 00089 fsal_internal_testAccess(p_context, access_type, NULL, p_object_attributes); 00090 00091 } 00092 else 00093 { /* p_object_attributes is NULL */ 00094 fsal_attrib_list_t attrs; 00095 00096 FSAL_CLEAR_MASK(attrs.asked_attributes); 00097 FSAL_SET_MASK(attrs.asked_attributes, 00098 FSAL_ATTR_OWNER | FSAL_ATTR_GROUP | FSAL_ATTR_ACL | FSAL_ATTR_MODE); 00099 00100 status = LUSTREFSAL_getattrs(p_object_handle, p_context, &attrs); 00101 00102 /* on error, we set a special bit in the mask. */ 00103 if(FSAL_IS_ERROR(status)) 00104 Return(status.major, status.minor, INDEX_FSAL_access); 00105 00106 status = fsal_internal_testAccess(p_context, access_type, NULL, &attrs); 00107 } 00108 00109 Return(status.major, status.minor, INDEX_FSAL_access); 00110 00111 }