Add fdidx argument to vn_open() and vn_open_cred() and pass -1 throughout.

This commit is contained in:
Poul-Henning Kamp 2003-07-27 17:04:56 +00:00
parent 1b6c609507
commit 7c89f162bc
Notes: svn2git 2020-12-20 02:59:44 +00:00
svn path=/head/; revision=118094
17 changed files with 24 additions and 23 deletions

View File

@ -840,13 +840,13 @@ mdcreate_vnode(struct md_ioctl *mdio, struct thread *td)
flags = FREAD|FWRITE;
NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, mdio->md_file, td);
error = vn_open(&nd, &flags, 0);
error = vn_open(&nd, &flags, 0, -1);
if (error) {
if (error != EACCES && error != EPERM && error != EROFS)
return (error);
flags &= ~FWRITE;
NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, mdio->md_file, td);
error = vn_open(&nd, &flags, 0);
error = vn_open(&nd, &flags, 0, -1);
if (error)
return (error);
}

View File

@ -1727,7 +1727,7 @@ raidlookup(path, td, vpp)
NDINIT(nd, LOOKUP, FOLLOW, UIO_SYSSPACE, path, curthread);
flags = FREAD | FWRITE;
if ((error = vn_open(nd, &flags, 0)) != 0) {
if ((error = vn_open(nd, &flags, 0, -1)) != 0) {
rf_printf(2, "RAIDframe: vn_open returned %d\n", error);
goto end1;
}

View File

@ -144,7 +144,7 @@ acct(td, uap)
if (uap->path != NULL) {
NDINIT(&nd, LOOKUP, NOFOLLOW, UIO_USERSPACE, uap->path, td);
flags = FWRITE | O_APPEND;
error = vn_open(&nd, &flags, 0);
error = vn_open(&nd, &flags, 0, -1);
if (error)
goto done2;
NDFREE(&nd, NDF_ONLY_PNBUF);

View File

@ -345,7 +345,7 @@ alq_open(struct alq **alqp, const char *file, struct ucred *cred, int size,
NDINIT(&nd, LOOKUP, NOFOLLOW, UIO_SYSSPACE, file, td);
flags = FWRITE | O_NOFOLLOW | O_CREAT;
error = vn_open_cred(&nd, &flags, 0, cred);
error = vn_open_cred(&nd, &flags, 0, cred, -1);
if (error)
return (error);

View File

@ -1701,7 +1701,7 @@ fdcheckstd(td)
NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, "/dev/null",
td);
flags = FREAD | FWRITE;
error = vn_open(&nd, &flags, 0);
error = vn_open(&nd, &flags, 0, -1);
if (error != 0) {
FILEDESC_LOCK(fdp);
fdp->fd_ofiles[fd] = NULL;

View File

@ -524,7 +524,7 @@ ktrace(td, uap)
NDINIT(&nd, LOOKUP, NOFOLLOW, UIO_USERSPACE, uap->fname, td);
flags = FREAD | FWRITE | O_NOFOLLOW;
mtx_lock(&Giant);
error = vn_open(&nd, &flags, 0);
error = vn_open(&nd, &flags, 0, -1);
if (error) {
mtx_unlock(&Giant);
td->td_pflags &= ~TDP_INKTRACE;

View File

@ -1392,7 +1392,7 @@ linker_lookup_file(const char *path, int pathlen, const char *name,
*/
NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, result, td);
flags = FREAD;
error = vn_open(&nd, &flags, 0);
error = vn_open(&nd, &flags, 0, -1);
if (error == 0) {
NDFREE(&nd, NDF_ONLY_PNBUF);
type = nd.ni_vp->v_type;
@ -1440,7 +1440,7 @@ linker_hints_lookup(const char *path, int pathlen, const char *modname,
NDINIT(&nd, LOOKUP, NOFOLLOW, UIO_SYSSPACE, pathbuf, td);
flags = FREAD;
error = vn_open(&nd, &flags, 0);
error = vn_open(&nd, &flags, 0, -1);
if (error)
goto bad;
NDFREE(&nd, NDF_ONLY_PNBUF);

View File

@ -2545,7 +2545,7 @@ coredump(struct thread *td)
return (EINVAL);
NDINIT(&nd, LOOKUP, NOFOLLOW, UIO_SYSSPACE, name, td); /* XXXKSE */
flags = O_CREAT | FWRITE | O_NOFOLLOW;
error = vn_open(&nd, &flags, S_IRUSR | S_IWUSR);
error = vn_open(&nd, &flags, S_IRUSR | S_IWUSR, -1);
free(name, M_TEMP);
if (error)
return (error);

View File

@ -561,7 +561,7 @@ link_elf_load_file(linker_class_t cls, const char* filename,
NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, filename, td);
flags = FREAD;
error = vn_open(&nd, &flags, 0);
error = vn_open(&nd, &flags, 0, -1);
if (error)
return error;
NDFREE(&nd, NDF_ONLY_PNBUF);

View File

@ -561,7 +561,7 @@ link_elf_load_file(linker_class_t cls, const char* filename,
NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, filename, td);
flags = FREAD;
error = vn_open(&nd, &flags, 0);
error = vn_open(&nd, &flags, 0, -1);
if (error)
return error;
NDFREE(&nd, NDF_ONLY_PNBUF);

View File

@ -376,7 +376,7 @@ cn_devopen(struct cn_device *cnd, struct thread *td, int forceopen)
}
snprintf(path, sizeof(path), "/dev/%s", cnd->cnd_name);
NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, path, td);
error = vn_open(&nd, &openflag, 0);
error = vn_open(&nd, &openflag, 0, -1);
if (error == 0) {
NDFREE(&nd, NDF_ONLY_PNBUF);
VOP_UNLOCK(nd.ni_vp, 0, td);

View File

@ -685,7 +685,7 @@ kern_open(struct thread *td, char *path, enum uio_seg pathseg, int flags,
* the descriptor while we are blocked in vn_open()
*/
fhold(fp);
error = vn_open(&nd, &flags, cmode);
error = vn_open(&nd, &flags, cmode, -1);
if (error) {
/*
* release our own reference

View File

@ -685,7 +685,7 @@ kern_open(struct thread *td, char *path, enum uio_seg pathseg, int flags,
* the descriptor while we are blocked in vn_open()
*/
fhold(fp);
error = vn_open(&nd, &flags, cmode);
error = vn_open(&nd, &flags, cmode, -1);
if (error) {
/*
* release our own reference

View File

@ -84,13 +84,13 @@ struct fileops vnops = {
};
int
vn_open(ndp, flagp, cmode)
vn_open(ndp, flagp, cmode, fdidx)
register struct nameidata *ndp;
int *flagp, cmode;
int *flagp, cmode, fdidx;
{
struct thread *td = ndp->ni_cnd.cn_thread;
return (vn_open_cred(ndp, flagp, cmode, td->td_ucred));
return (vn_open_cred(ndp, flagp, cmode, td->td_ucred, fdidx));
}
/*
@ -101,10 +101,11 @@ vn_open(ndp, flagp, cmode)
* due to the NDINIT being done elsewhere.
*/
int
vn_open_cred(ndp, flagp, cmode, cred)
vn_open_cred(ndp, flagp, cmode, cred, fdidx)
register struct nameidata *ndp;
int *flagp, cmode;
struct ucred *cred;
int fdidx;
{
struct vnode *vp;
struct mount *mp;

View File

@ -144,7 +144,7 @@ nfs_dolock(struct vop_advlock_args *ap)
NDINIT(&nd, LOOKUP, FOLLOW, UIO_SYSSPACE, _PATH_LCKFIFO, td);
fmode = FFLAGS(O_WRONLY | O_NONBLOCK);
error = vn_open_cred(&nd, &fmode, 0, thread0.td_ucred);
error = vn_open_cred(&nd, &fmode, 0, thread0.td_ucred, -1);
switch (error) {
case ENOENT:
case ENXIO:

View File

@ -645,9 +645,9 @@ int debug_vn_lock(struct vnode *vp, int flags, struct thread *p,
const char *filename, int line);
#define vn_lock(vp,flags,p) debug_vn_lock(vp,flags,p,__FILE__,__LINE__)
#endif
int vn_open(struct nameidata *ndp, int *flagp, int cmode);
int vn_open(struct nameidata *ndp, int *flagp, int cmode, int fdidx);
int vn_open_cred(struct nameidata *ndp, int *flagp, int cmode,
struct ucred *cred);
struct ucred *cred, int fdidx);
void vn_pollevent(struct vnode *vp, int events);
void vn_pollgone(struct vnode *vp);
int vn_pollrecord(struct vnode *vp, struct thread *p, int events);

View File

@ -419,7 +419,7 @@ quotaon(td, mp, type, fname)
vpp = &ump->um_quotas[type];
NDINIT(&nd, LOOKUP, FOLLOW, UIO_USERSPACE, fname, td);
flags = FREAD | FWRITE;
error = vn_open(&nd, &flags, 0);
error = vn_open(&nd, &flags, 0, -1);
if (error)
return (error);
NDFREE(&nd, NDF_ONLY_PNBUF);