/** * @brief The Rquota getquota function, for all versions. * * @param[in] arg Ignored * @param[in] export Ignored * @param[in] worker Ignored * @param[in] req Ignored * @param[out] res Ignored * */ int rquota_getquota(nfs_arg_t *arg, nfs_worker_data_t *worker, struct svc_req *req, nfs_res_t *res) { fsal_status_t fsal_status; fsal_quota_t fsal_quota; int quota_type = USRQUOTA; struct gsh_export *exp; char *quota_path; getquota_rslt *qres = &res->res_rquota_getquota; LogFullDebug(COMPONENT_NFSPROTO, "REQUEST PROCESSING: Calling rquota_getquota"); if (req->rq_vers == EXT_RQUOTAVERS) quota_type = arg->arg_ext_rquota_getquota.gqa_type; qres->status = Q_EPERM; if (arg->arg_rquota_getquota.gqa_pathp[0] == '/') { exp = get_gsh_export_by_path(arg->arg_rquota_getquota.gqa_pathp, false); if (exp == NULL) goto out; quota_path = arg->arg_rquota_getquota.gqa_pathp; } else { exp = get_gsh_export_by_tag(arg->arg_rquota_getquota.gqa_pathp); if (exp == NULL) goto out; quota_path = exp->fullpath; } fsal_status = exp->fsal_export->ops->get_quota(exp->fsal_export, quota_path, quota_type, &fsal_quota); if (FSAL_IS_ERROR(fsal_status)) { if (fsal_status.major == ERR_FSAL_NO_QUOTA) qres->status = Q_NOQUOTA; goto out; } /* success */ qres->getquota_rslt_u.gqr_rquota.rq_active = TRUE; qres->getquota_rslt_u.gqr_rquota.rq_bsize = fsal_quota.bsize; qres->getquota_rslt_u.gqr_rquota.rq_bhardlimit = fsal_quota.bhardlimit; qres->getquota_rslt_u.gqr_rquota.rq_bsoftlimit = fsal_quota.bsoftlimit; qres->getquota_rslt_u.gqr_rquota.rq_curblocks = fsal_quota.curblocks; qres->getquota_rslt_u.gqr_rquota.rq_curfiles = fsal_quota.curfiles; qres->getquota_rslt_u.gqr_rquota.rq_fhardlimit = fsal_quota.fhardlimit; qres->getquota_rslt_u.gqr_rquota.rq_fsoftlimit = fsal_quota.fsoftlimit; qres->getquota_rslt_u.gqr_rquota.rq_btimeleft = fsal_quota.btimeleft; qres->getquota_rslt_u.gqr_rquota.rq_ftimeleft = fsal_quota.ftimeleft; qres->status = Q_OK; out: return NFS_REQ_OK; } /* rquota_getquota */
int _9p_auth(struct _9p_request_data *req9p, void *worker_data, u32 *plenout, char *preply) { char *cursor = req9p->_9pmsg + _9P_HDR_SIZE + _9P_TYPE_SIZE; u16 *msgtag = NULL; u32 *afid = NULL; u16 *uname_len = NULL; char *uname_str = NULL; u16 *aname_len = NULL; char *aname_str = NULL; u32 *n_aname = NULL; uint64_t fileid; u32 err = 0; struct _9p_fid *pfid = NULL; struct gsh_export *exp; exportlist_t *export = NULL; cache_inode_status_t cache_status; char exppath[MAXPATHLEN]; /* Get data */ _9p_getptr(cursor, msgtag, u16); _9p_getptr(cursor, afid, u32); _9p_getstr(cursor, uname_len, uname_str); _9p_getstr(cursor, aname_len, aname_str); _9p_getptr(cursor, n_aname, u32); LogDebug(COMPONENT_9P, "TAUTH: tag=%u afid=%d uname='%.*s' aname='%.*s' n_uname=%d", (u32) *msgtag, *afid, (int) *uname_len, uname_str, (int) *aname_len, aname_str, *n_aname); if (*afid >= _9P_FID_PER_CONN) return _9p_rerror(req9p, worker_data, msgtag, ERANGE, plenout, preply); /* * Find the export for the aname (using as well Path or Tag) */ snprintf(exppath, MAXPATHLEN, "%.*s", (int)*aname_len, aname_str); if (exppath[0] == '/') exp = get_gsh_export_by_path(exppath); else exp = get_gsh_export_by_tag(exppath); /* Did we find something ? */ if (exp == NULL) return _9p_rerror(req9p, worker_data, msgtag, ENOENT, plenout, preply); /* Set export and fid id in fid */ export = &exp->export;
int _9p_attach(struct _9p_request_data *req9p, u32 *plenout, char *preply) { char *cursor = req9p->_9pmsg + _9P_HDR_SIZE + _9P_TYPE_SIZE; u16 *msgtag = NULL; u32 *fid = NULL; u32 *afid = NULL; u16 *uname_len = NULL; char *uname_str = NULL; u16 *aname_len = NULL; char *aname_str = NULL; u32 *n_uname = NULL; uint64_t fileid; u32 err = 0; struct _9p_fid *pfid = NULL; struct gsh_export *export = NULL; cache_inode_status_t cache_status; fsal_status_t fsal_status; char exppath[MAXPATHLEN]; cache_inode_fsal_data_t fsal_data; struct fsal_obj_handle *pfsal_handle; int port; /* Get data */ _9p_getptr(cursor, msgtag, u16); _9p_getptr(cursor, fid, u32); _9p_getptr(cursor, afid, u32); _9p_getstr(cursor, uname_len, uname_str); _9p_getstr(cursor, aname_len, aname_str); _9p_getptr(cursor, n_uname, u32); LogDebug(COMPONENT_9P, "TATTACH: tag=%u fid=%u afid=%d uname='%.*s' aname='%.*s' n_uname=%d", (u32) *msgtag, *fid, *afid, (int) *uname_len, uname_str, (int) *aname_len, aname_str, *n_uname); if (*fid >= _9P_FID_PER_CONN) { err = ERANGE; goto errout; } /* * Find the export for the aname (using as well Path or Tag) */ snprintf(exppath, MAXPATHLEN, "%.*s", (int)*aname_len, aname_str); if (exppath[0] == '/') export = get_gsh_export_by_path(exppath, false); else export = get_gsh_export_by_tag(exppath);
int mnt_Mnt(nfs_arg_t *arg, nfs_worker_data_t *worker, struct svc_req *req, nfs_res_t *res) { struct gsh_export *export = NULL; struct fsal_obj_handle *pfsal_handle = NULL; int auth_flavor[NB_AUTH_FLAVOR]; int index_auth = 0; int i = 0; char dumpfh[1024]; int retval = NFS_REQ_OK; nfs_fh3 *fh3 = (nfs_fh3 *) &res->res_mnt3.mountres3_u.mountinfo.fhandle; cache_entry_t *entry = NULL; LogDebug(COMPONENT_NFSPROTO, "REQUEST PROCESSING: Calling mnt_Mnt path=%s", arg->arg_mnt); /* Paranoid command to clean the result struct. */ memset(res, 0, sizeof(nfs_res_t)); /* Quick escape if an unsupported MOUNT version */ if (req->rq_vers != MOUNT_V3) { res->res_mnt1.status = NFSERR_ACCES; goto out; } if (arg->arg_mnt == NULL) { LogCrit(COMPONENT_NFSPROTO, "NULL path passed as Mount argument !!!"); retval = NFS_REQ_DROP; goto out; } /* If the path ends with a '/', get rid of it */ /** @todo: should it be a while()?? */ if (arg->arg_mnt[strlen(arg->arg_mnt) - 1] == '/') arg->arg_mnt[strlen(arg->arg_mnt) - 1] = '\0'; /* Find the export for the dirname (using as well Path or Tag) */ if (arg->arg_mnt[0] == '/') export = get_gsh_export_by_path(arg->arg_mnt, false); else export = get_gsh_export_by_tag(arg->arg_mnt);
/** * @brief The Rquota setquota function, for all versions. * * The RQUOTA setquota function, for all versions. * * @param[in] arg quota args * @param[in] export Ignored * @param[in] worker Ignored * @param[in] req Ignored * @param[out] res returned quota (modified) * */ int rquota_setquota(nfs_arg_t *arg, nfs_worker_data_t *worker, struct svc_req *req, nfs_res_t *res) { fsal_status_t fsal_status; fsal_quota_t fsal_quota_in; fsal_quota_t fsal_quota_out; int quota_type = USRQUOTA; struct gsh_export *exp; char *quota_path; setquota_args *qarg = &arg->arg_rquota_setquota; setquota_rslt *qres = &res->res_rquota_setquota; LogFullDebug(COMPONENT_NFSPROTO, "REQUEST PROCESSING: Calling rquota_setquota"); if (req->rq_vers == EXT_RQUOTAVERS) quota_type = arg->arg_ext_rquota_setquota.sqa_type; qres->status = Q_EPERM; if (qarg->sqa_pathp[0] == '/') { exp = get_gsh_export_by_path(qarg->sqa_pathp, false); if (exp == NULL) goto out; quota_path = qarg->sqa_pathp; } else { exp = get_gsh_export_by_tag(qarg->sqa_pathp); if (exp == NULL) goto out; quota_path = exp->fullpath; } memset(&fsal_quota_in, 0, sizeof(fsal_quota_t)); memset(&fsal_quota_out, 0, sizeof(fsal_quota_t)); fsal_quota_in.bhardlimit = qarg->sqa_dqblk.rq_bhardlimit; fsal_quota_in.bsoftlimit = qarg->sqa_dqblk.rq_bsoftlimit; fsal_quota_in.curblocks = qarg->sqa_dqblk.rq_curblocks; fsal_quota_in.fhardlimit = qarg->sqa_dqblk.rq_fhardlimit; fsal_quota_in.fsoftlimit = qarg->sqa_dqblk.rq_fsoftlimit; fsal_quota_in.btimeleft = qarg->sqa_dqblk.rq_btimeleft; fsal_quota_in.ftimeleft = qarg->sqa_dqblk.rq_ftimeleft; fsal_status = exp->fsal_export->exp_ops.set_quota(exp->fsal_export, quota_path, quota_type, &fsal_quota_in, &fsal_quota_out); if (FSAL_IS_ERROR(fsal_status)) { if (fsal_status.major == ERR_FSAL_NO_QUOTA) qres->status = Q_NOQUOTA; goto out; } /* is success */ qres->setquota_rslt_u.sqr_rquota.rq_active = TRUE; qres->setquota_rslt_u.sqr_rquota.rq_bhardlimit = fsal_quota_out.bhardlimit; qres->setquota_rslt_u.sqr_rquota.rq_bsoftlimit = fsal_quota_out.bsoftlimit; qres->setquota_rslt_u.sqr_rquota.rq_curblocks = fsal_quota_out.curblocks; qres->setquota_rslt_u.sqr_rquota.rq_fhardlimit = fsal_quota_out.fhardlimit; qres->setquota_rslt_u.sqr_rquota.rq_fsoftlimit = fsal_quota_out.fsoftlimit; qres->setquota_rslt_u.sqr_rquota.rq_btimeleft = fsal_quota_out.btimeleft; qres->setquota_rslt_u.sqr_rquota.rq_ftimeleft = fsal_quota_out.ftimeleft; qres->status = Q_OK; out: return NFS_REQ_OK; } /* rquota_setquota */