NFS update
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4713 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
parent
c5bbc7b71d
commit
f5ad5f4bc2
@ -10,7 +10,7 @@
|
||||
* copyright (c) 2004
|
||||
* the regents of the university of michigan
|
||||
* all rights reserved
|
||||
*
|
||||
*
|
||||
* permission is granted to use, copy, create derivative works and redistribute
|
||||
* this software and such derivative works for any purpose, so long as the name
|
||||
* of the university of michigan is not used in any advertising or publicity
|
||||
@ -18,7 +18,7 @@
|
||||
* written prior authorization. if the above copyright notice or any other
|
||||
* identification of the university of michigan is included in any copy of any
|
||||
* portion of this software, then the disclaimer below must also be included.
|
||||
*
|
||||
*
|
||||
* this software is provided as is, without representation from the university
|
||||
* of michigan as to its fitness for any purpose, and without warranty by the
|
||||
* university of michigan of any kind, either express or implied, including
|
||||
@ -160,7 +160,7 @@ int nfs_connect(struct nfsmount *nmp)
|
||||
|
||||
rpc->rc_proctlen = 0;
|
||||
rpc->rc_proct = NULL;
|
||||
|
||||
|
||||
nmp->nm_rpcclnt = rpc;
|
||||
|
||||
return rpcclnt_connect(rpc);
|
||||
@ -180,7 +180,7 @@ void nfs_safedisconnect(struct nfsmount *nmp)
|
||||
}
|
||||
#endif
|
||||
|
||||
int nfs_request(struct nfsmount *nmp, int procnum, void *datain, void *dataout)
|
||||
int nfs_request(struct nfsmount *nmp, int procnum, void *datain, void **dataout)
|
||||
{
|
||||
int error;
|
||||
struct rpcclnt *clnt= nmp->nm_rpcclnt;
|
||||
@ -189,12 +189,14 @@ int nfs_request(struct nfsmount *nmp, int procnum, void *datain, void *dataout)
|
||||
|
||||
tryagain:
|
||||
|
||||
memset(&reply, 0, sizeof(reply));
|
||||
|
||||
if ((error = rpcclnt_request(clnt, procnum, &reply, datain)) != 0)
|
||||
{
|
||||
goto out;
|
||||
}
|
||||
|
||||
bcopy (dataout, &reply.stat.where, sizeof(reply.stat.where));
|
||||
*dataout = (void *)reply.stat.where;
|
||||
|
||||
if (reply.rpc_verfi.authtype != 0)
|
||||
{
|
||||
@ -231,7 +233,7 @@ tryagain:
|
||||
}
|
||||
|
||||
return 0;
|
||||
|
||||
|
||||
out:
|
||||
return error;
|
||||
}
|
||||
|
@ -10,7 +10,7 @@
|
||||
* copyright (c) 2004
|
||||
* the regents of the university of michigan
|
||||
* all rights reserved
|
||||
*
|
||||
*
|
||||
* permission is granted to use, copy, create derivative works and redistribute
|
||||
* this software and such derivative works for any purpose, so long as the name
|
||||
* of the university of michigan is not used in any advertising or publicity
|
||||
@ -18,7 +18,7 @@
|
||||
* written prior authorization. if the above copyright notice or any other
|
||||
* identification of the university of michigan is included in any copy of any
|
||||
* portion of this software, then the disclaimer below must also be included.
|
||||
*
|
||||
*
|
||||
* this software is provided as is, without representation from the university
|
||||
* of michigan as to its fitness for any purpose, and without warranty by the
|
||||
* university of michigan of any kind, either express or implied, including
|
||||
@ -61,7 +61,7 @@ EXTERN void nfs_disconnect(struct nfsmount *);
|
||||
EXTERN int nfs_sigintr(struct nfsmount *, struct nfsreq *, cthread_t *);
|
||||
EXTERN void nfs_safedisconnect(struct nfsmount *);
|
||||
#endif
|
||||
EXTERN int nfs_request(struct nfsmount *, int, void*, void*);
|
||||
EXTERN int nfs_request(struct nfsmount *, int, void *, void **);
|
||||
EXTERN int nfs_nmcancelreqs(struct nfsmount *);
|
||||
|
||||
#undef EXTERN
|
||||
|
@ -185,7 +185,7 @@ nfs_open(FAR struct file *filep, FAR const char *relpath,
|
||||
struct nfsmount *nmp;
|
||||
struct nfsnode *np;
|
||||
struct CREATE3args create;
|
||||
struct CREATE3resok resok;
|
||||
struct CREATE3resok *resok;
|
||||
void *datareply;
|
||||
int error = 0;
|
||||
|
||||
@ -222,22 +222,22 @@ again:
|
||||
memset(&sp, 0, sizeof(struct nfsv3_sattr));
|
||||
memset(&vap, 0, sizeof(struct nfs_fattr));
|
||||
vap = nmp->nm_head->n_fattr;
|
||||
sp.sa_modetrue = true;
|
||||
sp.sa_mode = txdr_unsigned(vap.fa_mode);
|
||||
sp.sa_uidfalse = nfs_xdrneg1;
|
||||
sp.sa_gidfalse = nfs_xdrneg1;
|
||||
sp.sa_modetrue = true;
|
||||
sp.sa_mode = txdr_unsigned(mode);
|
||||
sp.sa_uidfalse = nfs_xdrneg1;
|
||||
sp.sa_gidfalse = nfs_xdrneg1;
|
||||
sp.sa_sizefalse = nfs_xdrneg1;
|
||||
sp.sa_atimetype = txdr_unsigned(NFSV3SATTRTIME_TOCLIENT);
|
||||
sp.sa_mtimetype = txdr_unsigned(NFSV3SATTRTIME_TOCLIENT);
|
||||
sp.sa_atime = vap.fa3_atime;
|
||||
sp.sa_mtime = vap.fa3_mtime;
|
||||
sp.sa_atime = vap.fa3_atime;
|
||||
sp.sa_mtime = vap.fa3_mtime;
|
||||
|
||||
memset(&create, 0, sizeof(struct CREATE3args));
|
||||
create.how = sp;
|
||||
create.where.dir = nmp->nm_fh;
|
||||
create.where.dir = np->n_fhp;
|
||||
create.where.name = relpath;
|
||||
|
||||
error = nfs_request(nmp, NFSPROC_CREATE, &create, datareply);
|
||||
error = nfs_request(nmp, NFSPROC_CREATE, &create, &datareply);
|
||||
if (!error)
|
||||
{
|
||||
/* Create an instance of the file private data to describe the opened
|
||||
@ -256,14 +256,14 @@ again:
|
||||
* non-zero elements)
|
||||
*/
|
||||
|
||||
bcopy (datareply, &resok, sizeof(struct CREATE3resok));
|
||||
resok = (struct CREATE3resok *) datareply;
|
||||
np->n_open = true;
|
||||
np->nfsv3_type = NFREG;
|
||||
np->n_fhp = resok.handle;
|
||||
np->n_size = fxdr_hyper(&resok.attributes.fa3_size);
|
||||
np->n_fattr = resok.attributes;
|
||||
fxdr_nfsv3time(&resok.attributes.fa3_mtime, &np->n_mtime)
|
||||
np->n_ctime = fxdr_hyper(&resok.attributes.fa3_ctime);
|
||||
np->n_fhp = resok->handle;
|
||||
np->n_size = fxdr_hyper(&resok->attributes.fa3_size);
|
||||
np->n_fattr = resok->attributes;
|
||||
fxdr_nfsv3time(&resok->attributes.fa3_mtime, &np->n_mtime)
|
||||
np->n_ctime = fxdr_hyper(&resok->attributes.fa3_ctime);
|
||||
|
||||
/* Attach the private date to the struct file instance */
|
||||
|
||||
@ -275,7 +275,7 @@ again:
|
||||
* (but a simple reference count could have done that).
|
||||
*/
|
||||
|
||||
np->n_next = nmp->nm_head;
|
||||
np->n_next = nmp->nm_head;
|
||||
nmp->nm_head = np->n_next;
|
||||
error = 0;
|
||||
}
|
||||
@ -311,6 +311,7 @@ again:
|
||||
NFS_INVALIDATE_ATTRCACHE(np);
|
||||
|
||||
errout_with_semaphore:
|
||||
kfree(np);
|
||||
nfs_semgive(nmp);
|
||||
return error;
|
||||
}
|
||||
@ -364,7 +365,7 @@ static ssize_t nfs_read(FAR struct file *filep, char *buffer, size_t buflen)
|
||||
uint64_t offset;
|
||||
void *datareply;
|
||||
struct READ3args read;
|
||||
struct READ3resok resok;
|
||||
struct READ3resok *resok;
|
||||
uint8_t *userbuffer = (uint8_t*)buffer;
|
||||
int error = 0;
|
||||
int len;
|
||||
@ -435,19 +436,20 @@ again:
|
||||
read.count = buflen;
|
||||
read.offset = offset;
|
||||
|
||||
error = nfs_request(nmp, NFSPROC_READ, &read, datareply);
|
||||
error = nfs_request(nmp, NFSPROC_READ, &read, &datareply);
|
||||
if (error)
|
||||
{
|
||||
goto errout_with_semaphore;
|
||||
}
|
||||
|
||||
bcopy (datareply, &resok, sizeof(struct READ3resok));
|
||||
eof = resok.eof;
|
||||
//bcopy (datareply, &resok, sizeof(struct READ3resok));
|
||||
resok = (struct READ3resok *) datareply;
|
||||
eof = resok->eof;
|
||||
if (eof == true)
|
||||
{
|
||||
readsize = resok.count;
|
||||
np->n_fattr = resok.file_attributes;
|
||||
memcpy(userbuffer, resok.data, readsize);
|
||||
readsize = resok->count;
|
||||
np->n_fattr = resok->file_attributes;
|
||||
memcpy(userbuffer, resok->data, readsize);
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -475,7 +477,7 @@ nfs_write(FAR struct file *filep, const char *buffer, size_t buflen)
|
||||
unsigned int writesize;
|
||||
void *datareply;
|
||||
struct WRITE3args write;
|
||||
struct WRITE3resok resok;
|
||||
struct WRITE3resok *resok;
|
||||
uint8_t *userbuffer = (uint8_t*)buffer;
|
||||
int error = 0;
|
||||
uint64_t offset;
|
||||
@ -529,22 +531,23 @@ nfs_write(FAR struct file *filep, const char *buffer, size_t buflen)
|
||||
write.stable = committed;
|
||||
memcpy((void *)write.data, userbuffer, buflen);
|
||||
|
||||
error = nfs_request(nmp, NFSPROC_WRITE, &write, datareply);
|
||||
error = nfs_request(nmp, NFSPROC_WRITE, &write, &datareply);
|
||||
if (error)
|
||||
{
|
||||
goto errout_with_semaphore;
|
||||
}
|
||||
|
||||
bcopy (datareply, &resok, sizeof(struct WRITE3resok));
|
||||
writesize = resok.count;
|
||||
//bcopy (datareply, &resok, sizeof(struct WRITE3resok));
|
||||
resok = (struct WRITE3resok *) datareply;
|
||||
writesize = resok->count;
|
||||
if (writesize == 0)
|
||||
{
|
||||
error = NFSERR_IO;
|
||||
goto errout_with_semaphore;
|
||||
}
|
||||
|
||||
commit = resok.committed;
|
||||
np->n_fattr = resok.file_wcc.after;
|
||||
commit = resok->committed;
|
||||
np->n_fattr = resok->file_wcc.after;
|
||||
|
||||
/* Return the lowest committment level obtained by any of the RPCs. */
|
||||
|
||||
@ -560,12 +563,12 @@ nfs_write(FAR struct file *filep, const char *buffer, size_t buflen)
|
||||
|
||||
if ((nmp->nm_flag & NFSMNT_HASWRITEVERF) == 0)
|
||||
{
|
||||
bcopy((void*) resok.verf, (void*) nmp->nm_verf, NFSX_V3WRITEVERF);
|
||||
bcopy((void*) resok->verf, (void*) nmp->nm_verf, NFSX_V3WRITEVERF);
|
||||
nmp->nm_flag |= NFSMNT_HASWRITEVERF;
|
||||
}
|
||||
else if (strncmp((char*) resok.verf, (char*) nmp->nm_verf, NFSX_V3WRITEVERF))
|
||||
else if (strncmp((char*) resok->verf, (char*) nmp->nm_verf, NFSX_V3WRITEVERF))
|
||||
{
|
||||
bcopy((void*) resok.verf, (void*) nmp->nm_verf, NFSX_V3WRITEVERF);
|
||||
bcopy((void*) resok->verf, (void*) nmp->nm_verf, NFSX_V3WRITEVERF);
|
||||
}
|
||||
|
||||
fxdr_nfsv3time(&np->n_fattr.fa3_mtime, &np->n_mtime)
|
||||
@ -588,9 +591,9 @@ int nfs_readdirrpc(struct nfsmount *nmp, struct nfsnode *np,
|
||||
bool end_of_directory, struct fs_dirent_s *dir)
|
||||
{
|
||||
int error = 0;
|
||||
void *datareply = NULL;
|
||||
void *datareply;
|
||||
struct READDIR3args readir;
|
||||
struct READDIR3resok resok;
|
||||
struct READDIR3resok *resok;
|
||||
|
||||
/* Loop around doing readdir rpc's of size nm_readdirsize
|
||||
* truncated to a multiple of NFS_READDIRBLKSIZ.
|
||||
@ -618,24 +621,25 @@ int nfs_readdirrpc(struct nfsmount *nmp, struct nfsnode *np,
|
||||
readir.cookieverf.nfsuquad[1] = np->n_cookieverf.nfsuquad[1];
|
||||
}
|
||||
|
||||
error = nfs_request(nmp, NFSPROC_READDIR, &readir, datareply);
|
||||
error = nfs_request(nmp, NFSPROC_READDIR, &readir, &datareply);
|
||||
|
||||
if (error)
|
||||
{
|
||||
goto nfsmout;
|
||||
}
|
||||
|
||||
bcopy (datareply, &resok, sizeof(struct READDIR3resok));
|
||||
np->n_fattr = resok.dir_attributes;
|
||||
np->n_cookieverf.nfsuquad[0] = resok.cookieverf.nfsuquad[0];
|
||||
np->n_cookieverf.nfsuquad[1] = resok.cookieverf.nfsuquad[1];
|
||||
dir->fd_dir.d_type = resok.reply.entries->fileid;
|
||||
memcpy(&dir->fd_dir.d_name[NAME_MAX], &resok.reply.entries->name, NAME_MAX);
|
||||
//bcopy (datareply, &resok, sizeof(struct READDIR3resok));
|
||||
resok = (struct READDIR3resok *) datareply;
|
||||
np->n_fattr = resok->dir_attributes;
|
||||
np->n_cookieverf.nfsuquad[0] = resok->cookieverf.nfsuquad[0];
|
||||
np->n_cookieverf.nfsuquad[1] = resok->cookieverf.nfsuquad[1];
|
||||
dir->fd_dir.d_type = resok->reply.entries->fileid;
|
||||
memcpy(&dir->fd_dir.d_name[NAME_MAX], &resok->reply.entries->name, NAME_MAX);
|
||||
//dir->fd_dir.d_name = resok->reply.entries->name;//
|
||||
dir->u.nfs.cookie[0] = resok.reply.entries->cookie.nfsuquad[0];
|
||||
dir->u.nfs.cookie[1] = resok.reply.entries->cookie.nfsuquad[1];
|
||||
dir->u.nfs.cookie[0] = resok->reply.entries->cookie.nfsuquad[0];
|
||||
dir->u.nfs.cookie[1] = resok->reply.entries->cookie.nfsuquad[1];
|
||||
|
||||
if (resok.reply.eof == true)
|
||||
if (resok->reply.eof == true)
|
||||
{
|
||||
end_of_directory = true;
|
||||
}
|
||||
@ -667,7 +671,7 @@ int nfs_readdirrpc(struct nfsmount *nmp, struct nfsnode *np,
|
||||
|
||||
/* We are now either at the end of the directory */
|
||||
|
||||
if (resok.reply.entries == NULL)
|
||||
if (resok->reply.entries == NULL)
|
||||
{
|
||||
np->n_direofoffset = fxdr_hyper(&dir->u.nfs.cookie[0]);
|
||||
|
||||
@ -686,7 +690,7 @@ nfsmout:
|
||||
/****************************************************************************
|
||||
* Name: nfs_readdir
|
||||
*
|
||||
* Description: Read the next directory entry
|
||||
* Description: Read from directory
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
@ -990,6 +994,7 @@ void nfs_decode_args(struct nfsmount *nmp, struct nfs_args *argp)
|
||||
int mountnfs(struct nfs_args *argp, void **handle)
|
||||
{
|
||||
struct nfsmount *nmp;
|
||||
struct nfsnode *np;
|
||||
int error;
|
||||
|
||||
/* Create an instance of the mountpt state structure */
|
||||
@ -1030,6 +1035,18 @@ int mountnfs(struct nfs_args *argp, void **handle)
|
||||
nmp->nm_nam = argp->addr;
|
||||
nfs_decode_args(nmp, argp);
|
||||
|
||||
/* Create an instance of the file private data to describe the opened
|
||||
* file.
|
||||
*/
|
||||
|
||||
np = (struct nfsnode *)kzalloc(sizeof(struct nfsnode));
|
||||
if (!np)
|
||||
{
|
||||
fdbg("Failed to allocate private data\n", error);
|
||||
return -ENOMEM;
|
||||
}
|
||||
|
||||
nmp->nm_head = np;
|
||||
/* Set up the sockets and per-host congestion */
|
||||
|
||||
nmp->nm_sotype = argp->sotype;
|
||||
@ -1056,6 +1073,7 @@ int mountnfs(struct nfs_args *argp, void **handle)
|
||||
bad:
|
||||
nfs_disconnect(nmp);
|
||||
sem_destroy(&nmp->nm_sem);
|
||||
kfree(nmp->nm_head);
|
||||
kfree(nmp->nm_so);
|
||||
kfree(nmp->nm_rpcclnt);
|
||||
kfree(nmp);
|
||||
@ -1113,7 +1131,6 @@ static int nfs_bind(struct inode *blkdriver, const void *data, void **handle)
|
||||
int nfs_unbind(void *handle, struct inode **blkdriver)
|
||||
{
|
||||
struct nfsmount *nmp = (struct nfsmount *) handle ;
|
||||
int error;
|
||||
|
||||
fvdbg("Entry\n");
|
||||
|
||||
@ -1123,52 +1140,14 @@ int nfs_unbind(void *handle, struct inode **blkdriver)
|
||||
}
|
||||
|
||||
nfs_semtake(nmp);
|
||||
if (nmp->nm_head)
|
||||
{
|
||||
/* We cannot unmount now.. there are open files */
|
||||
nfs_disconnect(nmp);
|
||||
sem_destroy(&nmp->nm_sem);
|
||||
kfree(nmp->nm_head);
|
||||
kfree(nmp->nm_so);
|
||||
kfree(nmp->nm_rpcclnt);
|
||||
kfree(nmp);
|
||||
|
||||
error = -EBUSY;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Unmount ... close the block driver */
|
||||
/*
|
||||
if (nmp->nm_blkdriver)
|
||||
{
|
||||
struct inode *inode = nmp->nm_blkdriver;
|
||||
if (inode)
|
||||
{
|
||||
if (inode->u.i_bops && inode->u.i_bops->close)
|
||||
{
|
||||
(void)inode->u.i_bops->close(inode);
|
||||
}
|
||||
*/
|
||||
/* We hold a reference to the block driver but should
|
||||
* not but mucking with inodes in this context. So, we will just return
|
||||
* our contained reference to the block driver inode and let the umount
|
||||
* logic dispose of it.
|
||||
*/
|
||||
/*
|
||||
if (blkdriver)
|
||||
{
|
||||
*blkdriver = inode;
|
||||
}
|
||||
}
|
||||
}
|
||||
*/
|
||||
/* Release the mountpoint private data */
|
||||
|
||||
nfs_disconnect(nmp);
|
||||
sem_destroy(&nmp->nm_sem);
|
||||
kfree(nmp->nm_so);
|
||||
kfree(nmp->nm_rpcclnt);
|
||||
kfree(nmp);
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
nfs_semgive(nmp);
|
||||
return error;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@ -1180,7 +1159,7 @@ int nfs_unbind(void *handle, struct inode **blkdriver)
|
||||
|
||||
static int nfs_statfs(struct inode *mountpt, struct statfs *sbp)
|
||||
{
|
||||
struct nfs_statfs sfp;
|
||||
struct nfs_statfs *sfp;
|
||||
struct nfsmount *nmp;
|
||||
int error = 0;
|
||||
uint64_t tquad;
|
||||
@ -1218,24 +1197,24 @@ static int nfs_statfs(struct inode *mountpt, struct statfs *sbp)
|
||||
nfsstats.rpccnt[NFSPROC_FSSTAT]++;
|
||||
memset(&fsstat, 0, sizeof(struct FSSTAT3args));
|
||||
fsstat.fsroot = nmp->nm_fh;
|
||||
error = nfs_request(nmp, NFSPROC_FSSTAT, &fsstat, datareply);
|
||||
error = nfs_request(nmp, NFSPROC_FSSTAT, &fsstat, &datareply);
|
||||
if (error)
|
||||
{
|
||||
goto errout_with_semaphore;
|
||||
}
|
||||
|
||||
bcopy (datareply, &sfp, sizeof(struct nfs_statfs));
|
||||
nmp->nm_head->n_fattr = sfp.obj_attributes;
|
||||
sfp = (struct nfs_statfs *) datareply;
|
||||
nmp->nm_head->n_fattr = sfp->obj_attributes;
|
||||
sbp->f_bsize = NFS_FABLKSIZE;
|
||||
tquad = fxdr_hyper(&sfp.sf_tbytes);
|
||||
tquad = fxdr_hyper(&sfp->sf_tbytes);
|
||||
sbp->f_blocks = tquad / (uint64_t) NFS_FABLKSIZE;
|
||||
tquad = fxdr_hyper(&sfp.sf_fbytes);
|
||||
tquad = fxdr_hyper(&sfp->sf_fbytes);
|
||||
sbp->f_bfree = tquad / (uint64_t) NFS_FABLKSIZE;
|
||||
tquad = fxdr_hyper(&sfp.sf_abytes);
|
||||
tquad = fxdr_hyper(&sfp->sf_abytes);
|
||||
sbp->f_bavail = tquad / (uint64_t) NFS_FABLKSIZE;
|
||||
tquad = fxdr_hyper(&sfp.sf_tfiles);
|
||||
tquad = fxdr_hyper(&sfp->sf_tfiles);
|
||||
sbp->f_files = tquad;
|
||||
tquad = fxdr_hyper(&sfp.sf_ffiles);
|
||||
tquad = fxdr_hyper(&sfp->sf_ffiles);
|
||||
sbp->f_ffree = tquad;
|
||||
sbp->f_namelen = NAME_MAX;
|
||||
|
||||
@ -1257,7 +1236,7 @@ static int nfs_remove(struct inode *mountpt, const char *relpath)
|
||||
struct nfsnode *np;
|
||||
void *datareply;
|
||||
struct REMOVE3args remove;
|
||||
struct REMOVE3resok resok;
|
||||
struct REMOVE3resok *resok;
|
||||
int error = 0;
|
||||
|
||||
/* Sanity checks */
|
||||
@ -1295,7 +1274,7 @@ static int nfs_remove(struct inode *mountpt, const char *relpath)
|
||||
remove.object.dir = np->n_fhp;
|
||||
remove.object.name = relpath;
|
||||
|
||||
error = nfs_request(nmp, NFSPROC_REMOVE, &remove, datareply);
|
||||
error = nfs_request(nmp, NFSPROC_REMOVE, &remove, &datareply);
|
||||
|
||||
/* Kludge City: If the first reply to the remove rpc is lost..
|
||||
* the reply to the retransmitted request will be ENOENT
|
||||
@ -1313,8 +1292,8 @@ static int nfs_remove(struct inode *mountpt, const char *relpath)
|
||||
goto errout_with_semaphore;
|
||||
}
|
||||
|
||||
bcopy (datareply, &resok, sizeof(struct REMOVE3resok));
|
||||
np->n_fattr = resok.dir_wcc.after;
|
||||
resok = (struct REMOVE3resok *) datareply;
|
||||
np->n_fattr = resok->dir_wcc.after;
|
||||
np->n_flag |= NMODIFIED;
|
||||
}
|
||||
NFS_INVALIDATE_ATTRCACHE(np);
|
||||
@ -1333,12 +1312,11 @@ errout_with_semaphore:
|
||||
|
||||
static int nfs_mkdir(struct inode *mountpt, const char *relpath, mode_t mode)
|
||||
{
|
||||
//struct nfs_fattr *vap;
|
||||
struct nfsv3_sattr sp;
|
||||
struct nfsmount *nmp;
|
||||
struct nfsnode *np;
|
||||
struct MKDIR3args mkir;
|
||||
struct MKDIR3resok resok;
|
||||
struct MKDIR3resok *resok;
|
||||
void *datareply;
|
||||
int error = 0;
|
||||
|
||||
@ -1349,18 +1327,7 @@ static int nfs_mkdir(struct inode *mountpt, const char *relpath, mode_t mode)
|
||||
/* Get the mountpoint private data from the inode structure */
|
||||
|
||||
nmp = (struct nfsmount*) mountpt->i_private;
|
||||
|
||||
/* Create an instance of the private data to describe the opened
|
||||
* file.
|
||||
*/
|
||||
|
||||
np = (struct nfsnode*)kzalloc(sizeof(struct nfsnode));
|
||||
if (!np)
|
||||
{
|
||||
fdbg("Failed to allocate private data\n", error);
|
||||
error = -ENOMEM;
|
||||
goto errout_with_semaphore;
|
||||
}
|
||||
np = nmp->nm_head;
|
||||
|
||||
/* Check if the mount is still healthy */
|
||||
|
||||
@ -1373,7 +1340,7 @@ static int nfs_mkdir(struct inode *mountpt, const char *relpath, mode_t mode)
|
||||
|
||||
nfsstats.rpccnt[NFSPROC_MKDIR]++;
|
||||
memset(&mkir, 0, sizeof(struct MKDIR3args));
|
||||
mkir.where.dir = nmp->nm_fh;
|
||||
mkir.where.dir = np->n_fhp;
|
||||
mkir.where.name = relpath;
|
||||
|
||||
sp.sa_modetrue = nfs_true;
|
||||
@ -1383,26 +1350,24 @@ static int nfs_mkdir(struct inode *mountpt, const char *relpath, mode_t mode)
|
||||
sp.sa_sizefalse = nfs_xdrneg1;
|
||||
sp.sa_atimetype = txdr_unsigned(NFSV3SATTRTIME_TOCLIENT);
|
||||
sp.sa_mtimetype = txdr_unsigned(NFSV3SATTRTIME_TOCLIENT);
|
||||
|
||||
|
||||
memset(&sp.sa_atime, 0, sizeof(nfstime3));
|
||||
memset(&sp.sa_mtime, 0, sizeof(nfstime3));
|
||||
|
||||
mkir.attributes = sp;
|
||||
|
||||
error = nfs_request(nmp, NFSPROC_MKDIR, &mkir, datareply);
|
||||
error = nfs_request(nmp, NFSPROC_MKDIR, &mkir, &datareply);
|
||||
if (error)
|
||||
{
|
||||
goto errout_with_semaphore;
|
||||
}
|
||||
|
||||
bcopy (datareply, &resok, sizeof(struct MKDIR3resok));
|
||||
resok = (struct MKDIR3resok *) datareply;
|
||||
np->nfsv3_type = NFDIR;
|
||||
np->n_fhp = resok.handle;
|
||||
np->n_fattr = resok.obj_attributes;
|
||||
np->n_fhp = resok->handle;
|
||||
np->n_fattr = resok->obj_attributes;
|
||||
np->n_flag |= NMODIFIED;
|
||||
|
||||
nmp->nm_head = np;
|
||||
|
||||
|
||||
NFS_INVALIDATE_ATTRCACHE(np);
|
||||
|
||||
errout_with_semaphore:
|
||||
@ -1422,7 +1387,7 @@ static int nfs_rmdir(struct inode *mountpt, const char *relpath)
|
||||
struct nfsmount *nmp;
|
||||
struct nfsnode *np;
|
||||
struct RMDIR3args rmdir;
|
||||
struct RMDIR3resok resok;
|
||||
struct RMDIR3resok *resok;
|
||||
void *datareply;
|
||||
int error = 0;
|
||||
|
||||
@ -1455,8 +1420,8 @@ static int nfs_rmdir(struct inode *mountpt, const char *relpath)
|
||||
memset(&rmdir, 0, sizeof(struct RMDIR3args));
|
||||
rmdir.object.dir = np->n_fhp;
|
||||
rmdir.object.name = relpath;
|
||||
error = nfs_request(nmp, NFSPROC_RMDIR, &rmdir, datareply);
|
||||
|
||||
error = nfs_request(nmp, NFSPROC_RMDIR, &rmdir, &datareply);
|
||||
if (error == ENOENT)
|
||||
{
|
||||
error = 0;
|
||||
@ -1467,8 +1432,8 @@ static int nfs_rmdir(struct inode *mountpt, const char *relpath)
|
||||
goto errout_with_semaphore;
|
||||
}
|
||||
|
||||
bcopy (datareply, &resok, sizeof(struct RMDIR3resok));
|
||||
np->n_fattr = resok.dir_wcc.after;
|
||||
resok = (struct RMDIR3resok *) datareply;
|
||||
np->n_fattr = resok->dir_wcc.after;
|
||||
np->n_flag |= NMODIFIED;
|
||||
}
|
||||
|
||||
@ -1493,7 +1458,7 @@ static int nfs_rename(struct inode *mountpt, const char *oldrelpath,
|
||||
struct nfsnode *np;
|
||||
void *datareply;
|
||||
struct RENAME3args rename;
|
||||
struct RENAME3resok resok;
|
||||
struct RENAME3resok *resok;
|
||||
int error = 0;
|
||||
|
||||
/* Sanity checks */
|
||||
@ -1528,9 +1493,9 @@ static int nfs_rename(struct inode *mountpt, const char *oldrelpath,
|
||||
rename.to.dir = np->n_fhp;
|
||||
rename.to.name = newrelpath;
|
||||
|
||||
error = nfs_request(nmp, NFSPROC_RENAME, &rename, datareply);
|
||||
error = nfs_request(nmp, NFSPROC_RENAME, &rename, &datareply);
|
||||
|
||||
/* Kludge: Map ENOENT => 0 assuming that it is a reply to a retry. */
|
||||
/* ENOENT => 0 assuming that it is a reply to a retry. */
|
||||
|
||||
if (error == ENOENT)
|
||||
{
|
||||
@ -1542,8 +1507,8 @@ static int nfs_rename(struct inode *mountpt, const char *oldrelpath,
|
||||
goto errout_with_semaphore;
|
||||
}
|
||||
|
||||
bcopy (datareply, &resok, sizeof(struct RENAME3resok));
|
||||
np->n_fattr = resok.todir_wcc.after;
|
||||
resok = (struct RENAME3resok *) datareply;
|
||||
np->n_fattr = resok->todir_wcc.after;
|
||||
np->n_flag |= NMODIFIED;
|
||||
NFS_INVALIDATE_ATTRCACHE(np);
|
||||
|
||||
@ -1561,7 +1526,7 @@ errout_with_semaphore:
|
||||
|
||||
static int nfs_fsinfo(struct inode *mountpt, const char *relpath, struct stat *buf)
|
||||
{
|
||||
struct nfsv3_fsinfo fsp;
|
||||
struct nfsv3_fsinfo *fsp;
|
||||
struct FSINFOargs fsinfo;
|
||||
struct nfsmount *nmp;
|
||||
uint32_t pref, max;
|
||||
@ -1588,21 +1553,22 @@ static int nfs_fsinfo(struct inode *mountpt, const char *relpath, struct stat *b
|
||||
memset(buf, 0, sizeof(struct stat));
|
||||
nfsstats.rpccnt[NFSPROC_FSINFO]++;
|
||||
fsinfo.fsroot = nmp->nm_fh;
|
||||
error = nfs_request(nmp, NFSPROC_FSINFO, &fsinfo, datareply);
|
||||
|
||||
error = nfs_request(nmp, NFSPROC_FSINFO, &fsinfo, &datareply);
|
||||
if (error)
|
||||
{
|
||||
goto errout_with_semaphore;
|
||||
}
|
||||
|
||||
bcopy (datareply, &fsp, sizeof(struct nfsv3_fsinfo));
|
||||
nmp->nm_head->n_fattr = fsp.obj_attributes;
|
||||
pref = fxdr_unsigned(uint32_t, fsp.fs_wtpref);
|
||||
fsp = (struct nfsv3_fsinfo *) datareply;
|
||||
nmp->nm_head->n_fattr = fsp->obj_attributes;
|
||||
pref = fxdr_unsigned(uint32_t, fsp->fs_wtpref);
|
||||
if (pref < nmp->nm_wsize)
|
||||
{
|
||||
nmp->nm_wsize = (pref + NFS_FABLKSIZE - 1) & ~(NFS_FABLKSIZE - 1);
|
||||
}
|
||||
|
||||
max = fxdr_unsigned(uint32_t, fsp.fs_wtmax);
|
||||
max = fxdr_unsigned(uint32_t, fsp->fs_wtmax);
|
||||
if (max < nmp->nm_wsize)
|
||||
{
|
||||
nmp->nm_wsize = max & ~(NFS_FABLKSIZE - 1);
|
||||
@ -1610,13 +1576,13 @@ static int nfs_fsinfo(struct inode *mountpt, const char *relpath, struct stat *b
|
||||
nmp->nm_wsize = max;
|
||||
}
|
||||
|
||||
pref = fxdr_unsigned(uint32_t, fsp.fs_rtpref);
|
||||
pref = fxdr_unsigned(uint32_t, fsp->fs_rtpref);
|
||||
if (pref < nmp->nm_rsize)
|
||||
{
|
||||
nmp->nm_rsize = (pref + NFS_FABLKSIZE - 1) & ~(NFS_FABLKSIZE - 1);
|
||||
}
|
||||
|
||||
max = fxdr_unsigned(uint32_t, fsp.fs_rtmax);
|
||||
max = fxdr_unsigned(uint32_t, fsp->fs_rtmax);
|
||||
if (max < nmp->nm_rsize)
|
||||
{
|
||||
nmp->nm_rsize = max & ~(NFS_FABLKSIZE - 1);
|
||||
@ -1626,7 +1592,7 @@ static int nfs_fsinfo(struct inode *mountpt, const char *relpath, struct stat *b
|
||||
}
|
||||
}
|
||||
|
||||
pref = fxdr_unsigned(uint32_t, fsp.fs_dtpref);
|
||||
pref = fxdr_unsigned(uint32_t, fsp->fs_dtpref);
|
||||
if (pref < nmp->nm_readdirsize)
|
||||
{
|
||||
nmp->nm_readdirsize = (pref + NFS_DIRBLKSIZ - 1) & ~(NFS_DIRBLKSIZ - 1);
|
||||
@ -1641,14 +1607,14 @@ static int nfs_fsinfo(struct inode *mountpt, const char *relpath, struct stat *b
|
||||
}
|
||||
}
|
||||
|
||||
buf->st_mode = fxdr_hyper(&fsp.obj_attributes.fa_mode);
|
||||
buf->st_size = fxdr_hyper(&fsp.obj_attributes.fa3_size);
|
||||
buf->st_mode = fxdr_hyper(&fsp->obj_attributes.fa_mode);
|
||||
buf->st_size = fxdr_hyper(&fsp->obj_attributes.fa3_size);
|
||||
buf->st_blksize = 0;
|
||||
buf->st_blocks = 0;
|
||||
buf->st_mtime = fxdr_hyper(&fsp.obj_attributes.fa3_mtime);
|
||||
buf->st_atime = fxdr_hyper(&fsp.obj_attributes.fa3_atime);
|
||||
buf->st_ctime = fxdr_hyper(&fsp.obj_attributes.fa3_ctime);
|
||||
nmp->nm_flag |= NFSMNT_GOTFSINFO;
|
||||
buf->st_blocks = 0;
|
||||
buf->st_mtime = fxdr_hyper(&fsp->obj_attributes.fa3_mtime);
|
||||
buf->st_atime = fxdr_hyper(&fsp->obj_attributes.fa3_atime);
|
||||
buf->st_ctime = fxdr_hyper(&fsp->obj_attributes.fa3_ctime);
|
||||
nmp->nm_flag |= NFSMNT_GOTFSINFO;
|
||||
|
||||
errout_with_semaphore:
|
||||
nfs_semgive(nmp);
|
||||
|
@ -1117,8 +1117,6 @@ void rpcclnt_safedisconnect(struct rpcclnt *rpc)
|
||||
}
|
||||
#endif
|
||||
|
||||
/* XXX: ignores tryagain! */
|
||||
|
||||
/* Code from nfs_request - goes something like this - fill in task struct -
|
||||
* links task into list - calls nfs_send() for first transmit - calls
|
||||
* nfs_receive() to get reply - fills in reply (which should be initialized
|
||||
@ -1270,7 +1268,6 @@ int rpcclnt_request(struct rpcclnt *rpc, int procnum, struct rpc_reply *reply, v
|
||||
|
||||
/* Break down the rpc header and check if ok */
|
||||
|
||||
memset(reply, 0, sizeof(rpc_reply));
|
||||
reply->stat.type = fxdr_unsigned(uint32_t, replysvr->stat.type);
|
||||
if (reply->stat.type == RPC_MSGDENIED)
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user