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 00022 #include <hpss_errno.h> 00023 00051 fsal_status_t HPSSFSAL_truncate(hpssfsal_handle_t * filehandle, /* IN */ 00052 hpssfsal_op_context_t * p_context, /* IN */ 00053 fsal_size_t length, /* IN */ 00054 hpssfsal_file_t * file_descriptor, /* Unused in this FSAL */ 00055 fsal_attrib_list_t * object_attributes /* [ IN/OUT ] */ 00056 ) 00057 { 00058 00059 int rc; 00060 u_signed64 trunc_size; 00061 00062 /* sanity checks. 00063 * note : object_attributes is optional. 00064 */ 00065 if(!filehandle || !p_context) 00066 Return(ERR_FSAL_FAULT, 0, INDEX_FSAL_truncate); 00067 00068 /* convert fsal_size_t to u_signed64 */ 00069 00070 trunc_size = fsal2hpss_64(length); 00071 00072 /* check if it is a file */ 00073 00074 if(filehandle->data.obj_type != FSAL_TYPE_FILE) 00075 { 00076 Return(ERR_FSAL_INVAL, 0, INDEX_FSAL_truncate); 00077 } 00078 00079 /* Executes the HPSS truncate operation */ 00080 00081 TakeTokenFSCall(); 00082 00083 rc = hpss_TruncateHandle(&(filehandle->data.ns_handle), /* IN - handle of file or parent */ 00084 NULL, /* IN (handle addressing) */ 00085 trunc_size, /* IN - new file length */ 00086 &(p_context->credential.hpss_usercred) /* IN - pointer to user's credentials */ 00087 ); 00088 00089 ReleaseTokenFSCall(); 00090 00091 /* The HPSS_ENOENT error actually means that handle is STALE */ 00092 if(rc == HPSS_ENOENT) 00093 Return(ERR_FSAL_STALE, -rc, INDEX_FSAL_truncate); 00094 else if(rc) 00095 Return(hpss2fsal_error(rc), -rc, INDEX_FSAL_truncate); 00096 00097 /* Optionnaly retrieve attributes */ 00098 if(object_attributes) 00099 { 00100 00101 fsal_status_t st; 00102 00103 st = HPSSFSAL_getattrs(filehandle, p_context, object_attributes); 00104 00105 if(FSAL_IS_ERROR(st)) 00106 { 00107 FSAL_CLEAR_MASK(object_attributes->asked_attributes); 00108 FSAL_SET_MASK(object_attributes->asked_attributes, FSAL_ATTR_RDATTR_ERR); 00109 } 00110 00111 } 00112 00113 /* No error occured */ 00114 Return(ERR_FSAL_NO_ERROR, 0, INDEX_FSAL_truncate); 00115 00116 }