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