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:
patacongo 2012-05-07 23:33:39 +00:00
parent c5bbc7b71d
commit f5ad5f4bc2
4 changed files with 130 additions and 165 deletions

View File

@ -10,7 +10,7 @@
* copyright (c) 2004 * copyright (c) 2004
* the regents of the university of michigan * the regents of the university of michigan
* all rights reserved * all rights reserved
* *
* permission is granted to use, copy, create derivative works and redistribute * 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 * 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 * 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 * written prior authorization. if the above copyright notice or any other
* identification of the university of michigan is included in any copy of any * 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. * portion of this software, then the disclaimer below must also be included.
* *
* this software is provided as is, without representation from the university * 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 * 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 * 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_proctlen = 0;
rpc->rc_proct = NULL; rpc->rc_proct = NULL;
nmp->nm_rpcclnt = rpc; nmp->nm_rpcclnt = rpc;
return rpcclnt_connect(rpc); return rpcclnt_connect(rpc);
@ -180,7 +180,7 @@ void nfs_safedisconnect(struct nfsmount *nmp)
} }
#endif #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; int error;
struct rpcclnt *clnt= nmp->nm_rpcclnt; struct rpcclnt *clnt= nmp->nm_rpcclnt;
@ -189,12 +189,14 @@ int nfs_request(struct nfsmount *nmp, int procnum, void *datain, void *dataout)
tryagain: tryagain:
memset(&reply, 0, sizeof(reply));
if ((error = rpcclnt_request(clnt, procnum, &reply, datain)) != 0) if ((error = rpcclnt_request(clnt, procnum, &reply, datain)) != 0)
{ {
goto out; goto out;
} }
bcopy (dataout, &reply.stat.where, sizeof(reply.stat.where)); *dataout = (void *)reply.stat.where;
if (reply.rpc_verfi.authtype != 0) if (reply.rpc_verfi.authtype != 0)
{ {
@ -231,7 +233,7 @@ tryagain:
} }
return 0; return 0;
out: out:
return error; return error;
} }

View File

@ -10,7 +10,7 @@
* copyright (c) 2004 * copyright (c) 2004
* the regents of the university of michigan * the regents of the university of michigan
* all rights reserved * all rights reserved
* *
* permission is granted to use, copy, create derivative works and redistribute * 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 * 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 * 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 * written prior authorization. if the above copyright notice or any other
* identification of the university of michigan is included in any copy of any * 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. * portion of this software, then the disclaimer below must also be included.
* *
* this software is provided as is, without representation from the university * 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 * 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 * 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 int nfs_sigintr(struct nfsmount *, struct nfsreq *, cthread_t *);
EXTERN void nfs_safedisconnect(struct nfsmount *); EXTERN void nfs_safedisconnect(struct nfsmount *);
#endif #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 *); EXTERN int nfs_nmcancelreqs(struct nfsmount *);
#undef EXTERN #undef EXTERN

View File

