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 #include "HPSSclapiExt/hpssclapiext.h" 00022 00023 #include <hpss_errno.h> 00024 00046 fsal_status_t HPSSFSAL_getattrs(hpssfsal_handle_t * filehandle, /* IN */ 00047 hpssfsal_op_context_t * p_context, /* IN */ 00048 fsal_attrib_list_t * object_attributes /* IN/OUT */ 00049 ) 00050 { 00051 00052 int rc; 00053 fsal_status_t status; 00054 ns_ObjHandle_t hpss_hdl; 00055 hpss_Attrs_t hpss_attr; 00056 00057 /* sanity checks. 00058 * note : object_attributes is mandatory in FSAL_getattrs. 00059 */ 00060 if(!filehandle || !p_context || !object_attributes) 00061 Return(ERR_FSAL_FAULT, 0, INDEX_FSAL_getattrs); 00062 00063 /* get attributes */ 00064 /* We use HPSSFSAL_GetRawAttrHandle for not chasing junctions 00065 * nor solving symlinks. What's more, we want hpss_Attrs_t. 00066 */ 00067 00068 TakeTokenFSCall(); 00069 00070 rc = HPSSFSAL_GetRawAttrHandle(&(filehandle->data.ns_handle), NULL, &p_context->credential.hpss_usercred, FALSE, /* don't solve junctions */ 00071 &hpss_hdl, NULL, &hpss_attr); 00072 00073 ReleaseTokenFSCall(); 00074 00075 /* The HPSS_ENOENT error actually means that handle is STALE */ 00076 if(rc == HPSS_ENOENT) 00077 Return(ERR_FSAL_STALE, -rc, INDEX_FSAL_getattrs); 00078 else if(rc) 00079 Return(hpss2fsal_error(rc), -rc, INDEX_FSAL_getattrs); 00080 00081 /* convert attributes */ 00082 00083 status = hpss2fsal_attributes(&hpss_hdl, &hpss_attr, object_attributes); 00084 00085 if(FSAL_IS_ERROR(status)) 00086 Return(status.major, status.minor, INDEX_FSAL_getattrs); 00087 00088 Return(ERR_FSAL_NO_ERROR, 0, INDEX_FSAL_getattrs); 00089 00090 } 00091 00125 fsal_status_t HPSSFSAL_setattrs(hpssfsal_handle_t * filehandle, /* IN */ 00126 hpssfsal_op_context_t * p_context, /* IN */ 00127 fsal_attrib_list_t * attrib_set, /* IN */ 00128 fsal_attrib_list_t * object_attributes /* [ IN/OUT ] */ 00129 ) 00130 { 00131 00132 int rc; 00133 fsal_status_t status; 00134 fsal_attrib_list_t attrs; 00135 00136 hpss_fileattrbits_t hpss_attr_mask; 00137 hpss_fileattr_t hpss_fattr_in, hpss_fattr_out; 00138 00139 /* sanity checks. 00140 * note : object_attributes is optional. 00141 */ 00142 if(!filehandle || !p_context || !attrib_set) 00143 Return(ERR_FSAL_FAULT, 0, INDEX_FSAL_setattrs); 00144 00145 /* local copy of attributes */ 00146 attrs = *attrib_set; 00147 00148 /* First, check that FSAL attributes changes are allowed. */ 00149 00150 /* Is it allowed to change times ? */ 00151 00152 if(!global_fs_info.cansettime) 00153 { 00154 00155 if(attrs.asked_attributes 00156 & (FSAL_ATTR_ATIME | FSAL_ATTR_CREATION | FSAL_ATTR_CTIME | FSAL_ATTR_MTIME)) 00157 { 00158 00159 /* handled as an unsettable attribute. */ 00160 Return(ERR_FSAL_INVAL, 0, INDEX_FSAL_setattrs); 00161 } 00162 00163 } 00164 00165 /* apply umask, if mode attribute is to be changed */ 00166 00167 if(FSAL_TEST_MASK(attrs.asked_attributes, FSAL_ATTR_MODE)) 00168 { 00169 attrs.mode &= (~global_fs_info.umask); 00170 } 00171 00174 /* init variables */ 00175 memset(&hpss_fattr_in, 0, sizeof(hpss_fileattr_t)); 00176 00177 hpss_fattr_in.ObjectHandle = filehandle->data.ns_handle; 00178 00179 /* Then, convert attribute set. */ 00180 00181 status = fsal2hpss_attribset(filehandle, 00182 &attrs, &hpss_attr_mask, &(hpss_fattr_in.Attrs)); 00183 00184 if(FSAL_IS_ERROR(status)) 00185 Return(status.major, status.minor, INDEX_FSAL_setattrs); 00186 00187 /* Call HPSS client API function. */ 00188 00189 TakeTokenFSCall(); 00190 00191 rc = HPSSFSAL_FileSetAttrHandle(&(filehandle->data.ns_handle), /* IN - object handle */ 00192 NULL, /* IN - path to the object */ 00193 &(p_context->credential.hpss_usercred), /* IN - user credentials */ 00194 hpss_attr_mask, /* IN - attributes fields to set */ 00195 &hpss_fattr_in, /* IN - input attributes */ 00196 &hpss_fattr_out /* OUT - attributes after change */ 00197 ); 00198 00199 ReleaseTokenFSCall(); 00200 00201 /* The HPSS_ENOENT error actually means that handle is STALE */ 00202 if(rc == HPSS_ENOENT) 00203 Return(ERR_FSAL_STALE, -rc, INDEX_FSAL_setattrs); 00204 else if(rc) 00205 Return(hpss2fsal_error(rc), -rc, INDEX_FSAL_setattrs); 00206 00207 /* Optionaly fills output attributes. */ 00208 00212 /* 00213 * HPSS only fills the modified attribute in hpss_fattr_out. 00214 * Thus, if the modified attributes equal the attributes to be returned 00215 * there is no need to proceed a getattr. 00216 */ 00217 if(object_attributes && 00218 (object_attributes->asked_attributes == attrib_set->asked_attributes)) 00219 { 00220 00221 /* caution: hpss_fattr_out.ObjectHandle is not filled. */ 00222 00223 status = hpss2fsal_attributes(&(filehandle->data.ns_handle), 00224 &(hpss_fattr_out.Attrs), object_attributes); 00225 00226 /* on error, we set a special bit in the mask. */ 00227 if(FSAL_IS_ERROR(status)) 00228 { 00229 FSAL_CLEAR_MASK(object_attributes->asked_attributes); 00230 FSAL_SET_MASK(object_attributes->asked_attributes, FSAL_ATTR_RDATTR_ERR); 00231 } 00232 00233 } 00234 /* if more attributes are asked, we have to proceed a getattr. */ 00235 else if(object_attributes) 00236 { 00237 00238 status = HPSSFSAL_getattrs(filehandle, p_context, object_attributes); 00239 00240 /* on error, we set a special bit in the mask. */ 00241 if(FSAL_IS_ERROR(status)) 00242 { 00243 FSAL_CLEAR_MASK(object_attributes->asked_attributes); 00244 FSAL_SET_MASK(object_attributes->asked_attributes, FSAL_ATTR_RDATTR_ERR); 00245 } 00246 00247 } 00248 00249 Return(ERR_FSAL_NO_ERROR, 0, INDEX_FSAL_setattrs); 00250 00251 } 00271 fsal_status_t HPSSFSAL_getextattrs(hpssfsal_handle_t * p_filehandle, /* IN */ 00272 hpssfsal_op_context_t * p_context, /* IN */ 00273 fsal_extattrib_list_t * p_object_attributes /* OUT */ 00274 ) 00275 { 00276 Return(ERR_FSAL_NOTSUPP, 0, INDEX_FSAL_getextattrs); 00277 } /* HPSSFSAL_getextattrs */