projects
/
unix-history
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
tags
|
clone url
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
use new `cacheinval' macro
[unix-history]
/
usr
/
src
/
sys
/
ufs
/
ffs
/
ffs_vnops.c
diff --git
a/usr/src/sys/ufs/ffs/ffs_vnops.c
b/usr/src/sys/ufs/ffs/ffs_vnops.c
index
b381e94
..
3f9dfde
100644
(file)
--- a/
usr/src/sys/ufs/ffs/ffs_vnops.c
+++ b/
usr/src/sys/ufs/ffs/ffs_vnops.c
@@
-1,4
+1,4
@@
-/* ffs_vnops.c 6.
7 84/06/27
*/
+/* ffs_vnops.c 6.
12 84/07/20
*/
#include "../h/param.h"
#include "../h/systm.h"
#include "../h/param.h"
#include "../h/systm.h"
@@
-15,7
+15,6
@@
#include "../h/uio.h"
#include "../h/socket.h"
#include "../h/socketvar.h"
#include "../h/uio.h"
#include "../h/socket.h"
#include "../h/socketvar.h"
-#include "../h/nami.h"
#include "../h/mount.h"
extern struct fileops inodeops;
#include "../h/mount.h"
extern struct fileops inodeops;
@@
-49,9
+48,13
@@
chdirec(ipp)
register struct inode *ip;
struct a {
char *fname;
register struct inode *ip;
struct a {
char *fname;
- };
+ } *uap = (struct a *)u.u_ap;
+ register struct nameidata *ndp = &u.u_nd;
- ip = namei(uchar, LOOKUP, 1);
+ ndp->ni_nameiop = LOOKUP | FOLLOW;
+ ndp->ni_segflg = UIO_USERSPACE;
+ ndp->ni_dirp = uap->fname;
+ ip = namei(ndp);
if (ip == NULL)
return;
if ((ip->i_mode&IFMT) != IFDIR) {
if (ip == NULL)
return;
if ((ip->i_mode&IFMT) != IFDIR) {
@@
-60,7
+63,7
@@
chdirec(ipp)
}
if (access(ip, IEXEC))
goto bad;
}
if (access(ip, IEXEC))
goto bad;
-
iunlock
(ip);
+
IUNLOCK
(ip);
if (*ipp)
irele(*ipp);
*ipp = ip;
if (*ipp)
irele(*ipp);
*ipp = ip;
@@
-81,7
+84,7
@@
open()
int crtmode;
} *uap = (struct a *) u.u_ap;
int crtmode;
} *uap = (struct a *) u.u_ap;
- copen(uap->mode-FOPEN, uap->crtmode);
+ copen(uap->mode-FOPEN, uap->crtmode
, uap->fname
);
}
/*
}
/*
@@
-94,7
+97,7
@@
creat()
int fmode;
} *uap = (struct a *)u.u_ap;
int fmode;
} *uap = (struct a *)u.u_ap;
- copen(FWRITE|FCREAT|FTRUNC, uap->fmode);
+ copen(FWRITE|FCREAT|FTRUNC, uap->fmode
, uap->fname
);
}
/*
}
/*
@@
-102,12
+105,14
@@
creat()
* Check permissions, allocate an open file structure,
* and call the device open routine if any.
*/
* Check permissions, allocate an open file structure,
* and call the device open routine if any.
*/
-copen(mode, arg)
+copen(mode, arg
, fname
)
register int mode;
int arg;
register int mode;
int arg;
+ caddr_t fname;
{
register struct inode *ip;
register struct file *fp;
{
register struct inode *ip;
register struct file *fp;
+ register struct nameidata *ndp = &u.u_nd;
int i;
#ifdef notdef
int i;
#ifdef notdef
@@
-116,12
+121,15
@@
copen(mode, arg)
return;
}
#endif
return;
}
#endif
+ ndp->ni_segflg = UIO_USERSPACE;
+ ndp->ni_dirp = fname;
if (mode&FCREAT) {
if (mode&FCREAT) {
- ip = namei(uchar, CREATE, 1);
+ ndp->ni_nameiop = CREATE | FOLLOW;
+ ip = namei(ndp);
if (ip == NULL) {
if (u.u_error)
return;
if (ip == NULL) {
if (u.u_error)
return;
- ip = maknode(arg&07777&(~ISVTX));
+ ip = maknode(arg&07777&(~ISVTX)
, ndp
);
if (ip == NULL)
return;
mode &= ~FTRUNC;
if (ip == NULL)
return;
mode &= ~FTRUNC;
@@
-134,7
+142,8
@@
copen(mode, arg)
mode &= ~FCREAT;
}
} else {
mode &= ~FCREAT;
}
} else {
- ip = namei(uchar, LOOKUP, 1);
+ ndp->ni_nameiop = LOOKUP | FOLLOW;
+ ip = namei(ndp);
if (ip == NULL)
return;
}
if (ip == NULL)
return;
}
@@
-160,7
+169,7
@@
copen(mode, arg)
goto bad;
if (mode&FTRUNC)
itrunc(ip, (u_long)0);
goto bad;
if (mode&FTRUNC)
itrunc(ip, (u_long)0);
-
iunlock
(ip);
+
IUNLOCK
(ip);
fp->f_flag = mode&FMASK;
fp->f_type = DTYPE_INODE;
fp->f_ops = &inodeops;
fp->f_flag = mode&FMASK;
fp->f_type = DTYPE_INODE;
fp->f_ops = &inodeops;
@@
-194,19
+203,22
@@
mknod()
char *fname;
int fmode;
int dev;
char *fname;
int fmode;
int dev;
- } *uap;
+ } *uap = (struct a *)u.u_ap;
+ register struct nameidata *ndp = &u.u_nd;
- uap = (struct a *)u.u_ap;
if (!suser())
return;
if (!suser())
return;
- ip = namei(uchar, CREATE, 0);
+ ndp->ni_nameiop = CREATE;
+ ndp->ni_segflg = UIO_USERSPACE;
+ ndp->ni_dirp = uap->fname;
+ ip = namei(ndp);
if (ip != NULL) {
u.u_error = EEXIST;
goto out;
}
if (u.u_error)
return;
if (ip != NULL) {
u.u_error = EEXIST;
goto out;
}
if (u.u_error)
return;
- ip = maknode(uap->fmode);
+ ip = maknode(uap->fmode
, ndp
);
if (ip == NULL)
return;
switch (ip->i_mode & IFMT) {
if (ip == NULL)
return;
switch (ip->i_mode & IFMT) {
@@
-237,10
+249,13
@@
link()
register struct a {
char *target;
char *linkname;
register struct a {
char *target;
char *linkname;
- } *uap;
+ } *uap = (struct a *)u.u_ap;
+ register struct nameidata *ndp = &u.u_nd;
- uap = (struct a *)u.u_ap;
- ip = namei(uchar, LOOKUP, 1); /* well, this routine is doomed anyhow */
+ ndp->ni_nameiop = LOOKUP | FOLLOW;
+ ndp->ni_segflg = UIO_USERSPACE;
+ ndp->ni_dirp = uap->target;
+ ip = namei(ndp); /* well, this routine is doomed anyhow */
if (ip == NULL)
return;
if ((ip->i_mode&IFMT) == IFDIR && !suser()) {
if (ip == NULL)
return;
if ((ip->i_mode&IFMT) == IFDIR && !suser()) {
@@
-250,9
+265,11
@@
link()
ip->i_nlink++;
ip->i_flag |= ICHG;
iupdat(ip, &time, &time, 1);
ip->i_nlink++;
ip->i_flag |= ICHG;
iupdat(ip, &time, &time, 1);
- iunlock(ip);
- u.u_dirp = (caddr_t)uap->linkname;
- xp = namei(uchar, CREATE, 0);
+ IUNLOCK(ip);
+ ndp->ni_nameiop = CREATE;
+ ndp->ni_segflg = UIO_USERSPACE;
+ ndp->ni_dirp = (caddr_t)uap->linkname;
+ xp = namei(ndp);
if (xp != NULL) {
u.u_error = EEXIST;
iput(xp);
if (xp != NULL) {
u.u_error = EEXIST;
iput(xp);
@@
-260,12
+277,12
@@
link()
}
if (u.u_error)
goto out;
}
if (u.u_error)
goto out;
- if (
u.u
_pdir->i_dev != ip->i_dev) {
- iput(
u.u
_pdir);
+ if (
ndp->ni
_pdir->i_dev != ip->i_dev) {
+ iput(
ndp->ni
_pdir);
u.u_error = EXDEV;
goto out;
}
u.u_error = EXDEV;
goto out;
}
- u.u_error = direnter(ip);
+ u.u_error = direnter(ip
, ndp
);
out:
if (u.u_error) {
ip->i_nlink--;
out:
if (u.u_error) {
ip->i_nlink--;
@@
-282,12
+299,12
@@
symlink()
register struct a {
char *target;
char *linkname;
register struct a {
char *target;
char *linkname;
- } *uap;
+ } *uap
= (struct a *)u.u_ap
;
register struct inode *ip;
register char *tp;
register c, nc;
register struct inode *ip;
register char *tp;
register c, nc;
+ register struct nameidata *ndp = &u.u_nd;
- uap = (struct a *)u.u_ap;
tp = uap->target;
nc = 0;
while (c = fubyte(tp)) {
tp = uap->target;
nc = 0;
while (c = fubyte(tp)) {
@@
-298,8
+315,10
@@
symlink()
tp++;
nc++;
}
tp++;
nc++;
}
- u.u_dirp = uap->linkname;
- ip = namei(uchar, CREATE, 0);
+ ndp->ni_nameiop = CREATE;
+ ndp->ni_segflg = UIO_USERSPACE;
+ ndp->ni_dirp = uap->linkname;
+ ip = namei(ndp);
if (ip) {
iput(ip);
u.u_error = EEXIST;
if (ip) {
iput(ip);
u.u_error = EEXIST;
@@
-307,7
+326,7
@@
symlink()
}
if (u.u_error)
return;
}
if (u.u_error)
return;
- ip = maknode(IFLNK | 0777);
+ ip = maknode(IFLNK | 0777
, ndp
);
if (ip == NULL)
return;
u.u_error = rdwri(UIO_WRITE, ip, uap->target, nc, 0, 0, (int *)0);
if (ip == NULL)
return;
u.u_error = rdwri(UIO_WRITE, ip, uap->target, nc, 0, 0, (int *)0);
@@
-324,13
+343,17
@@
unlink()
{
struct a {
char *fname;
{
struct a {
char *fname;
- };
+ }
*uap = (struct a *)u.u_ap
;
register struct inode *ip, *dp;
register struct inode *ip, *dp;
+ register struct nameidata *ndp = &u.u_nd;
- ip = namei(uchar, DELETE | LOCKPARENT, 0);
+ ndp->ni_nameiop = DELETE | LOCKPARENT;
+ ndp->ni_segflg = UIO_USERSPACE;
+ ndp->ni_dirp = uap->fname;
+ ip = namei(ndp);
if (ip == NULL)
return;
if (ip == NULL)
return;
- dp =
u.u
_pdir;
+ dp =
ndp->ni
_pdir;
if ((ip->i_mode&IFMT) == IFDIR && !suser())
goto out;
/*
if ((ip->i_mode&IFMT) == IFDIR && !suser())
goto out;
/*
@@
-342,7
+365,7
@@
unlink()
}
if (ip->i_flag&ITEXT)
xrele(ip); /* try once to free text */
}
if (ip->i_flag&ITEXT)
xrele(ip); /* try once to free text */
- if (dirremove()) {
+ if (dirremove(
ndp
)) {
ip->i_nlink--;
ip->i_flag |= ICHG;
}
ip->i_nlink--;
ip->i_flag |= ICHG;
}
@@
-364,9
+387,8
@@
lseek()
int fd;
off_t off;
int sbase;
int fd;
off_t off;
int sbase;
- } *uap;
+ } *uap
= (struct a *)u.u_ap
;
- uap = (struct a *)u.u_ap;
GETF(fp, uap->fd);
if (fp->f_type != DTYPE_INODE) {
u.u_error = ESPIPE;
GETF(fp, uap->fd);
if (fp->f_type != DTYPE_INODE) {
u.u_error = ESPIPE;
@@
-403,14
+425,17
@@
saccess()
register struct a {
char *fname;
int fmode;
register struct a {
char *fname;
int fmode;
- } *uap;
+ } *uap = (struct a *)u.u_ap;
+ register struct nameidata *ndp = &u.u_nd;
- uap = (struct a *)u.u_ap;
svuid = u.u_uid;
svgid = u.u_gid;
u.u_uid = u.u_ruid;
u.u_gid = u.u_rgid;
svuid = u.u_uid;
svgid = u.u_gid;
u.u_uid = u.u_ruid;
u.u_gid = u.u_rgid;
- ip = namei(uchar, LOOKUP, 1);
+ ndp->ni_nameiop = LOOKUP | FOLLOW;
+ ndp->ni_segflg = UIO_USERSPACE;
+ ndp->ni_dirp = uap->fname;
+ ip = namei(ndp);
if (ip != NULL) {
if ((uap->fmode&R_OK) && access(ip, IREAD))
goto done;
if (ip != NULL) {
if ((uap->fmode&R_OK) && access(ip, IREAD))
goto done;
@@
-431,7
+456,7
@@
done:
stat()
{
stat()
{
- stat1(
1
);
+ stat1(
FOLLOW
);
}
/*
}
/*
@@
-440,7
+465,7
@@
stat()
lstat()
{
lstat()
{
- stat1(
0
);
+ stat1(
NOFOLLOW
);
}
stat1(follow)
}
stat1(follow)
@@
-450,11
+475,14
@@
stat1(follow)
register struct a {
char *fname;
struct stat *ub;
register struct a {
char *fname;
struct stat *ub;
- } *uap;
+ } *uap
= (struct a *)u.u_ap
;
struct stat sb;
struct stat sb;
+ register struct nameidata *ndp = &u.u_nd;
- uap = (struct a *)u.u_ap;
- ip = namei(uchar, LOOKUP, follow);
+ ndp->ni_nameiop = LOOKUP | follow;
+ ndp->ni_segflg = UIO_USERSPACE;
+ ndp->ni_dirp = uap->fname;
+ ip = namei(ndp);
if (ip == NULL)
return;
(void) ino_stat(ip, &sb);
if (ip == NULL)
return;
(void) ino_stat(ip, &sb);
@@
-473,9
+501,13
@@
readlink()
char *buf;
int count;
} *uap = (struct a *)u.u_ap;
char *buf;
int count;
} *uap = (struct a *)u.u_ap;
+ register struct nameidata *ndp = &u.u_nd;
int resid;
int resid;
- ip = namei(uchar, LOOKUP, 0);
+ ndp->ni_nameiop = LOOKUP;
+ ndp->ni_segflg = UIO_USERSPACE;
+ ndp->ni_dirp = uap->name;
+ ip = namei(ndp);
if (ip == NULL)
return;
if ((ip->i_mode&IFMT) != IFLNK) {
if (ip == NULL)
return;
if ((ip->i_mode&IFMT) != IFLNK) {
@@
-497,10
+529,9
@@
chmod()
struct a {
char *fname;
int fmode;
struct a {
char *fname;
int fmode;
- } *uap;
+ } *uap
= (struct a *)u.u_ap
;
- uap = (struct a *)u.u_ap;
- if ((ip = owner(1)) == NULL)
+ if ((ip = owner(uap->fname, FOLLOW)) == NULL)
return;
chmod1(ip, uap->fmode);
iput(ip);
return;
chmod1(ip, uap->fmode);
iput(ip);
@@
-514,20
+545,19
@@
fchmod()
struct a {
int fd;
int fmode;
struct a {
int fd;
int fmode;
- } *uap;
+ } *uap
= (struct a *)u.u_ap
;
register struct inode *ip;
register struct file *fp;
register struct inode *ip;
register struct file *fp;
- uap = (struct a *)u.u_ap;
fp = getinode(uap->fd);
if (fp == NULL)
return;
ip = (struct inode *)fp->f_data;
if (u.u_uid != ip->i_uid && !suser())
return;
fp = getinode(uap->fd);
if (fp == NULL)
return;
ip = (struct inode *)fp->f_data;
if (u.u_uid != ip->i_uid && !suser())
return;
-
ilock
(ip);
+
ILOCK
(ip);
chmod1(ip, uap->fmode);
chmod1(ip, uap->fmode);
-
iunlock
(ip);
+
IUNLOCK
(ip);
}
/*
}
/*
@@
-561,10
+591,9
@@
chown()
char *fname;
int uid;
int gid;
char *fname;
int uid;
int gid;
- } *uap;
+ } *uap
= (struct a *)u.u_ap
;
- uap = (struct a *)u.u_ap;
- if (!suser() || (ip = owner(0)) == NULL)
+ if (!suser() || (ip = owner(uap->fname, NOFOLLOW)) == NULL)
return;
u.u_error = chown1(ip, uap->uid, uap->gid);
iput(ip);
return;
u.u_error = chown1(ip, uap->uid, uap->gid);
iput(ip);
@@
-579,20
+608,19
@@
fchown()
int fd;
int uid;
int gid;
int fd;
int uid;
int gid;
- } *uap;
+ } *uap
= (struct a *)u.u_ap
;
register struct inode *ip;
register struct file *fp;
register struct inode *ip;
register struct file *fp;
- uap = (struct a *)u.u_ap;
fp = getinode(uap->fd);
if (fp == NULL)
return;
ip = (struct inode *)fp->f_data;
if (!suser())
return;
fp = getinode(uap->fd);
if (fp == NULL)
return;
ip = (struct inode *)fp->f_data;
if (!suser())
return;
-
ilock
(ip);
+
ILOCK
(ip);
u.u_error = chown1(ip, uap->uid, uap->gid);
u.u_error = chown1(ip, uap->uid, uap->gid);
-
iunlock
(ip);
+
IUNLOCK
(ip);
}
/*
}
/*
@@
-644,7
+672,7
@@
utimes()
register struct inode *ip;
struct timeval tv[2];
register struct inode *ip;
struct timeval tv[2];
- if ((ip = owner(
1
)) == NULL)
+ if ((ip = owner(
uap->fname, FOLLOW
)) == NULL)
return;
u.u_error = copyin((caddr_t)uap->tptr, (caddr_t)tv, sizeof (tv));
if (u.u_error == 0) {
return;
u.u_error = copyin((caddr_t)uap->tptr, (caddr_t)tv, sizeof (tv));
if (u.u_error == 0) {
@@
-673,8
+701,12
@@
truncate()
u_long length;
} *uap = (struct a *)u.u_ap;
struct inode *ip;
u_long length;
} *uap = (struct a *)u.u_ap;
struct inode *ip;
+ register struct nameidata *ndp = &u.u_nd;
- ip = namei(uchar, LOOKUP, 1);
+ ndp->ni_nameiop = LOOKUP | FOLLOW;
+ ndp->ni_segflg = UIO_USERSPACE;
+ ndp->ni_dirp = uap->fname;
+ ip = namei(ndp);
if (ip == NULL)
return;
if (access(ip, IWRITE))
if (ip == NULL)
return;
if (access(ip, IWRITE))
@@
-708,9
+740,9
@@
ftruncate()
return;
}
ip = (struct inode *)fp->f_data;
return;
}
ip = (struct inode *)fp->f_data;
-
ilock
(ip);
+
ILOCK
(ip);
itrunc(ip, uap->length);
itrunc(ip, uap->length);
-
iunlock
(ip);
+
IUNLOCK
(ip);
}
/*
}
/*
@@
-728,9
+760,9
@@
fsync()
if (fp == NULL)
return;
ip = (struct inode *)fp->f_data;
if (fp == NULL)
return;
ip = (struct inode *)fp->f_data;
-
ilock
(ip);
+
ILOCK
(ip);
syncip(ip);
syncip(ip);
-
iunlock
(ip);
+
IUNLOCK
(ip);
}
/*
}
/*
@@
-764,21
+796,25
@@
rename()
struct a {
char *from;
char *to;
struct a {
char *from;
char *to;
- } *uap;
+ } *uap
= (struct a *)u.u_ap
;
register struct inode *ip, *xp, *dp;
register struct inode *ip, *xp, *dp;
+ struct inode *zp;
int oldparent, parentdifferent, doingdirectory;
int oldparent, parentdifferent, doingdirectory;
+ register struct nameidata *ndp = &u.u_nd;
int error = 0;
int error = 0;
- uap = (struct a *)u.u_ap;
- ip = namei(uchar, DELETE | LOCKPARENT, 0);
+ ndp->ni_nameiop = DELETE | LOCKPARENT;
+ ndp->ni_segflg = UIO_USERSPACE;
+ ndp->ni_dirp = uap->from;
+ ip = namei(ndp);
if (ip == NULL)
return;
if (ip == NULL)
return;
- dp =
u.u
_pdir;
+ dp =
ndp->ni
_pdir;
oldparent = 0, doingdirectory = 0;
if ((ip->i_mode&IFMT) == IFDIR) {
register struct direct *d;
oldparent = 0, doingdirectory = 0;
if ((ip->i_mode&IFMT) == IFDIR) {
register struct direct *d;
- d = &
u.u
_dent;
+ d = &
ndp->ni
_dent;
/*
* Avoid ".", "..", and aliases of "." for obvious reasons.
*/
/*
* Avoid ".", "..", and aliases of "." for obvious reasons.
*/
@@
-807,19
+843,20
@@
rename()
ip->i_nlink++;
ip->i_flag |= ICHG;
iupdat(ip, &time, &time, 1);
ip->i_nlink++;
ip->i_flag |= ICHG;
iupdat(ip, &time, &time, 1);
-
iunlock
(ip);
+
IUNLOCK
(ip);
/*
* When the target exists, both the directory
* and target inodes are returned locked.
*/
/*
* When the target exists, both the directory
* and target inodes are returned locked.
*/
- u.u_dirp = (caddr_t)uap->to;
- xp = namei(uchar, CREATE | LOCKPARENT | NOCACHE, 0);
+ ndp->ni_nameiop = CREATE | LOCKPARENT | NOCACHE;
+ ndp->ni_dirp = (caddr_t)uap->to;
+ xp = namei(ndp);
if (u.u_error) {
error = u.u_error;
goto out;
}
if (u.u_error) {
error = u.u_error;
goto out;
}
- dp =
u.u
_pdir;
+ dp =
ndp->ni
_pdir;
/*
* If ".." must be changed (ie the directory gets a new
* parent) then the source directory must not be in the
/*
* If ".." must be changed (ie the directory gets a new
* parent) then the source directory must not be in the
@@
-835,19
+872,18
@@
rename()
if (access(ip, IWRITE))
goto bad;
do {
if (access(ip, IWRITE))
goto bad;
do {
- dp =
u.u
_pdir;
+ dp =
ndp->ni
_pdir;
if (xp != NULL)
iput(xp);
u.u_error = checkpath(ip, dp);
if (u.u_error)
goto out;
if (xp != NULL)
iput(xp);
u.u_error = checkpath(ip, dp);
if (u.u_error)
goto out;
- u.u_dirp = (caddr_t)uap->to;
- xp = namei(uchar, CREATE | LOCKPARENT | NOCACHE, 0);
+ xp = namei(ndp);
if (u.u_error) {
error = u.u_error;
goto out;
}
if (u.u_error) {
error = u.u_error;
goto out;
}
- } while (dp !=
u.u
_pdir);
+ } while (dp !=
ndp->ni
_pdir);
}
/*
* 2) If target doesn't exist, link the target
}
/*
* 2) If target doesn't exist, link the target
@@
-873,7
+909,7
@@
rename()
dp->i_flag |= ICHG;
iupdat(dp, &time, &time, 1);
}
dp->i_flag |= ICHG;
iupdat(dp, &time, &time, 1);
}
- error = direnter(ip);
+ error = direnter(ip
, ndp
);
if (error)
goto out;
} else {
if (error)
goto out;
} else {
@@
-906,7
+942,7
@@
rename()
error = EISDIR;
goto bad;
}
error = EISDIR;
goto bad;
}
- dirrewrite(dp, ip);
+ dirrewrite(dp, ip
, ndp
);
if (u.u_error) {
error = u.u_error;
goto bad1;
if (u.u_error) {
error = u.u_error;
goto bad1;
@@
-936,19
+972,18
@@
rename()
/*
* 3) Unlink the source.
*/
/*
* 3) Unlink the source.
*/
- u.u_dirp = uap->from;
- dp = namei(uchar, DELETE, 0);
+ ndp->ni_nameiop = DELETE | LOCKPARENT;
+ ndp->ni_segflg = UIO_USERSPACE;
+ ndp->ni_dirp = uap->from;
+ zp = namei(ndp);
+ dp = ndp->ni_pdir;
/*
* Insure directory entry still exists and
* has not changed since the start of all
* this. If either has occured, forget about
/*
* Insure directory entry still exists and
* has not changed since the start of all
* this. If either has occured, forget about
- * about deleting the original entry and just
- * adjust the link count in the inode.
+ * about deleting the original entry.
*/
*/
- if (dp == NULL || u.u_dent.d_ino != ip->i_number) {
- ip->i_nlink--;
- ip->i_flag |= ICHG;
- } else {
+ if (dp != NULL && zp == ip) {
/*
* If source is a directory, must adjust
* link count of parent directory also.
/*
* If source is a directory, must adjust
* link count of parent directory also.
@@
-963,13
+998,15
@@
rename()
dp->i_nlink--;
dp->i_flag |= ICHG;
}
dp->i_nlink--;
dp->i_flag |= ICHG;
}
- if (dirremove()) {
-
i
p->i_nlink--;
-
i
p->i_flag |= ICHG;
+ if (dirremove(
ndp
)) {
+
z
p->i_nlink--;
+
z
p->i_flag |= ICHG;
}
if (error == 0) /* conservative */
error = u.u_error;
}
}
if (error == 0) /* conservative */
error = u.u_error;
}
+ if (zp != NULL)
+ iput(zp);
irele(ip);
if (dp)
iput(dp);
irele(ip);
if (dp)
iput(dp);
@@
-985,13
+1022,15
@@
rename()
if (doingdirectory && parentdifferent && error == 0) {
struct dirtemplate dirbuf;
if (doingdirectory && parentdifferent && error == 0) {
struct dirtemplate dirbuf;
- u.u_dirp = uap->to;
- ip = namei(uchar, LOOKUP | LOCKPARENT, 0);
+ ndp->ni_nameiop = LOOKUP | LOCKPARENT;
+ ndp->ni_segflg = UIO_USERSPACE;
+ ndp->ni_dirp = uap->to;
+ ip = namei(ndp);
if (ip == NULL) {
printf("rename: .. went away\n");
return;
}
if (ip == NULL) {
printf("rename: .. went away\n");
return;
}
- dp =
u.u
_pdir;
+ dp =
ndp->ni
_pdir;
if ((ip->i_mode&IFMT) != IFDIR) {
printf("rename: .. not a directory\n");
goto stuck;
if ((ip->i_mode&IFMT) != IFDIR) {
printf("rename: .. not a directory\n");
goto stuck;
@@
-1000,7
+1039,7
@@
rename()
sizeof (struct dirtemplate), (off_t)0, 1, (int *)0);
if (error == 0) {
dirbuf.dotdot_ino = dp->i_number;
sizeof (struct dirtemplate), (off_t)0, 1, (int *)0);
if (error == 0) {
dirbuf.dotdot_ino = dp->i_number;
-
dp->i_id = ++nextinodeid
;
+
cacheinval(dp)
;
(void) rdwri(UIO_WRITE, ip, (caddr_t)&dirbuf,
sizeof (struct dirtemplate), (off_t)0, 1, (int *)0);
}
(void) rdwri(UIO_WRITE, ip, (caddr_t)&dirbuf,
sizeof (struct dirtemplate), (off_t)0, 1, (int *)0);
}
@@
-1028,19
+1067,21
@@
done:
* Make a new file.
*/
struct inode *
* Make a new file.
*/
struct inode *
-maknode(mode)
+maknode(mode
, ndp
)
int mode;
int mode;
+ register struct nameidata *ndp;
{
register struct inode *ip;
{
register struct inode *ip;
+ register struct inode *pdir = ndp->ni_pdir;
ino_t ipref;
if ((mode & IFMT) == IFDIR)
ino_t ipref;
if ((mode & IFMT) == IFDIR)
- ipref = dirpref(
u.u_
pdir->i_fs);
+ ipref = dirpref(pdir->i_fs);
else
else
- ipref =
u.u_
pdir->i_number;
- ip = ialloc(
u.u_
pdir, ipref, mode);
+ ipref = pdir->i_number;
+ ip = ialloc(pdir, ipref, mode);
if (ip == NULL) {
if (ip == NULL) {
- iput(
u.u_
pdir);
+ iput(pdir);
return (NULL);
}
#ifdef QUOTA
return (NULL);
}
#ifdef QUOTA
@@
-1053,7
+1094,7
@@
maknode(mode)
ip->i_mode = mode & ~u.u_cmask;
ip->i_nlink = 1;
ip->i_uid = u.u_uid;
ip->i_mode = mode & ~u.u_cmask;
ip->i_nlink = 1;
ip->i_uid = u.u_uid;
- ip->i_gid =
u.u_
pdir->i_gid;
+ ip->i_gid = pdir->i_gid;
if (ip->i_mode & ISGID && !groupmember(ip->i_gid))
ip->i_mode &= ~ISGID;
#ifdef QUOTA
if (ip->i_mode & ISGID && !groupmember(ip->i_gid))
ip->i_mode &= ~ISGID;
#ifdef QUOTA
@@
-1064,7
+1105,7
@@
maknode(mode)
* Make sure inode goes to disk before directory entry.
*/
iupdat(ip, &time, &time, 1);
* Make sure inode goes to disk before directory entry.
*/
iupdat(ip, &time, &time, 1);
- u.u_error = direnter(ip);
+ u.u_error = direnter(ip
, ndp
);
if (u.u_error) {
/*
* Write error occurred trying to update directory
if (u.u_error) {
/*
* Write error occurred trying to update directory
@@
-1094,12
+1135,15
@@
mkdir()
struct a {
char *name;
int dmode;
struct a {
char *name;
int dmode;
- } *uap;
+ } *uap
= (struct a *)u.u_ap
;
register struct inode *ip, *dp;
struct dirtemplate dirtemplate;
register struct inode *ip, *dp;
struct dirtemplate dirtemplate;
+ register struct nameidata *ndp = &u.u_nd;
- uap = (struct a *)u.u_ap;
- ip = namei(uchar, CREATE, 0);
+ ndp->ni_nameiop = CREATE;
+ ndp->ni_segflg = UIO_USERSPACE;
+ ndp->ni_dirp = uap->name;
+ ip = namei(ndp);
if (u.u_error)
return;
if (ip != NULL) {
if (u.u_error)
return;
if (ip != NULL) {
@@
-1107,7
+1151,7
@@
mkdir()
u.u_error = EEXIST;
return;
}
u.u_error = EEXIST;
return;
}
- dp =
u.u
_pdir;
+ dp =
ndp->ni
_pdir;
uap->dmode &= 0777;
uap->dmode |= IFDIR;
/*
uap->dmode &= 0777;
uap->dmode |= IFDIR;
/*
@@
-1165,11
+1209,13
@@
mkdir()
* install the entry for it in
* the parent directory.
*/
* install the entry for it in
* the parent directory.
*/
- u.u_error = direnter(ip);
+ u.u_error = direnter(ip
, ndp
);
dp = NULL;
if (u.u_error) {
dp = NULL;
if (u.u_error) {
- u.u_dirp = uap->name;
- dp = namei(uchar, LOOKUP | NOCACHE, 0);
+ ndp->ni_nameiop = LOOKUP | NOCACHE;
+ ndp->ni_segflg = UIO_USERSPACE;
+ ndp->ni_dirp = uap->name;
+ dp = namei(ndp);
if (dp) {
dp->i_nlink--;
dp->i_flag |= ICHG;
if (dp) {
dp->i_nlink--;
dp->i_flag |= ICHG;
@@
-1197,13
+1243,17
@@
rmdir()
{
struct a {
char *name;
{
struct a {
char *name;
- };
+ }
*uap = (struct a *)u.u_ap
;
register struct inode *ip, *dp;
register struct inode *ip, *dp;
+ register struct nameidata *ndp = &u.u_nd;
- ip = namei(uchar, DELETE | LOCKPARENT, 0);
+ ndp->ni_nameiop = DELETE | LOCKPARENT;
+ ndp->ni_segflg = UIO_USERSPACE;
+ ndp->ni_dirp = uap->name;
+ ip = namei(ndp);
if (ip == NULL)
return;
if (ip == NULL)
return;
- dp =
u.u
_pdir;
+ dp =
ndp->ni
_pdir;
/*
* No rmdir "." please.
*/
/*
* No rmdir "." please.
*/
@@
-1240,7
+1290,7
@@
rmdir()
* inode. If we crash in between, the directory
* will be reattached to lost+found,
*/
* inode. If we crash in between, the directory
* will be reattached to lost+found,
*/
- if (dirremove() == 0)
+ if (dirremove(
ndp
) == 0)
goto out;
dp->i_nlink--;
dp->i_flag |= ICHG;
goto out;
dp->i_nlink--;
dp->i_flag |= ICHG;
@@
-1259,6
+1309,7
@@
rmdir()
*/
ip->i_nlink -= 2;
itrunc(ip, (u_long)0);
*/
ip->i_nlink -= 2;
itrunc(ip, (u_long)0);
+ cacheinval(ip);
out:
if (dp)
iput(dp);
out:
if (dp)
iput(dp);
@@
-1289,9
+1340,8
@@
umask()
{
register struct a {
int mask;
{
register struct a {
int mask;
- } *uap;
+ } *uap
= (struct a *)u.u_ap
;
- uap = (struct a *)u.u_ap;
u.u_r.r_val1 = u.u_cmask;
u.u_cmask = uap->mask & 07777;
}
u.u_r.r_val1 = u.u_cmask;
u.u_cmask = uap->mask & 07777;
}