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 00049 fsal_status_t FSAL_truncate(fsal_handle_t * filehandle, /* IN */ 00050 fsal_op_context_t * p_context, /* IN */ 00051 fsal_size_t length, /* IN */ 00052 fsal_file_t * file_descriptor, /* Unused in this FSAL */ 00053 fsal_attrib_list_t * object_attributes /* [ IN/OUT ] */ 00054 ) 00055 { 00056 00057 int rc; 00058 00059 /* sanity checks. 00060 * note : object_attributes is optional. 00061 */ 00062 if(!filehandle || !p_context) 00063 Return(ERR_FSAL_FAULT, 0, INDEX_FSAL_truncate); 00064 00065 /* >> check object type if it's stored into the filehandle << */ 00066 00067 if(filehandle->object_type_reminder != FSAL_TYPE_FILE) 00068 { 00069 Return(ERR_FSAL_INVAL, 0, INDEX_FSAL_truncate); 00070 } 00071 00072 TakeTokenFSCall(); 00073 00074 /* >> call your filesystem truncate operation << */ 00075 00076 ReleaseTokenFSCall(); 00077 00078 /* >> interpret error code << */ 00079 00080 /* >> Optionnaly retrieve post op attributes 00081 * If your filesystem truncate call can't return them, 00082 * you can proceed like this : << 00083 */ 00084 if(object_attributes) 00085 { 00086 00087 fsal_status_t st; 00088 00089 st = FSAL_getattrs(filehandle, p_context, object_attributes); 00090 00091 if(FSAL_IS_ERROR(st)) 00092 { 00093 FSAL_CLEAR_MASK(object_attributes->asked_attributes); 00094 FSAL_SET_MASK(object_attributes->asked_attributes, FSAL_ATTR_RDATTR_ERR); 00095 } 00096 00097 } 00098 00099 /* No error occured */ 00100 Return(ERR_FSAL_NO_ERROR, 0, INDEX_FSAL_truncate); 00101 00102 }