nfs-ganesha 1.4
|
00001 /* 00002 * 00003 * 00004 * Copyright CEA/DAM/DIF (2008) 00005 * contributeur : Philippe DENIEL philippe.deniel@cea.fr 00006 * Thomas LEIBOVICI thomas.leibovici@cea.fr 00007 * 00008 * 00009 * This program is free software; you can redistribute it and/or 00010 * modify it under the terms of the GNU Lesser General Public 00011 * License as published by the Free Software Foundation; either 00012 * version 3 of the License, or (at your option) any later version. 00013 * 00014 * This program is distributed in the hope that it will be useful, 00015 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00016 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00017 * Lesser General Public License for more details. 00018 * 00019 * You should have received a copy of the GNU Lesser General Public 00020 * License along with this library; if not, write to the Free Software 00021 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00022 * 00023 * --------------------------------------- 00024 */ 00025 00036 #ifdef HAVE_CONFIG_H 00037 #include "config.h" 00038 #endif 00039 00040 /* fsal_types contains constants and type definitions for FSAL */ 00041 #include "fsal_types.h" 00042 #include "fsal.h" 00043 #include "mfsl_types.h" 00044 #include "mfsl.h" 00045 #include "common_utils.h" 00046 00060 fsal_status_t MFSAL_getattrs_check_perms(mfsl_object_t * filehandle, /* IN */ 00061 mfsl_object_specific_data_t * pspecdata, /* IN */ 00062 fsal_op_context_t * p_context, /* IN */ 00063 mfsl_context_t * p_mfsl_context, /* IN */ 00064 fsal_attrib_list_t * object_attributes /* IN */ ) 00065 { 00066 fsal_status_t fsal_status; 00067 00068 fsal_status = FSAL_test_access(p_context, FSAL_R_OK, object_attributes); 00069 00070 if(FSAL_IS_ERROR(fsal_status)) 00071 return fsal_status; 00072 00073 MFSL_return(ERR_FSAL_NO_ERROR, 0); 00074 } /* MFSL_setattr_check_perms */ 00075 00089 fsal_status_t MFSL_getattrs(mfsl_object_t * filehandle, /* IN */ 00090 fsal_op_context_t * p_context, /* IN */ 00091 mfsl_context_t * p_mfsl_context, /* IN */ 00092 fsal_attrib_list_t * object_attributes /* [ IN/OUT ] */ 00093 ) 00094 { 00095 fsal_status_t fsal_status; 00096 mfsl_object_specific_data_t *pasyncdata; 00097 00098 if(mfsl_async_get_specdata(filehandle, &pasyncdata)) 00099 { 00100 P(filehandle->lock); 00101 fsal_status = MFSAL_getattrs_check_perms(filehandle, 00102 pasyncdata, 00103 p_context, 00104 p_mfsl_context, object_attributes); 00105 V(filehandle->lock); 00106 00107 if(FSAL_IS_ERROR(fsal_status)) 00108 return fsal_status; 00109 00110 /* Is the object deleted ? */ 00111 if(pasyncdata->deleted == TRUE) 00112 MFSL_return(ERR_FSAL_NOENT, ENOENT); 00113 00114 /* merge the attributes to the asynchronous attributes */ 00115 if((object_attributes->asked_attributes & FSAL_ATTR_SIZE) || 00116 (object_attributes->asked_attributes & FSAL_ATTR_SPACEUSED)) 00117 { 00118 /* Operation on a non data cached file */ 00119 object_attributes->filesize = pasyncdata->async_attr.filesize; 00120 object_attributes->spaceused = pasyncdata->async_attr.spaceused; 00121 } 00122 00123 if(object_attributes->asked_attributes & 00124 (FSAL_ATTR_MODE | FSAL_ATTR_OWNER | FSAL_ATTR_GROUP)) 00125 { 00126 if(object_attributes->asked_attributes & FSAL_ATTR_MODE) 00127 object_attributes->mode = pasyncdata->async_attr.mode; 00128 00129 if(object_attributes->asked_attributes & FSAL_ATTR_OWNER) 00130 object_attributes->owner = pasyncdata->async_attr.owner; 00131 00132 if(object_attributes->asked_attributes & FSAL_ATTR_GROUP) 00133 object_attributes->group = pasyncdata->async_attr.group; 00134 } 00135 00136 if(object_attributes->asked_attributes & (FSAL_ATTR_ATIME | FSAL_ATTR_MTIME)) 00137 { 00138 if(object_attributes->asked_attributes & FSAL_ATTR_ATIME) 00139 object_attributes->atime = pasyncdata->async_attr.atime; 00140 00141 if(object_attributes->asked_attributes & FSAL_ATTR_MTIME) 00142 object_attributes->mtime = pasyncdata->async_attr.mtime; 00143 } 00144 00145 /* Regular exit */ 00146 MFSL_return(ERR_FSAL_NO_ERROR, 0); 00147 } 00148 else 00149 { 00150 return FSAL_getattrs(&filehandle->handle, p_context, object_attributes); 00151 } 00152 } /* MFSL_getattrs */