nfs-ganesha 1.4
|
00001 00009 #ifdef HAVE_CONFIG_H 00010 #include "config.h" 00011 #endif 00012 00013 #ifdef _SOLARIS 00014 #include "solaris_port.h" 00015 #endif /* _SOLARIS */ 00016 00017 #include "fsal.h" 00018 #include "fsal_internal.h" 00019 #include "fsal_convert.h" 00020 00021 #include <string.h> 00022 00023 /* generic definitions for extended attributes */ 00024 00025 #define XATTR_FOR_FILE 0x00000001 00026 #define XATTR_FOR_DIR 0x00000002 00027 #define XATTR_FOR_SYMLINK 0x00000004 00028 #define XATTR_FOR_ALL 0x0000000F 00029 #define XATTR_RO 0x00000100 00030 #define XATTR_RW 0x00000200 00031 00032 /* function for getting an attribute value */ 00033 00034 typedef int (*xattr_getfunc_t) (proxyfsal_handle_t *, /* object handle */ 00035 proxyfsal_op_context_t *, /* context */ 00036 caddr_t, /* output buff */ 00037 size_t, /* output buff size */ 00038 size_t *); /* output size */ 00039 00040 typedef int (*xattr_setfunc_t) (proxyfsal_handle_t *, /* object handle */ 00041 proxyfsal_op_context_t *, /* context */ 00042 caddr_t, /* input buff */ 00043 size_t, /* input size */ 00044 int); /* creation flag */ 00045 00046 typedef int (*xattr_printfunc_t) (caddr_t, /* Input buffer */ 00047 size_t, /* Input size */ 00048 caddr_t, /* Output (ASCII) buffer */ 00049 size_t *); /* Output size */ 00050 00051 typedef struct fsal_xattr_def__ 00052 { 00053 char xattr_name[FSAL_MAX_NAME_LEN]; 00054 xattr_getfunc_t get_func; 00055 xattr_setfunc_t set_func; 00056 xattr_printfunc_t print_func; 00057 int flags; 00058 } fsal_xattr_def_t; 00059 00060 /* 00061 * XATTRS GET/SET FUNCTIONS 00062 */ 00063 00064 int get_svr_addr(proxyfsal_handle_t * p_objecthandle, /* IN */ 00065 proxyfsal_op_context_t * p_context, /* IN */ 00066 caddr_t buffer_addr, /* IN/OUT */ 00067 size_t buffer_size, /* IN */ 00068 size_t * p_output_size) /* OUT */ 00069 { 00070 uint32_t addr; 00071 00072 if(!p_objecthandle || !p_context || !p_output_size) 00073 return ERR_FSAL_FAULT; 00074 00075 addr = ntohl(p_context->srv_addr); 00076 00077 snprintf((char *)buffer_addr, buffer_size, "%u.%u.%u.%u", 00078 (addr & 0xFF000000) >> 24, 00079 (addr & 0x00FF0000) >> 16, (addr & 0x0000FF00) >> 8, (addr & 0x000000FF)); 00080 00081 *p_output_size = strlen((char *)buffer_addr) + 1; 00082 00083 return 0; 00084 00085 } 00086 00087 int get_svr_port(proxyfsal_handle_t * p_objecthandle, /* IN */ 00088 proxyfsal_op_context_t * p_context, /* IN */ 00089 caddr_t buffer_addr, /* IN/OUT */ 00090 size_t buffer_size, /* IN */ 00091 size_t * p_output_size) /* OUT */ 00092 { 00093 uint16_t port; 00094 00095 if(!p_objecthandle || !p_context || !p_output_size) 00096 return ERR_FSAL_FAULT; 00097 00098 port = ntohs(p_context->srv_port); 00099 00100 snprintf((char *)buffer_addr, buffer_size, "%hu", port); 00101 00102 *p_output_size = strlen((char *)buffer_addr) + 1; 00103 00104 return 0; 00105 00106 } 00107 00108 int get_prognum(proxyfsal_handle_t * p_objecthandle, /* IN */ 00109 proxyfsal_op_context_t * p_context, /* IN */ 00110 caddr_t buffer_addr, /* IN/OUT */ 00111 size_t buffer_size, /* IN */ 00112 size_t * p_output_size) /* OUT */ 00113 { 00114 if(!p_objecthandle || !p_context || !p_output_size) 00115 return ERR_FSAL_FAULT; 00116 00117 snprintf((char *)buffer_addr, buffer_size, "%u", p_context->srv_prognum); 00118 00119 *p_output_size = strlen((char *)buffer_addr) + 1; 00120 00121 return 0; 00122 00123 } 00124 00125 int get_proto(proxyfsal_handle_t * p_objecthandle, /* IN */ 00126 proxyfsal_op_context_t * p_context, /* IN */ 00127 caddr_t buffer_addr, /* IN/OUT */ 00128 size_t buffer_size, /* IN */ 00129 size_t * p_output_size) /* OUT */ 00130 { 00131 if(!p_objecthandle || !p_context || !p_output_size) 00132 return ERR_FSAL_FAULT; 00133 00134 snprintf((char *)buffer_addr, buffer_size, "%s", p_context->srv_proto); 00135 00136 *p_output_size = strlen((char *)buffer_addr) + 1; 00137 00138 return 0; 00139 00140 } 00141 00142 int get_clientid(proxyfsal_handle_t * p_objecthandle, /* IN */ 00143 proxyfsal_op_context_t * p_context, /* IN */ 00144 caddr_t buffer_addr, /* IN/OUT */ 00145 size_t buffer_size, /* IN */ 00146 size_t * p_output_size) /* OUT */ 00147 { 00148 if(!p_objecthandle || !p_context || !p_output_size) 00149 return ERR_FSAL_FAULT; 00150 00151 snprintf((char *)buffer_addr, buffer_size, "%llX", 00152 (unsigned long long int)p_context->clientid); 00153 00154 *p_output_size = strlen((char *)buffer_addr) + 1; 00155 00156 return 0; 00157 00158 } 00159 00160 int get_type(proxyfsal_handle_t * p_objecthandle, /* IN */ 00161 proxyfsal_op_context_t * p_context, /* IN */ 00162 caddr_t buffer_addr, /* IN/OUT */ 00163 size_t buffer_size, /* IN */ 00164 size_t * p_output_size) /* OUT */ 00165 { 00166 if(!p_objecthandle || !p_context || !p_output_size) 00167 return ERR_FSAL_FAULT; 00168 00169 switch (p_objecthandle->data.object_type_reminder) 00170 { 00171 case FSAL_TYPE_DIR: 00172 strncpy((char *)buffer_addr, "directory", buffer_size); 00173 break; 00174 00175 case FSAL_TYPE_FILE: 00176 strncpy((char *)buffer_addr, "file", buffer_size); 00177 break; 00178 00179 case FSAL_TYPE_LNK: 00180 strncpy((char *)buffer_addr, "symlink", buffer_size); 00181 break; 00182 00183 case FSAL_TYPE_JUNCTION: 00184 strncpy((char *)buffer_addr, "junction", buffer_size); 00185 break; 00186 00187 default: 00188 strncpy((char *)buffer_addr, "other/unknown", buffer_size); 00189 break; 00190 } 00191 00192 ((char *)buffer_addr)[strlen((char *)buffer_addr)] = '\n'; 00193 *p_output_size = strlen((char *)buffer_addr) + 1; 00194 return 0; 00195 00196 } 00197 00198 int get_svr_handle(proxyfsal_handle_t * p_objecthandle, /* IN */ 00199 proxyfsal_op_context_t * p_context, /* IN */ 00200 caddr_t buffer_addr, /* IN/OUT */ 00201 size_t buffer_size, /* IN */ 00202 size_t * p_output_size) /* OUT */ 00203 { 00204 if(!p_objecthandle || !p_context || !p_output_size) 00205 return ERR_FSAL_FAULT; 00206 00207 /* truncate it if buffer is too small */ 00208 if(p_objecthandle->data.srv_handle_len > buffer_size) 00209 { 00210 memcpy(buffer_addr, p_objecthandle->data.srv_handle_val, buffer_size); 00211 *p_output_size = buffer_size; 00212 } 00213 else 00214 { 00215 memcpy(buffer_addr, p_objecthandle->data.srv_handle_val, p_objecthandle->data.srv_handle_len); 00216 *p_output_size = p_objecthandle->data.srv_handle_len; 00217 } 00218 00219 return 0; 00220 00221 } 00222 00223 int print_srv_handle(caddr_t InBuff, size_t InSize, caddr_t OutBuff, size_t * pOutSize) 00224 { 00225 unsigned int i = 0; 00226 size_t MaxSize = (InSize < *pOutSize / 2) ? InSize : *pOutSize / 2; 00227 00228 for(i = 0; i < MaxSize; i++) 00229 *pOutSize += 00230 sprintf(&(((char *)OutBuff)[i * 2]), "%02x", 00231 (unsigned char)(((char *)InBuff)[i])); 00232 00233 return 0; 00234 } /* print_srv_handle */ 00235 00236 /* ATTRIBUTES LIST */ 00237 00238 static fsal_xattr_def_t xattr_list[] = { 00239 {"type", get_type, NULL, NULL, XATTR_FOR_ALL | XATTR_RO}, 00240 {"remote_handle", get_svr_handle, NULL, print_srv_handle, XATTR_FOR_ALL | XATTR_RO}, 00241 {"client_id", get_clientid, NULL, NULL, XATTR_FOR_ALL | XATTR_RO}, 00242 {"remote_server_addr", get_svr_addr, NULL, NULL, XATTR_FOR_ALL | XATTR_RO}, 00243 {"remote_server_port", get_svr_port, NULL, NULL, XATTR_FOR_ALL | XATTR_RO}, 00244 {"nfs_prognum", get_prognum, NULL, NULL, XATTR_FOR_ALL | XATTR_RO}, 00245 {"protocol", get_proto, NULL, NULL, XATTR_FOR_ALL | XATTR_RO} 00246 }; 00247 00248 #define XATTR_COUNT 8 00249 00250 /* we assume that this number is < 254 */ 00251 #if ( XATTR_COUNT > 254 ) 00252 #error "ERROR: xattr count > 254" 00253 #endif 00254 00255 /* YOUR SHOULD NOT HAVE TO MODIFY THE FOLLOWING FUNCTIONS */ 00256 00257 /* test if an object has a given attribute */ 00258 int do_match_type(int xattr_flag, fsal_nodetype_t obj_type) 00259 { 00260 switch (obj_type) 00261 { 00262 case FSAL_TYPE_FILE: 00263 return ((xattr_flag & XATTR_FOR_FILE) == XATTR_FOR_FILE); 00264 00265 case FSAL_TYPE_DIR: 00266 return ((xattr_flag & XATTR_FOR_DIR) == XATTR_FOR_DIR); 00267 00268 case FSAL_TYPE_LNK: 00269 return ((xattr_flag & XATTR_FOR_SYMLINK) == XATTR_FOR_SYMLINK); 00270 00271 default: 00272 return ((xattr_flag & XATTR_FOR_ALL) == XATTR_FOR_ALL); 00273 } 00274 } 00275 00276 static int file_attributes_to_xattr_attrs(fsal_attrib_list_t * file_attrs, 00277 fsal_attrib_list_t * p_xattr_attrs, 00278 unsigned int attr_index) 00279 { 00280 00281 /* supported attributes are: 00282 * - owner (same as the objet) 00283 * - group (same as the objet) 00284 * - type FSAL_TYPE_XATTR 00285 * - fileid (attr index ? or (fileid^((index+1)<<24)) ) 00286 * - mode (config & file) 00287 * - atime, mtime, ctime = these of the object ? 00288 * - size=1block, used=1block 00289 * - rdev=0 00290 * - nlink=1 00291 */ 00292 fsal_attrib_mask_t supported = FSAL_ATTR_SUPPATTR | FSAL_ATTR_MODE | FSAL_ATTR_FILEID 00293 | FSAL_ATTR_TYPE | FSAL_ATTR_OWNER | FSAL_ATTR_GROUP 00294 | FSAL_ATTR_ATIME | FSAL_ATTR_MTIME | FSAL_ATTR_CTIME 00295 | FSAL_ATTR_CREATION | FSAL_ATTR_CHGTIME | FSAL_ATTR_SIZE 00296 | FSAL_ATTR_SPACEUSED | FSAL_ATTR_NUMLINKS | FSAL_ATTR_RAWDEV | FSAL_ATTR_FSID; 00297 fsal_attrib_mask_t unsupp; 00298 00299 /* only those supported by filesystem */ 00300 supported &= global_fs_info.supported_attrs; 00301 00302 if(p_xattr_attrs->asked_attributes == 0) 00303 { 00304 p_xattr_attrs->asked_attributes = supported; 00305 00306 LogCrit(COMPONENT_FSAL, 00307 "Error: p_xattr_attrs->asked_attributes was 0 in %s() line %d, file %s", 00308 __FUNCTION__, __LINE__, __FILE__); 00309 } 00310 00311 unsupp = p_xattr_attrs->asked_attributes & (~supported); 00312 00313 if(unsupp) 00314 { 00315 LogDebug(COMPONENT_FSAL, 00316 "Asking for unsupported attributes in %s(): %#llX removing it from asked attributes", 00317 __FUNCTION__, unsupp); 00318 00319 p_xattr_attrs->asked_attributes &= (~unsupp); 00320 } 00321 00322 if(p_xattr_attrs->asked_attributes & FSAL_ATTR_SUPPATTR) 00323 p_xattr_attrs->supported_attributes = supported; 00324 00325 if(p_xattr_attrs->asked_attributes & FSAL_ATTR_MODE) 00326 { 00327 p_xattr_attrs->mode = file_attrs->mode & global_fs_info.xattr_access_rights; 00328 if(xattr_list[attr_index].flags & XATTR_RO) 00329 p_xattr_attrs->mode &= ~(0222); 00330 } 00331 00332 if(p_xattr_attrs->asked_attributes & FSAL_ATTR_FILEID) 00333 { 00334 unsigned int i; 00335 unsigned long hash = attr_index + 1; 00336 char *str = (char *)&file_attrs->fileid; 00337 00338 for(i = 0; i < sizeof(p_xattr_attrs->fileid); i++, str++) 00339 { 00340 hash = (hash << 5) - hash + (unsigned long)(*str); 00341 } 00342 p_xattr_attrs->fileid = hash; 00343 } 00344 00345 if(p_xattr_attrs->asked_attributes & FSAL_ATTR_TYPE) 00346 p_xattr_attrs->type = FSAL_TYPE_XATTR; 00347 00348 if(p_xattr_attrs->asked_attributes & FSAL_ATTR_OWNER) 00349 p_xattr_attrs->owner = file_attrs->owner; 00350 00351 if(p_xattr_attrs->asked_attributes & FSAL_ATTR_GROUP) 00352 p_xattr_attrs->group = file_attrs->group; 00353 00354 if(p_xattr_attrs->asked_attributes & FSAL_ATTR_ATIME) 00355 p_xattr_attrs->atime = file_attrs->atime; 00356 00357 if(p_xattr_attrs->asked_attributes & FSAL_ATTR_MTIME) 00358 p_xattr_attrs->mtime = file_attrs->mtime; 00359 00360 if(p_xattr_attrs->asked_attributes & FSAL_ATTR_CTIME) 00361 p_xattr_attrs->ctime = file_attrs->ctime; 00362 00363 if(p_xattr_attrs->asked_attributes & FSAL_ATTR_CREATION) 00364 p_xattr_attrs->creation = file_attrs->creation; 00365 00366 if(p_xattr_attrs->asked_attributes & FSAL_ATTR_CHGTIME) 00367 { 00368 p_xattr_attrs->chgtime = file_attrs->chgtime; 00369 p_xattr_attrs->change = (uint64_t) p_xattr_attrs->chgtime.seconds; 00370 } 00371 00372 if(p_xattr_attrs->asked_attributes & FSAL_ATTR_SIZE) 00373 p_xattr_attrs->filesize = DEV_BSIZE; 00374 00375 if(p_xattr_attrs->asked_attributes & FSAL_ATTR_SPACEUSED) 00376 p_xattr_attrs->spaceused = DEV_BSIZE; 00377 00378 if(p_xattr_attrs->asked_attributes & FSAL_ATTR_NUMLINKS) 00379 p_xattr_attrs->numlinks = 1; 00380 00381 if(p_xattr_attrs->asked_attributes & FSAL_ATTR_RAWDEV) 00382 { 00383 p_xattr_attrs->rawdev.major = 0; 00384 p_xattr_attrs->rawdev.minor = 0; 00385 } 00386 00387 if(p_xattr_attrs->asked_attributes & FSAL_ATTR_FSID) 00388 { 00389 p_xattr_attrs->fsid = file_attrs->fsid; 00390 } 00391 00392 /* if mode==0, then owner is set to root and mode is set to 0600 */ 00393 if((p_xattr_attrs->asked_attributes & FSAL_ATTR_OWNER) 00394 && (p_xattr_attrs->asked_attributes & FSAL_ATTR_MODE) && (p_xattr_attrs->mode == 0)) 00395 { 00396 p_xattr_attrs->owner = 0; 00397 p_xattr_attrs->mode = 0600; 00398 if(xattr_list[attr_index].flags & XATTR_RO) 00399 p_xattr_attrs->mode &= ~(0200); 00400 } 00401 00402 return 0; 00403 00404 } 00405 00414 fsal_status_t PROXYFSAL_GetXAttrAttrs(fsal_handle_t * p_objecthandle, /* IN */ 00415 fsal_op_context_t * p_context, /* IN */ 00416 unsigned int xattr_id, /* IN */ 00417 fsal_attrib_list_t * p_attrs 00419 ) 00420 { 00421 int rc; 00422 fsal_status_t st; 00423 fsal_attrib_list_t file_attrs; 00424 00425 /* sanity checks */ 00426 if(!p_objecthandle || !p_context || !p_attrs) 00427 Return(ERR_FSAL_FAULT, 0, INDEX_FSAL_GetXAttrAttrs); 00428 00429 /* check that this index match the type of entry */ 00430 if(xattr_id >= XATTR_COUNT 00431 || !do_match_type(xattr_list[xattr_id].flags, ((proxyfsal_handle_t *)p_objecthandle)->data.object_type_reminder)) 00432 { 00433 Return(ERR_FSAL_INVAL, 0, INDEX_FSAL_GetXAttrAttrs); 00434 } 00435 00436 /* object attributes we want to retrieve from parent */ 00437 file_attrs.asked_attributes = FSAL_ATTR_MODE | FSAL_ATTR_FILEID | FSAL_ATTR_OWNER 00438 | FSAL_ATTR_GROUP | FSAL_ATTR_ATIME | FSAL_ATTR_MTIME 00439 | FSAL_ATTR_CTIME | FSAL_ATTR_CREATION | FSAL_ATTR_CHGTIME | FSAL_ATTR_FSID; 00440 00441 /* don't retrieve attributes not asked */ 00442 00443 file_attrs.asked_attributes &= p_attrs->asked_attributes; 00444 00445 st = FSAL_getattrs(p_objecthandle, p_context, &file_attrs); 00446 00447 if(FSAL_IS_ERROR(st)) 00448 Return(st.major, st.minor, INDEX_FSAL_GetXAttrAttrs); 00449 00450 if((rc = file_attributes_to_xattr_attrs(&file_attrs, p_attrs, xattr_id))) 00451 { 00452 Return(ERR_FSAL_INVAL, rc, INDEX_FSAL_GetXAttrAttrs); 00453 } 00454 00455 Return(ERR_FSAL_NO_ERROR, 0, INDEX_FSAL_GetXAttrAttrs); 00456 00457 } /* FSAL_GetXAttrAttrs */ 00458 00471 fsal_status_t PROXYFSAL_ListXAttrs(fsal_handle_t * p_objecthandle, /* IN */ 00472 unsigned int argcookie, /* IN */ 00473 fsal_op_context_t * p_context, /* IN */ 00474 fsal_xattrent_t * xattrs_tab, /* IN/OUT */ 00475 unsigned int xattrs_tabsize, /* IN */ 00476 unsigned int *p_nb_returned, /* OUT */ 00477 int *end_of_list /* OUT */ 00478 ) 00479 { 00480 unsigned int index; 00481 unsigned int out_index; 00482 fsal_status_t st; 00483 fsal_attrib_list_t file_attrs; 00484 unsigned int cookie = argcookie ; 00485 00486 /* sanity checks */ 00487 if(!p_objecthandle || !p_context || !xattrs_tab || !p_nb_returned || !end_of_list) 00488 Return(ERR_FSAL_FAULT, 0, INDEX_FSAL_ListXAttrs); 00489 00490 /* Deal with special cookie */ 00491 if( argcookie == FSAL_XATTR_RW_COOKIE ) cookie = XATTR_COUNT ; 00492 00493 /* object attributes we want to retrieve from parent */ 00494 file_attrs.asked_attributes = FSAL_ATTR_MODE | FSAL_ATTR_FILEID | FSAL_ATTR_OWNER 00495 | FSAL_ATTR_GROUP | FSAL_ATTR_ATIME | FSAL_ATTR_MTIME 00496 | FSAL_ATTR_CTIME | FSAL_ATTR_CREATION | FSAL_ATTR_CHGTIME | FSAL_ATTR_FSID; 00497 00498 /* don't retrieve unsuipported attributes */ 00499 file_attrs.asked_attributes &= global_fs_info.supported_attrs; 00500 00501 st = FSAL_getattrs(p_objecthandle, p_context, &file_attrs); 00502 00503 if(FSAL_IS_ERROR(st)) 00504 Return(st.major, st.minor, INDEX_FSAL_ListXAttrs); 00505 00506 for(index = cookie, out_index = 0; 00507 index < XATTR_COUNT && out_index < xattrs_tabsize; index++) 00508 { 00509 if(do_match_type(xattr_list[index].flags, ((proxyfsal_handle_t *)p_objecthandle)->data.object_type_reminder)) 00510 { 00511 /* fills an xattr entry */ 00512 xattrs_tab[out_index].xattr_id = index; 00513 FSAL_str2name(xattr_list[index].xattr_name, FSAL_MAX_NAME_LEN, 00514 &xattrs_tab[out_index].xattr_name); 00515 xattrs_tab[out_index].xattr_cookie = index + 1; 00516 00517 /* set asked attributes (all supported) */ 00518 xattrs_tab[out_index].attributes.asked_attributes = 00519 global_fs_info.supported_attrs; 00520 00521 if(file_attributes_to_xattr_attrs 00522 (&file_attrs, &xattrs_tab[out_index].attributes, index)) 00523 { 00524 /* set error flag */ 00525 xattrs_tab[out_index].attributes.asked_attributes = FSAL_ATTR_RDATTR_ERR; 00526 } 00527 00528 /* next output slot */ 00529 out_index++; 00530 } 00531 } 00532 00533 *p_nb_returned = out_index; 00534 *end_of_list = (index == XATTR_COUNT); 00535 00536 Return(ERR_FSAL_NO_ERROR, 0, INDEX_FSAL_ListXAttrs); 00537 00538 } 00539 00550 fsal_status_t PROXYFSAL_GetXAttrValueById(fsal_handle_t * p_objecthandle, /* IN */ 00551 unsigned int xattr_id, /* IN */ 00552 fsal_op_context_t * p_context, /* IN */ 00553 caddr_t buffer_addr, /* IN/OUT */ 00554 size_t buffer_size, /* IN */ 00555 size_t * p_output_size /* OUT */ 00556 ) 00557 { 00558 int rc; 00559 char buff[MAXPATHLEN]; 00560 00561 /* sanity checks */ 00562 if(!p_objecthandle || !p_context || !p_output_size || !buffer_addr) 00563 Return(ERR_FSAL_FAULT, 0, INDEX_FSAL_GetXAttrValue); 00564 00565 /* check that this index match the type of entry */ 00566 if(xattr_id >= XATTR_COUNT 00567 || !do_match_type(xattr_list[xattr_id].flags, ((proxyfsal_handle_t *)p_objecthandle)->data.object_type_reminder)) 00568 { 00569 Return(ERR_FSAL_INVAL, 0, INDEX_FSAL_GetXAttrValue); 00570 } 00571 00572 /* get the value */ 00573 if(xattr_list[xattr_id].print_func == NULL) 00574 { 00575 rc = xattr_list[xattr_id].get_func((proxyfsal_handle_t *)p_objecthandle, 00576 (proxyfsal_op_context_t *)p_context, 00577 buffer_addr, buffer_size, p_output_size); 00578 } 00579 else 00580 { 00581 rc = xattr_list[xattr_id].get_func((proxyfsal_handle_t *)p_objecthandle, 00582 (proxyfsal_op_context_t *)p_context, buff, MAXPATHLEN, p_output_size); 00583 00584 xattr_list[xattr_id].print_func(buff, MAXPATHLEN, buffer_addr, p_output_size); 00585 } 00586 00587 Return(rc, 0, INDEX_FSAL_GetXAttrValue); 00588 00589 } 00590 00600 fsal_status_t PROXYFSAL_GetXAttrIdByName(fsal_handle_t * p_objecthandle, /* IN */ 00601 const fsal_name_t * xattr_name, /* IN */ 00602 fsal_op_context_t * p_context, /* IN */ 00603 unsigned int *pxattr_id /* OUT */ 00604 ) 00605 { 00606 unsigned int index; 00607 int found = FALSE; 00608 00609 /* sanity checks */ 00610 if(!p_objecthandle || !xattr_name) 00611 Return(ERR_FSAL_FAULT, 0, INDEX_FSAL_GetXAttrValue); 00612 00613 for(index = 0; index < XATTR_COUNT; index++) 00614 { 00615 if(do_match_type(xattr_list[index].flags, ((proxyfsal_handle_t *)p_objecthandle)->data.object_type_reminder) 00616 && !strcmp(xattr_list[index].xattr_name, xattr_name->name)) 00617 { 00618 found = TRUE; 00619 break; 00620 } 00621 } 00622 00623 if(found) 00624 { 00625 *pxattr_id = index; 00626 Return(ERR_FSAL_NO_ERROR, 0, INDEX_FSAL_GetXAttrValue); 00627 } 00628 else 00629 Return(ERR_FSAL_NOENT, ENOENT, INDEX_FSAL_GetXAttrValue); 00630 } /* FSAL_GetXAttrIdByName */ 00631 00642 fsal_status_t PROXYFSAL_GetXAttrValueByName(fsal_handle_t * p_objecthandle, /* IN */ 00643 const fsal_name_t * xattr_name, /* IN */ 00644 fsal_op_context_t * p_context, /* IN */ 00645 caddr_t buffer_addr, /* IN/OUT */ 00646 size_t buffer_size, /* IN */ 00647 size_t * p_output_size /* OUT */ 00648 ) 00649 { 00650 unsigned int index; 00651 00652 /* sanity checks */ 00653 if(!p_objecthandle || !p_context || !p_output_size || !buffer_addr || !xattr_name) 00654 Return(ERR_FSAL_FAULT, 0, INDEX_FSAL_GetXAttrValue); 00655 00656 /* look for this name */ 00657 00658 for(index = 0; index < XATTR_COUNT; index++) 00659 { 00660 if(do_match_type(xattr_list[index].flags, ((proxyfsal_handle_t *)p_objecthandle)->data.object_type_reminder) 00661 && !strcmp(xattr_list[index].xattr_name, xattr_name->name)) 00662 { 00663 00664 return FSAL_GetXAttrValueById(p_objecthandle, index, p_context, buffer_addr, 00665 buffer_size, p_output_size); 00666 00667 } 00668 } 00669 00670 /* not found */ 00671 Return(ERR_FSAL_NOENT, 0, INDEX_FSAL_GetXAttrValue); 00672 00673 } 00674 00675 fsal_status_t PROXYFSAL_SetXAttrValue(fsal_handle_t * p_objecthandle, /* IN */ 00676 const fsal_name_t * xattr_name, /* IN */ 00677 fsal_op_context_t * p_context, /* IN */ 00678 caddr_t buffer_addr, /* IN */ 00679 size_t buffer_size, /* IN */ 00680 int create /* IN */ 00681 ) 00682 { 00683 Return(ERR_FSAL_PERM, 0, INDEX_FSAL_SetXAttrValue); 00684 } 00685 00686 fsal_status_t PROXYFSAL_SetXAttrValueById(fsal_handle_t * p_objecthandle, /* IN */ 00687 unsigned int xattr_id, /* IN */ 00688 fsal_op_context_t * p_context, /* IN */ 00689 caddr_t buffer_addr, /* IN */ 00690 size_t buffer_size /* IN */ 00691 ) 00692 { 00693 Return(ERR_FSAL_PERM, 0, INDEX_FSAL_SetXAttrValue); 00694 } 00695 00703 fsal_status_t PROXYFSAL_RemoveXAttrById(fsal_handle_t * p_objecthandle, /* IN */ 00704 fsal_op_context_t * p_context, /* IN */ 00705 unsigned int xattr_id) /* IN */ 00706 { 00707 ReturnCode(ERR_FSAL_NO_ERROR, 0); 00708 } /* FSAL_RemoveXAttrById */ 00709 00717 fsal_status_t PROXYFSAL_RemoveXAttrByName(fsal_handle_t * p_objecthandle, /* IN */ 00718 fsal_op_context_t * p_context, /* IN */ 00719 const fsal_name_t * xattr_name) /* IN */ 00720 { 00721 ReturnCode(ERR_FSAL_NO_ERROR, 0); 00722 } /* FSAL_RemoveXAttrById */ 00723 00724 int PROXYFSAL_GetXattrOffsetSetable( void ) 00725 { 00726 return XATTR_COUNT ; 00727 }