nfs-ganesha 1.4
|
00001 /* 00002 * Copyright CEA/DAM/DIF 2010 00003 * Author: Philippe Deniel (philippe.deniel@cea.fr) 00004 * 00005 * -------------------------- 00006 * 00007 * This program is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU Lesser General Public 00009 * License as published by the Free Software Foundation; either 00010 * version 3 of the License, or (at your option) any later version. 00011 * 00012 * This program is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 * Lesser General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU Lesser General Public 00018 * License along with this library; if not, write to the Free Software 00019 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00020 * 00021 * 00022 */ 00023 00024 #ifdef HAVE_CONFIG_H 00025 #include "config.h" 00026 #endif 00027 00028 #ifdef _SOLARIS 00029 #include "solaris_port.h" 00030 #endif 00031 00032 #include <stdio.h> 00033 #include <string.h> 00034 #include <pthread.h> 00035 #include <fcntl.h> 00036 #include <sys/file.h> /* for having FNDELAY */ 00037 #include <sys/quota.h> /* For USRQUOTA */ 00038 #include "HashData.h" 00039 #include "HashTable.h" 00040 #include "log.h" 00041 #include "ganesha_rpc.h" 00042 #include "nfs23.h" 00043 #include "nfs4.h" 00044 #include "nfs_core.h" 00045 #include "cache_inode.h" 00046 #include "nfs_exports.h" 00047 #include "nfs_creds.h" 00048 #include "nfs_tools.h" 00049 #include "mount.h" 00050 #include "rquota.h" 00051 #include "nfs_proto_functions.h" 00052 00066 int rquota_getquota(nfs_arg_t *parg, 00067 exportlist_t *pexport, 00068 fsal_op_context_t *pcontext, 00069 nfs_worker_data_t *pworker, 00070 struct svc_req *preq, 00071 nfs_res_t * pres) 00072 { 00073 fsal_status_t fsal_status; 00074 fsal_quota_t fsal_quota; 00075 fsal_path_t fsal_path; 00076 int quota_type = USRQUOTA; 00077 int quota_id; 00078 char work[MAXPATHLEN]; 00079 00080 LogFullDebug(COMPONENT_NFSPROTO, 00081 "REQUEST PROCESSING: Calling rquota_getquota"); 00082 00083 if(preq->rq_vers == EXT_RQUOTAVERS) 00084 { 00085 quota_type = parg->arg_ext_rquota_getquota.gqa_type; 00086 quota_id = parg->arg_ext_rquota_getquota.gqa_id; 00087 } 00088 else 00089 { 00090 quota_type = USRQUOTA; 00091 quota_id = parg->arg_rquota_getquota.gqa_uid; 00092 } 00093 00094 if(parg->arg_rquota_getquota.gqa_pathp[0] == '/') 00095 strncpy(work, parg->arg_rquota_getquota.gqa_pathp, MAXPATHLEN); 00096 else 00097 { 00098 if(nfs_export_tag2path(nfs_param.pexportlist, 00099 parg->arg_rquota_getquota.gqa_pathp, 00100 strnlen(parg->arg_rquota_getquota.gqa_pathp, MAXPATHLEN), 00101 work, MAXPATHLEN) == -1) 00102 00103 { 00104 pres->res_rquota_getquota.status = Q_EPERM; 00105 return NFS_REQ_OK; 00106 } 00107 } 00108 00109 if(FSAL_IS_ERROR((fsal_status = FSAL_str2path(work, MAXPATHLEN, &fsal_path)))) 00110 { 00111 pres->res_rquota_getquota.status = Q_EPERM; 00112 return NFS_REQ_OK; 00113 } 00114 00115 fsal_status = FSAL_get_quota(&fsal_path, quota_type, quota_id, &fsal_quota); 00116 if(FSAL_IS_ERROR(fsal_status)) 00117 { 00118 if(fsal_status.major == ERR_FSAL_NO_QUOTA) 00119 pres->res_rquota_getquota.status = Q_NOQUOTA; 00120 else 00121 pres->res_rquota_getquota.status = Q_EPERM; 00122 return NFS_REQ_OK; 00123 } 00124 00125 /* success */ 00126 pres->res_rquota_getquota.status = Q_OK; 00127 00128 pres->res_rquota_getquota.getquota_rslt_u.gqr_rquota.rq_active = TRUE; 00129 pres->res_rquota_getquota.getquota_rslt_u.gqr_rquota.rq_bsize = fsal_quota.bsize; 00130 pres->res_rquota_getquota.getquota_rslt_u.gqr_rquota.rq_bhardlimit = 00131 fsal_quota.bhardlimit; 00132 pres->res_rquota_getquota.getquota_rslt_u.gqr_rquota.rq_bsoftlimit = 00133 fsal_quota.bsoftlimit; 00134 pres->res_rquota_getquota.getquota_rslt_u.gqr_rquota.rq_curblocks = 00135 fsal_quota.curblocks; 00136 pres->res_rquota_getquota.getquota_rslt_u.gqr_rquota.rq_curfiles = fsal_quota.curfiles; 00137 pres->res_rquota_getquota.getquota_rslt_u.gqr_rquota.rq_fhardlimit = 00138 fsal_quota.fhardlimit; 00139 pres->res_rquota_getquota.getquota_rslt_u.gqr_rquota.rq_fsoftlimit = 00140 fsal_quota.fsoftlimit; 00141 pres->res_rquota_getquota.getquota_rslt_u.gqr_rquota.rq_btimeleft = 00142 fsal_quota.btimeleft; 00143 pres->res_rquota_getquota.getquota_rslt_u.gqr_rquota.rq_ftimeleft = 00144 fsal_quota.ftimeleft; 00145 00146 return NFS_REQ_OK; 00147 } /* rquota_getquota */ 00148 00157 void rquota_getquota_Free(nfs_res_t * pres) 00158 { 00159 return; 00160 }