@ -185,7 +185,7 @@ nfs_open(FAR struct file *filep, FAR const char *relpath,
struct nfsmount *nmp; struct nfsmount *nmp;
struct nfsnode *np; struct nfsnode *np;
struct CREATE3args create; struct CREATE3args create;
struct CREATE3resok resok; struct CREATE3resok *resok;
void *datareply; void *datareply;
int error = 0; int error = 0;
@ -222,22 +222,22 @@ again:
memset(&sp, 0, sizeof(struct nfsv3_sattr)); memset(&sp, 0, sizeof(struct nfsv3_sattr));
memset(&vap, 0, sizeof(struct nfs_fattr)); memset(&vap, 0, sizeof(struct nfs_fattr));
vap = nmp->nm_head->n_fattr; vap = nmp->nm_head->n_fattr;
sp.sa_modetrue = true; sp.sa_modetrue = true;
sp.sa_mode = txdr_unsigned(vap.fa_mode); sp.sa_mode = txdr_unsigned(mode);
sp.sa_uidfalse = nfs_xdrneg1; sp.sa_uidfalse = nfs_xdrneg1;
sp.sa_gidfalse = nfs_xdrneg1; sp.sa_gidfalse = nfs_xdrneg1;
sp.sa_sizefalse = nfs_xdrneg1; sp.sa_sizefalse = nfs_xdrneg1;
sp.sa_atimetype = txdr_unsigned(NFSV3SATTRTIME_TOCLIENT); sp.sa_atimetype = txdr_unsigned(NFSV3SATTRTIME_TOCLIENT);
sp.sa_mtimetype = txdr_unsigned(NFSV3SATTRTIME_TOCLIENT); sp.sa_mtimetype = txdr_unsigned(NFSV3SATTRTIME_TOCLIENT);
sp.sa_atime = vap.fa3_atime; sp.sa_atime = vap.fa3_atime;
sp.sa_mtime = vap.fa3_mtime; sp.sa_mtime = vap.fa3_mtime;
memset(&create, 0, sizeof(struct CREATE3args)); memset(&create, 0, sizeof(struct CREATE3args));
create.how = sp; create.how = sp;
create.where.dir = nmp->nm_fh; create.where.dir = np->n_fhp;
create.where.name = relpath; create.where.name = relpath;
error = nfs_request(nmp, NFSPROC_CREATE, &create, datareply); error = nfs_request(nmp, NFSPROC_CREATE, &create, &datareply);
if (!error) if (!error)
{ {
/* Create an instance of the file private data to describe the opened /* Create an instance of the file private data to describe the opened
@ -256,14 +256,14 @@ again:
* non-zero elements) * non-zero elements)
*/ */
bcopy (datareply, &resok, sizeof(struct CREATE3resok)); resok = (struct CREATE3resok *) datareply;
np->n_open = true; np->n_open = true;
np->nfsv3_type = NFREG; np->nfsv3_type = NFREG;
np->n_fhp = resok.handle; np->n_fhp = resok->handle;
np->n_size = fxdr_hyper(&resok.attributes.fa3_size); np->n_size = fxdr_hyper(&resok->attributes.fa3_size);
np->n_fattr = resok.attributes; np->n_fattr = resok->attributes;
fxdr_nfsv3time(&resok.attributes.fa3_mtime, &np->n_mtime) fxdr_nfsv3time(&resok->attributes.fa3_mtime, &np->n_mtime)
np->n_ctime = fxdr_hyper(&resok.attributes.fa3_ctime); np->n_ctime = fxdr_hyper(&resok->attributes.fa3_ctime);
/* Attach the private date to the struct file instance */ /* Attach the private date to the struct file instance */
@ -275,7 +275,7 @@ again:
* (but a simple reference count could have done that). * (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; nmp->nm_head = np->n_next;
error = 0; error = 0;
} }
@ -311,6 +311,7 @@ again:
NFS_INVALIDATE_ATTRCACHE(np); NFS_INVALIDATE_ATTRCACHE(np);
errout_with_semaphore: errout_with_semaphore:
kfree(np);
nfs_semgive(nmp); nfs_semgive(nmp);
return error; return error;
} }
@ -364,7 +365,7 @@ static ssize_t nfs_read(FAR struct file *filep, char *buffer, size_t buflen)
uint64_t offset; uint64_t offset;
void *datareply; void *datareply;
struct READ3args read; struct READ3args read;
struct READ3resok resok; struct READ3resok *resok;
uint8_t *userbuffer = (uint8_t*)buffer; uint8_t *userbuffer = (uint8_t*)buffer;
int error = 0; int error = 0;
int len; int len;
@ -435,19 +436,20 @@ again:
read.count = buflen; read.count = buflen;
read.offset = offset; read.offset = offset;
error = nfs_request(nmp, NFSPROC_READ, &read, datareply); error = nfs_request(nmp, NFSPROC_READ, &read, &datareply);
if (error) if (error)
{ {
goto errout_with_semaphore; goto errout_with_semaphore;
} }
bcopy (datareply, &resok, sizeof(struct READ3resok)); //bcopy (datareply, &resok, sizeof(struct READ3resok));
eof = resok.eof; resok = (struct READ3resok *) datareply;
eof = resok->eof;
if (eof == true) if (eof == true)
{ {
readsize = resok.count; readsize = resok->count;
np->n_fattr = resok.file_attributes; np->n_fattr = resok->file_attributes;
memcpy(userbuffer, resok.data, readsize); memcpy(userbuffer, resok->data, readsize);
} }
else else
{ {
@ -475,7 +477,7 @@ nfs_write(FAR struct file *filep, const char *buffer, size_t buflen)
unsigned int writesize; unsigned int writesize;
void *datareply; void *datareply;
struct WRITE3args write; struct WRITE3args write;
struct WRITE3resok resok; struct WRITE3resok *resok;
uint8_t *userbuffer = (uint8_t*)buffer; uint8_t *userbuffer = (uint8_t*)buffer;
int error = 0; int error = 0;
uint64_t offset; uint64_t offset;
@ -529,22 +531,23 @@ nfs_write(FAR struct file *filep, const char *buffer, size_t buflen)
write.stable = committed; write.stable = committed;
memcpy((void *)write.data, userbuffer, buflen); memcpy((void *)write.data, userbuffer, buflen);
error = nfs_request(nmp, NFSPROC_WRITE, &write, datareply); error = nfs_request(nmp, NFSPROC_WRITE, &write, &datareply);
if (error) if (error)
{ {
goto errout_with_semaphore; goto errout_with_semaphore;
} }
bcopy (datareply, &resok, sizeof(struct WRITE3resok)); //bcopy (datareply, &resok, sizeof(struct WRITE3resok));
writesize = resok.count; resok = (struct WRITE3resok *) datareply;
writesize = resok->count;
if (writesize == 0) if (writesize == 0)
{ {
error = NFSERR_IO; error = NFSERR_IO;
goto errout_with_semaphore; goto errout_with_semaphore;
} }
commit = resok.committed; commit = resok->committed;
np->n_fattr = resok.file_wcc.after; np->n_fattr = resok->file_wcc.after;
/* Return the lowest committment level obtained by any of the RPCs. */ /* 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) 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; 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) 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) bool end_of_directory, struct fs_dirent_s *dir)
{ {
int error = 0; int error = 0;
void *datareply = NULL; void *datareply;
struct READDIR3args readir; struct READDIR3args readir;
struct READDIR3resok resok; struct READDIR3resok *resok;
/* Loop around doing readdir rpc's of size nm_readdirsize /* Loop around doing readdir rpc's of size nm_readdirsize
* truncated to a multiple of NFS_READDIRBLKSIZ. * 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]; 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) if (error)
{ {
goto nfsmout; goto nfsmout;
} }
bcopy (datareply, &resok, sizeof(struct READDIR3resok)); //bcopy (datareply, &resok, sizeof(struct READDIR3resok));
np->n_fattr = resok.dir_attributes; resok = (struct READDIR3resok *) datareply;
np->n_cookieverf.nfsuquad[0] = resok.cookieverf.nfsuquad[0]; np->n_fattr = resok->dir_attributes;
np->n_cookieverf.nfsuquad[1] = resok.cookieverf.nfsuquad[1]; np->n_cookieverf.nfsuquad[0] = resok->cookieverf.nfsuquad[0];
dir->fd_dir.d_type = resok.reply.entries->fileid; np->n_cookieverf.nfsuquad[1] = resok->cookieverf.nfsuquad[1];
memcpy(&dir->fd_dir.d_name[NAME_MAX], &resok.reply.entries->name, NAME_MAX); 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->fd_dir.d_name = resok->reply.entries->name;//
dir->u.nfs.cookie[0] = resok.reply.entries->cookie.nfsuquad[0]; 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[1] = resok->reply.entries->cookie.nfsuquad[1];
if (resok.reply.eof == true) if (resok->reply.eof == true)
{ {
end_of_directory = 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 */ /* 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]); np->n_direofoffset = fxdr_hyper(&dir->u.nfs.cookie[0]);
@ -686,7 +690,7 @@ nfsmout:
/**************************************************************************** /****************************************************************************
* Name: nfs_readdir * 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) int mountnfs(struct nfs_args *argp, void **handle)
{ {
struct nfsmount *nmp; struct nfsmount *nmp;
struct nfsnode *np;
int error; int error;
/* Create an instance of the mountpt state structure */ /* 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; nmp->nm_nam = argp->addr;
nfs_decode_args(nmp, argp); 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 */ /* Set up the sockets and per-host congestion */
nmp->nm_sotype = argp->sotype; nmp->nm_sotype = argp->sotype;
@ -1056,6 +1073,7 @@ int mountnfs(struct nfs_args *argp, void **handle)
bad: bad:
nfs_disconnect(nmp); nfs_disconnect(nmp);
sem_destroy(&nmp->nm_sem); sem_destroy(&nmp->nm_sem);
kfree(nmp->nm_head);
kfree(nmp->nm_so); kfree(nmp->nm_so);
kfree(nmp->nm_rpcclnt); kfree(nmp->nm_rpcclnt);
kfree(nmp); 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) int nfs_unbind(void *handle, struct inode **blkdriver)
{ {
struct nfsmount *nmp = (struct nfsmount *) handle ; struct nfsmount *nmp = (struct nfsmount *) handle ;
int error;
fvdbg("Entry\n"); fvdbg("Entry\n");
@ -1123,52 +1140,14 @@ int nfs_unbind(void *handle, struct inode **blkdriver)
} }
nfs_semtake(nmp); nfs_semtake(nmp);
if (nmp->nm_head) nfs_disconnect(nmp);
{ sem_destroy(&nmp->nm_sem);
/* We cannot unmount now.. there are open files */ kfree(nmp->nm_head);
kfree(nmp->nm_so);
kfree(nmp->nm_rpcclnt);
kfree(nmp);
error = -EBUSY; return 0;
}
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;
} }
/**************************************************************************** /****************************************************************************
@ -1180,7 +1159,7 @@ int nfs_unbind(void *handle, struct inode **blkdriver)
static int nfs_statfs(struct inode *mountpt, struct statfs *sbp) static int nfs_statfs(struct inode *mountpt, struct statfs *sbp)
{ {
struct nfs_statfs sfp; struct nfs_statfs *sfp;
struct nfsmount *nmp; struct nfsmount *nmp;
int error = 0; int error = 0;
uint64_t tquad; uint64_t tquad;
@ -1218,24 +1197,24 @@ static int nfs_statfs(struct inode *mountpt, struct statfs *sbp)
nfsstats.rpccnt[NFSPROC_FSSTAT]++; nfsstats.rpccnt[NFSPROC_FSSTAT]++;
memset(&fsstat, 0, sizeof(struct FSSTAT3args)); memset(&fsstat, 0, sizeof(struct FSSTAT3args));
fsstat.fsroot = nmp->nm_fh; fsstat.fsroot = nmp->nm_fh;
error = nfs_request(nmp, NFSPROC_FSSTAT, &fsstat, datareply); error = nfs_request(nmp, NFSPROC_FSSTAT, &fsstat, &datareply);
if (error) if (error)
{ {
goto errout_with_semaphore; goto errout_with_semaphore;
} }
bcopy (datareply, &sfp, sizeof(struct nfs_statfs)); sfp = (struct nfs_statfs *) datareply;
nmp->nm_head->n_fattr = sfp.obj_attributes; nmp->nm_head->n_fattr = sfp->obj_attributes;
sbp->f_bsize = NFS_FABLKSIZE; 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; 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; 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; sbp->f_bavail = tquad / (uint64_t) NFS_FABLKSIZE;
tquad = fxdr_hyper(&sfp.sf_tfiles); tquad = fxdr_hyper(&sfp->sf_tfiles);
sbp->f_files = tquad; sbp->f_files = tquad;
tquad = fxdr_hyper(&sfp.sf_ffiles); tquad = fxdr_hyper(&sfp->sf_ffiles);
sbp->f_ffree = tquad; sbp->f_ffree = tquad;
sbp->f_namelen = NAME_MAX; sbp->f_namelen = NAME_MAX;
@ -1257,7 +1236,7 @@ static int nfs_remove(struct inode *mountpt, const char *relpath)
struct nfsnode *np; struct nfsnode *np;
void *datareply; void *datareply;
struct REMOVE3args remove; struct REMOVE3args remove;
struct REMOVE3resok resok; struct REMOVE3resok *resok;
int error = 0; int error = 0;
/* Sanity checks */ /* Sanity checks */
@ -1295,7 +1274,7 @@ static int nfs_remove(struct inode *mountpt, const char *relpath)
remove.object.dir = np->n_fhp; remove.object.dir = np->n_fhp;
remove.object.name = relpath; 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.. /* Kludge City: If the first reply to the remove rpc is lost..
* the reply to the retransmitted request will be ENOENT * 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; goto errout_with_semaphore;
} }
bcopy (datareply, &resok, sizeof(struct REMOVE3resok)); resok = (struct REMOVE3resok *) datareply;
np->n_fattr = resok.dir_wcc.after; np->n_fattr = resok->dir_wcc.after;
np->n_flag |= NMODIFIED; np->n_flag |= NMODIFIED;
} }
NFS_INVALIDATE_ATTRCACHE(np); NFS_INVALIDATE_ATTRCACHE(np);
@ -1333,12 +1312,11 @@ errout_with_semaphore:
static int nfs_mkdir(struct inode *mountpt, const char *relpath, mode_t mode) static int nfs_mkdir(struct inode *mountpt, const char *relpath, mode_t mode)
{ {
//struct nfs_fattr *vap;
struct nfsv3_sattr sp; struct nfsv3_sattr sp;
struct nfsmount *nmp; struct nfsmount *nmp;
struct nfsnode *np; struct nfsnode *np;
struct MKDIR3args mkir; struct MKDIR3args mkir;
struct MKDIR3resok resok; struct MKDIR3resok *resok;
void *datareply; void *datareply;
int error = 0; 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 */ /* Get the mountpoint private data from the inode structure */
nmp = (struct nfsmount*) mountpt->i_private; nmp = (struct nfsmount*) mountpt->i_private;
np = nmp->nm_head;
/* 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;
}
/* Check if the mount is still healthy */ /* 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]++; nfsstats.rpccnt[NFSPROC_MKDIR]++;
memset(&mkir, 0, sizeof(struct MKDIR3args)); memset(&mkir, 0, sizeof(struct MKDIR3args));
mkir.where.dir = nmp->nm_fh; mkir.where.dir = np->n_fhp;
mkir.where.name = relpath; mkir.where.name = relpath;
sp.sa_modetrue = nfs_true; 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_sizefalse = nfs_xdrneg1;
sp.sa_atimetype = txdr_unsigned(NFSV3SATTRTIME_TOCLIENT); sp.sa_atimetype = txdr_unsigned(NFSV3SATTRTIME_TOCLIENT);
sp.sa_mtimetype = txdr_unsigned(NFSV3SATTRTIME_TOCLIENT); sp.sa_mtimetype = txdr_unsigned(NFSV3SATTRTIME_TOCLIENT);
memset(&sp.sa_atime, 0, sizeof(nfstime3)); memset(&sp.sa_atime, 0, sizeof(nfstime3));
memset(&sp.sa_mtime, 0, sizeof(nfstime3)); memset(&sp.sa_mtime, 0, sizeof(nfstime3));
mkir.attributes = sp; mkir.attributes = sp;
error = nfs_request(nmp, NFSPROC_MKDIR, &mkir, datareply); error = nfs_request(nmp, NFSPROC_MKDIR, &mkir, &datareply);
if (error) if (error)
{ {
goto errout_with_semaphore; goto errout_with_semaphore;
} }
bcopy (datareply, &resok, sizeof(struct MKDIR3resok)); resok = (struct MKDIR3resok *) datareply;
np->nfsv3_type = NFDIR; np->nfsv3_type = NFDIR;
np->n_fhp = resok.handle; np->n_fhp = resok->handle;
np->n_fattr = resok.obj_attributes; np->n_fattr = resok->obj_attributes;
np->n_flag |= NMODIFIED; np->n_flag |= NMODIFIED;
nmp->nm_head = np;
NFS_INVALIDATE_ATTRCACHE(np); NFS_INVALIDATE_ATTRCACHE(np);
errout_with_semaphore: errout_with_semaphore:
@ -1422,7 +1387,7 @@ static int nfs_rmdir(struct inode *mountpt, const char *relpath)
struct nfsmount *nmp; struct nfsmount *nmp;
struct nfsnode *np; struct nfsnode *np;
struct RMDIR3args rmdir; struct RMDIR3args rmdir;
struct RMDIR3resok resok; struct RMDIR3resok *resok;
void *datareply; void *datareply;
int error = 0; int error = 0;
@ -1455,8 +1420,8 @@ static int nfs_rmdir(struct inode *mountpt, const char *relpath)
memset(&rmdir, 0, sizeof(struct RMDIR3args)); memset(&rmdir, 0, sizeof(struct RMDIR3args));
rmdir.object.dir = np->n_fhp; rmdir.object.dir = np->n_fhp;
rmdir.object.name = relpath; rmdir.object.name = relpath;
error = nfs_request(nmp, NFSPROC_RMDIR, &rmdir, datareply);
error = nfs_request(nmp, NFSPROC_RMDIR, &rmdir, &datareply);
if (error == ENOENT) if (error == ENOENT)
{ {
error = 0; error = 0;
@ -1467,8 +1432,8 @@ static int nfs_rmdir(struct inode *mountpt, const char *relpath)
goto errout_with_semaphore; goto errout_with_semaphore;
} }
bcopy (datareply, &resok, sizeof(struct RMDIR3resok)); resok = (struct RMDIR3resok *) datareply;
np->n_fattr = resok.dir_wcc.after; np->n_fattr = resok->dir_wcc.after;
np->n_flag |= NMODIFIED; np->n_flag |= NMODIFIED;
} }
@ -1493,7 +1458,7 @@ static int nfs_rename(struct inode *mountpt, const char *oldrelpath,
struct nfsnode *np; struct nfsnode *np;
void *datareply; void *datareply;
struct RENAME3args rename; struct RENAME3args rename;
struct RENAME3resok resok; struct RENAME3resok *resok;
int error = 0; int error = 0;
/* Sanity checks */ /* Sanity checks */
@ -1528,9 +1493,9 @@ static int nfs_rename(struct inode *mountpt, const char *oldrelpath,
rename.to.dir = np->n_fhp; rename.to.dir = np->n_fhp;
rename.to.name = newrelpath; 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) if (error == ENOENT)
{ {
@ -1542,8 +1507,8 @@ static int nfs_rename(struct inode *mountpt, const char *oldrelpath,
goto errout_with_semaphore; goto errout_with_semaphore;
} }
bcopy (datareply, &resok, sizeof(struct RENAME3resok)); resok = (struct RENAME3resok *) datareply;
np->n_fattr = resok.todir_wcc.after; np->n_fattr = resok->todir_wcc.after;
np->n_flag |= NMODIFIED; np->n_flag |= NMODIFIED;
NFS_INVALIDATE_ATTRCACHE(np); NFS_INVALIDATE_ATTRCACHE(np);
@ -1561,7 +1526,7 @@ errout_with_semaphore:
static int nfs_fsinfo(struct inode *mountpt, const char *relpath, struct stat *buf) 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 FSINFOargs fsinfo;
struct nfsmount *nmp; struct nfsmount *nmp;
uint32_t pref, max; 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)); memset(buf, 0, sizeof(struct stat));
nfsstats.rpccnt[NFSPROC_FSINFO]++; nfsstats.rpccnt[NFSPROC_FSINFO]++;
fsinfo.fsroot = nmp->nm_fh; fsinfo.fsroot = nmp->nm_fh;
error = nfs_request(nmp, NFSPROC_FSINFO, &fsinfo, datareply);
error = nfs_request(nmp, NFSPROC_FSINFO, &fsinfo, &datareply);
if (error) if (error)
{ {
goto errout_with_semaphore; goto errout_with_semaphore;
} }
bcopy (datareply, &fsp, sizeof(struct nfsv3_fsinfo)); fsp = (struct nfsv3_fsinfo *) datareply;
nmp->nm_head->n_fattr = fsp.obj_attributes; nmp->nm_head->n_fattr = fsp->obj_attributes;
pref = fxdr_unsigned(uint32_t, fsp.fs_wtpref); pref = fxdr_unsigned(uint32_t, fsp->fs_wtpref);
if (pref < nmp->nm_wsize) if (pref < nmp->nm_wsize)
{ {
nmp->nm_wsize = (pref + NFS_FABLKSIZE - 1) & ~(NFS_FABLKSIZE - 1); 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) if (max < nmp->nm_wsize)
{ {
nmp->nm_wsize = max & ~(NFS_FABLKSIZE - 1); 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; 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) if (pref < nmp->nm_rsize)
{ {
nmp->nm_rsize = (pref + NFS_FABLKSIZE - 1) & ~(NFS_FABLKSIZE - 1); 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) if (max < nmp->nm_rsize)
{ {
nmp->nm_rsize = max & ~(NFS_FABLKSIZE - 1); 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) if (pref < nmp->nm_readdirsize)
{ {
nmp->nm_readdirsize = (pref + NFS_DIRBLKSIZ - 1) & ~(NFS_DIRBLKSIZ - 1); 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_mode = fxdr_hyper(&fsp->obj_attributes.fa_mode);
buf->st_size = fxdr_hyper(&fsp.obj_attributes.fa3_size); buf->st_size = fxdr_hyper(&fsp->obj_attributes.fa3_size);
buf->st_blksize = 0; buf->st_blksize = 0;
buf->st_blocks = 0; buf->st_blocks = 0;
buf->st_mtime = fxdr_hyper(&fsp.obj_attributes.fa3_mtime); buf->st_mtime = fxdr_hyper(&fsp->obj_attributes.fa3_mtime);
buf->st_atime = fxdr_hyper(&fsp.obj_attributes.fa3_atime); buf->st_atime = fxdr_hyper(&fsp->obj_attributes.fa3_atime);
buf->st_ctime = fxdr_hyper(&fsp.obj_attributes.fa3_ctime); buf->st_ctime = fxdr_hyper(&fsp->obj_attributes.fa3_ctime);
nmp->nm_flag |= NFSMNT_GOTFSINFO; nmp->nm_flag |= NFSMNT_GOTFSINFO;
errout_with_semaphore: errout_with_semaphore:
nfs_semgive(nmp); nfs_semgive(nmp);

View File

@ -1117,8 +1117,6 @@ void rpcclnt_safedisconnect(struct rpcclnt *rpc)
} }
#endif #endif
/* XXX: ignores tryagain! */
/* Code from nfs_request - goes something like this - fill in task struct - /* Code from nfs_request - goes something like this - fill in task struct -
* links task into list - calls nfs_send() for first transmit - calls * links task into list - calls nfs_send() for first transmit - calls
* nfs_receive() to get reply - fills in reply (which should be initialized * 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 */ /* 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); reply->stat.type = fxdr_unsigned(uint32_t, replysvr->stat.type);
if (reply->stat.type == RPC_MSGDENIED) if (reply->stat.type == RPC_MSGDENIED)
{ {