VFS: use S_IS* macros

This commit is contained in:
Thomas Veerman 2012-04-25 12:44:42 +00:00
parent 96bbc5da3e
commit db8198d99d
13 changed files with 52 additions and 70 deletions

View File

@ -668,8 +668,7 @@ int do_ioctl()
if ((f = get_filp(scratch(fp).file.fd_nr, VNODE_READ)) == NULL) if ((f = get_filp(scratch(fp).file.fd_nr, VNODE_READ)) == NULL)
return(err_code); return(err_code);
vp = f->filp_vno; /* get vnode pointer */ vp = f->filp_vno; /* get vnode pointer */
if ((vp->v_mode & I_TYPE) != I_CHAR_SPECIAL && if (!S_ISCHR(vp->v_mode) && !S_ISBLK(vp->v_mode)) {
(vp->v_mode & I_TYPE) != I_BLOCK_SPECIAL) {
r = ENOTTY; r = ENOTTY;
} }
@ -677,7 +676,7 @@ int do_ioctl()
suspend_reopen = (f->filp_state != FS_NORMAL); suspend_reopen = (f->filp_state != FS_NORMAL);
dev = (dev_t) vp->v_sdev; dev = (dev_t) vp->v_sdev;
if ((vp->v_mode & I_TYPE) == I_BLOCK_SPECIAL) if (S_ISBLK(vp->v_mode))
r = bdev_ioctl(dev, who_e, ioctlrequest, argx); r = bdev_ioctl(dev, who_e, ioctlrequest, argx);
else else
r = dev_io(VFS_DEV_IOCTL, dev, who_e, argx, cvu64(0), r = dev_io(VFS_DEV_IOCTL, dev, who_e, argx, cvu64(0),
@ -1013,7 +1012,7 @@ void cdev_up(int maj)
rfilp = rfp->fp_filp[fd_nr]; rfilp = rfp->fp_filp[fd_nr];
vp = rfilp->filp_vno; vp = rfilp->filp_vno;
if (!vp) panic("VFS: cdev_up: no vp"); if (!vp) panic("VFS: cdev_up: no vp");
if ((vp->v_mode & I_TYPE) != I_CHAR_SPECIAL) continue; if (!S_ISCHR(vp->v_mode)) continue;
if (major(vp->v_sdev) != maj) continue; if (major(vp->v_sdev) != maj) continue;
rfp->fp_flags |= FP_SUSP_REOPEN; rfp->fp_flags |= FP_SUSP_REOPEN;
@ -1066,7 +1065,7 @@ int maj;
for (rfilp = filp; rfilp < &filp[NR_FILPS]; rfilp++) { for (rfilp = filp; rfilp < &filp[NR_FILPS]; rfilp++) {
if (rfilp->filp_count < 1 || !(vp = rfilp->filp_vno)) continue; if (rfilp->filp_count < 1 || !(vp = rfilp->filp_vno)) continue;
if (rfilp->filp_state != FS_NEEDS_REOPEN) continue; if (rfilp->filp_state != FS_NEEDS_REOPEN) continue;
if ((vp->v_mode & I_TYPE) != I_CHAR_SPECIAL) continue; if (!S_ISCHR(vp->v_mode)) continue;
major_dev = major(vp->v_sdev); major_dev = major(vp->v_sdev);
minor_dev = minor(vp->v_sdev); minor_dev = minor(vp->v_sdev);
@ -1131,7 +1130,7 @@ int maj;
vp = rfilp->filp_vno; vp = rfilp->filp_vno;
if (!vp) panic("VFS: restart_reopen: no vp"); if (!vp) panic("VFS: restart_reopen: no vp");
if ((vp->v_mode & I_TYPE) != I_CHAR_SPECIAL) continue; if (!S_ISCHR(vp->v_mode)) continue;
if (major(vp->v_sdev) != maj) continue; if (major(vp->v_sdev) != maj) continue;
rfp->fp_blocked_on = FP_BLOCKED_ON_NONE; rfp->fp_blocked_on = FP_BLOCKED_ON_NONE;
@ -1181,7 +1180,7 @@ void reopen_reply()
return; return;
} }
if ((vp->v_mode & I_TYPE) != I_CHAR_SPECIAL) { if (!S_ISCHR(vp->v_mode)) {
printf("VFS: reopen_reply: bad mode 0%o for filp number %d" printf("VFS: reopen_reply: bad mode 0%o for filp number %d"
" (from driver %d)\n", vp->v_mode, filp_no, driver_e); " (from driver %d)\n", vp->v_mode, filp_no, driver_e);
return; return;

View File

@ -149,7 +149,7 @@ static int get_read_vp(struct exec_info *execi, char *fullpath,
unlock_vmnt(execi->vmp); unlock_vmnt(execi->vmp);
if ((execi->vp->v_mode & I_TYPE) != I_REGULAR) if (!S_ISREG(execi->vp->v_mode))
return ENOEXEC; return ENOEXEC;
else if ((r = forbidden(fp, execi->vp, X_BIT)) != OK) else if ((r = forbidden(fp, execi->vp, X_BIT)) != OK)
return r; return r;

View File

@ -531,7 +531,7 @@ struct filp *f;
{ {
/* Close a file. Will also unlock filp when done */ /* Close a file. Will also unlock filp when done */
int mode_word, rw; int rw;
dev_t dev; dev_t dev;
struct vnode *vp; struct vnode *vp;
@ -543,10 +543,9 @@ struct filp *f;
if (f->filp_count - 1 == 0 && f->filp_mode != FILP_CLOSED) { if (f->filp_count - 1 == 0 && f->filp_mode != FILP_CLOSED) {
/* Check to see if the file is special. */ /* Check to see if the file is special. */
mode_word = vp->v_mode & I_TYPE; if (S_ISCHR(vp->v_mode) || S_ISBLK(vp->v_mode)) {
if (mode_word == I_CHAR_SPECIAL || mode_word == I_BLOCK_SPECIAL) {
dev = (dev_t) vp->v_sdev; dev = (dev_t) vp->v_sdev;
if (mode_word == I_BLOCK_SPECIAL) { if (S_ISBLK(vp->v_mode)) {
lock_bsf(); lock_bsf();
if (vp->v_bfs_e == ROOT_FS_E) { if (vp->v_bfs_e == ROOT_FS_E) {
/* Invalidate the cache unless the special is /* Invalidate the cache unless the special is
@ -556,15 +555,11 @@ struct filp *f;
req_flush(vp->v_bfs_e, dev); req_flush(vp->v_bfs_e, dev);
} }
unlock_bsf(); unlock_bsf();
}
/* Do any special processing on device close. (void) bdev_close(dev); /* Ignore errors on close */
* Ignore any errors, even SUSPEND. } else {
*/ (void) dev_close(dev, f-filp); /* Ignore errors */
if (mode_word == I_BLOCK_SPECIAL) }
(void) bdev_close(dev);
else
(void) dev_close(dev, f-filp);
f->filp_mode = FILP_CLOSED; f->filp_mode = FILP_CLOSED;
} }

View File

@ -123,7 +123,7 @@ int do_unlink()
assert(vmp != NULL); /* We must have locked the vmnt */ assert(vmp != NULL); /* We must have locked the vmnt */
/* Make sure that the object is a directory */ /* Make sure that the object is a directory */
if ((dirp->v_mode & I_TYPE) != I_DIRECTORY) { if (!S_ISDIR(dirp->v_mode)) {
unlock_vnode(dirp); unlock_vnode(dirp);
unlock_vmnt(vmp); unlock_vmnt(vmp);
put_vnode(dirp); put_vnode(dirp);
@ -455,7 +455,7 @@ struct fproc *rfp;
if ((vp = eat_path(&resolve, rfp)) == NULL) return(err_code); if ((vp = eat_path(&resolve, rfp)) == NULL) return(err_code);
/* Make sure this is a symbolic link */ /* Make sure this is a symbolic link */
if ((vp->v_mode & I_TYPE) != I_SYMBOLIC_LINK) if (!S_ISLNK(vp->v_mode))
r = EINVAL; r = EINVAL;
else else
r = req_rdlink(vp->v_fs_e, vp->v_inode_nr, NONE, (vir_bytes) link_path, r = req_rdlink(vp->v_fs_e, vp->v_inode_nr, NONE, (vir_bytes) link_path,
@ -500,7 +500,7 @@ int do_rdlink()
if ((vp = eat_path(&resolve, fp)) == NULL) return(err_code); if ((vp = eat_path(&resolve, fp)) == NULL) return(err_code);
/* Make sure this is a symbolic link */ /* Make sure this is a symbolic link */
if ((vp->v_mode & I_TYPE) != I_SYMBOLIC_LINK) if (!S_ISLNK(vp->v_mode))
r = EINVAL; r = EINVAL;
else else
r = req_rdlink(vp->v_fs_e, vp->v_inode_nr, who_e, buf, buf_size, 0); r = req_rdlink(vp->v_fs_e, vp->v_inode_nr, who_e, buf, buf_size, 0);

View File

@ -42,8 +42,8 @@ int req; /* either F_SETLK or F_SETLKW */
mo = f->filp_mode; mo = f->filp_mode;
if (ltype != F_UNLCK && ltype != F_RDLCK && ltype != F_WRLCK) return(EINVAL); if (ltype != F_UNLCK && ltype != F_RDLCK && ltype != F_WRLCK) return(EINVAL);
if (req == F_GETLK && ltype == F_UNLCK) return(EINVAL); if (req == F_GETLK && ltype == F_UNLCK) return(EINVAL);
if ( (f->filp_vno->v_mode & I_TYPE) != I_REGULAR && if (!S_ISREG(f->filp_vno->v_mode) && !S_ISBLK(f->filp_vno->v_mode))
(f->filp_vno->v_mode & I_TYPE) != I_BLOCK_SPECIAL) return(EINVAL); return(EINVAL);
if (req != F_GETLK && ltype == F_RDLCK && (mo & R_BIT) == 0) return(EBADF); if (req != F_GETLK && ltype == F_RDLCK && (mo & R_BIT) == 0) return(EBADF);
if (req != F_GETLK && ltype == F_WRLCK && (mo & W_BIT) == 0) return(EBADF); if (req != F_GETLK && ltype == F_WRLCK && (mo & W_BIT) == 0) return(EBADF);

View File

@ -229,7 +229,7 @@ int do_fcntl()
signed long offset; signed long offset;
/* Check if it's a regular file. */ /* Check if it's a regular file. */
if ((f->filp_vno->v_mode & I_TYPE) != I_REGULAR) r = EINVAL; if (!S_ISREG(f->filp_vno->v_mode)) r = EINVAL;
else if (!(f->filp_mode & W_BIT)) r = EBADF; else if (!(f->filp_mode & W_BIT)) r = EBADF;
else else
/* Copy flock data from userspace. */ /* Copy flock data from userspace. */
@ -495,7 +495,7 @@ static void free_proc(struct fproc *exiter, int flags)
if ((rfilp = rfp->fp_filp[i]) == NULL) continue; if ((rfilp = rfp->fp_filp[i]) == NULL) continue;
if (rfilp->filp_mode == FILP_CLOSED) continue; if (rfilp->filp_mode == FILP_CLOSED) continue;
vp = rfilp->filp_vno; vp = rfilp->filp_vno;
if ((vp->v_mode & I_TYPE) != I_CHAR_SPECIAL) continue; if (!S_ISCHR(vp->v_mode)) continue;
if ((dev_t) vp->v_sdev != dev) continue; if ((dev_t) vp->v_sdev != dev) continue;
lock_filp(rfilp, VNODE_READ); lock_filp(rfilp, VNODE_READ);
(void) dev_close(dev, rfilp-filp); /* Ignore any errors, even (void) dev_close(dev, rfilp-filp); /* Ignore any errors, even

View File

@ -173,7 +173,6 @@ endpoint_t fs_e,
int rdonly, int rdonly,
char mount_label[LABEL_MAX] ) char mount_label[LABEL_MAX] )
{ {
int rdir, mdir; /* TRUE iff {root|mount} file is dir */
int i, r = OK, found, isroot, mount_root, con_reqs, slot; int i, r = OK, found, isroot, mount_root, con_reqs, slot;
struct fproc *tfp, *rfp; struct fproc *tfp, *rfp;
struct dmap *dp; struct dmap *dp;
@ -348,9 +347,7 @@ char mount_label[LABEL_MAX] )
} }
/* File types may not conflict. */ /* File types may not conflict. */
mdir = ((vp->v_mode & I_TYPE) == I_DIRECTORY); /*TRUE iff dir*/ if (!S_ISDIR(vp->v_mode) && S_ISDIR(root_node->v_mode)) r = EISDIR;
rdir = ((root_node->v_mode & I_TYPE) == I_DIRECTORY);
if (!mdir && rdir) r = EISDIR;
/* If error, return the super block and both inodes; release the vmnt. */ /* If error, return the super block and both inodes; release the vmnt. */
if (r != OK) { if (r != OK) {
@ -582,7 +579,7 @@ static dev_t name_to_dev(int allow_mountpt, char path[PATH_MAX])
/* Request lookup */ /* Request lookup */
if ((vp = eat_path(&resolve, fp)) == NULL) return(NO_DEV); if ((vp = eat_path(&resolve, fp)) == NULL) return(NO_DEV);
if ((vp->v_mode & I_TYPE) == I_BLOCK_SPECIAL) { if (S_ISBLK(vp->v_mode)) {
dev = vp->v_sdev; dev = vp->v_sdev;
} else if (allow_mountpt && vp->v_vmnt->m_root_node == vp) { } else if (allow_mountpt && vp->v_vmnt->m_root_node == vp) {
dev = vp->v_dev; dev = vp->v_dev;

View File

@ -131,7 +131,7 @@ int common_open(char path[PATH_MAX], int oflags, mode_t omode)
/* If O_CREATE is set, try to make the file. */ /* If O_CREATE is set, try to make the file. */
if (oflags & O_CREAT) { if (oflags & O_CREAT) {
omode = I_REGULAR | (omode & ALL_MODES & fp->fp_umask); omode = I_REGULAR | (omode & ALLPERMS & fp->fp_umask);
vp = new_node(&resolve, oflags, omode); vp = new_node(&resolve, oflags, omode);
r = err_code; r = err_code;
if (r == OK) exist = FALSE; /* We just created the file */ if (r == OK) exist = FALSE; /* We just created the file */
@ -166,8 +166,8 @@ int common_open(char path[PATH_MAX], int oflags, mode_t omode)
/* Check protections. */ /* Check protections. */
if ((r = forbidden(fp, vp, bits)) == OK) { if ((r = forbidden(fp, vp, bits)) == OK) {
/* Opening reg. files, directories, and special files differ */ /* Opening reg. files, directories, and special files differ */
switch (vp->v_mode & I_TYPE) { switch (vp->v_mode & S_IFMT) {
case I_REGULAR: case S_IFREG:
/* Truncate regular file if O_TRUNC. */ /* Truncate regular file if O_TRUNC. */
if (oflags & O_TRUNC) { if (oflags & O_TRUNC) {
if ((r = forbidden(fp, vp, W_BIT)) != OK) if ((r = forbidden(fp, vp, W_BIT)) != OK)
@ -175,11 +175,11 @@ int common_open(char path[PATH_MAX], int oflags, mode_t omode)
truncate_vnode(vp, 0); truncate_vnode(vp, 0);
} }
break; break;
case I_DIRECTORY: case S_IFDIR:
/* Directories may be read but not written. */ /* Directories may be read but not written. */
r = (bits & W_BIT ? EISDIR : OK); r = (bits & W_BIT ? EISDIR : OK);
break; break;
case I_CHAR_SPECIAL: case S_IFCHR:
/* Invoke the driver for special processing. */ /* Invoke the driver for special processing. */
dev = (dev_t) vp->v_sdev; dev = (dev_t) vp->v_sdev;
/* TTY needs to know about the O_NOCTTY flag. */ /* TTY needs to know about the O_NOCTTY flag. */
@ -188,7 +188,7 @@ int common_open(char path[PATH_MAX], int oflags, mode_t omode)
else vp = filp->filp_vno; /* Might be updated by else vp = filp->filp_vno; /* Might be updated by
* dev_open/clone_opcl */ * dev_open/clone_opcl */
break; break;
case I_BLOCK_SPECIAL: case S_IFBLK:
lock_bsf(); lock_bsf();
@ -240,7 +240,7 @@ int common_open(char path[PATH_MAX], int oflags, mode_t omode)
unlock_bsf(); unlock_bsf();
break; break;
case I_NAMED_PIPE: case S_IFIFO:
/* Create a mapped inode on PFS which handles reads /* Create a mapped inode on PFS which handles reads
and writes to this named pipe. */ and writes to this named pipe. */
tll_upgrade(&vp->v_lock); tll_upgrade(&vp->v_lock);
@ -547,7 +547,7 @@ int do_mknod()
if (!super_user && (!S_ISFIFO(mode_bits) && !S_ISSOCK(mode_bits))) { if (!super_user && (!S_ISFIFO(mode_bits) && !S_ISSOCK(mode_bits))) {
return(EPERM); return(EPERM);
} }
bits = (mode_bits & I_TYPE) | (mode_bits & ALL_MODES & fp->fp_umask); bits = (mode_bits & S_IFMT) | (mode_bits & ACCESSPERMS & fp->fp_umask);
/* Open directory that's going to hold the new node. */ /* Open directory that's going to hold the new node. */
if (fetch_name(vname1, vname1_length, fullpath) != OK) return(err_code); if (fetch_name(vname1, vname1_length, fullpath) != OK) return(err_code);

View File

@ -552,9 +552,7 @@ char ename[NAME_MAX + 1];
pos = make64(0, 0); pos = make64(0, 0);
if ((dirp->v_mode & I_TYPE) != I_DIRECTORY) { if (!S_ISDIR(dirp->v_mode)) return(EBADF);
return(EBADF);
}
do { do {
r = req_getdents(dirp->v_fs_e, dirp->v_inode_nr, pos, buf, sizeof(buf), r = req_getdents(dirp->v_fs_e, dirp->v_inode_nr, pos, buf, sizeof(buf),

View File

@ -9,6 +9,7 @@
*/ */
#include "fs.h" #include "fs.h"
#include <sys/stat.h>
#include <unistd.h> #include <unistd.h>
#include <minix/callnr.h> #include <minix/callnr.h>
#include "file.h" #include "file.h"
@ -268,8 +269,7 @@ int forbidden(struct fproc *rfp, struct vnode *vp, mode_t access_desired)
* directories. Grant execute permission (for non-directories) if * directories. Grant execute permission (for non-directories) if
* and only if one of the 'X' bits is set. * and only if one of the 'X' bits is set.
*/ */
if ( (bits & I_TYPE) == I_DIRECTORY || if ( S_ISDIR(bits) || bits & ((X_BIT << 6) | (X_BIT << 3) | X_BIT))
bits & ((X_BIT << 6) | (X_BIT << 3) | X_BIT))
perm_bits = R_BIT | W_BIT | X_BIT; perm_bits = R_BIT | W_BIT | X_BIT;
else else
perm_bits = R_BIT | W_BIT; perm_bits = R_BIT | W_BIT;

View File

@ -108,8 +108,7 @@ int read_write(int rw_flag, struct filp *f, char *buf, size_t size,
register struct vnode *vp; register struct vnode *vp;
u64_t position, res_pos, new_pos; u64_t position, res_pos, new_pos;
unsigned int cum_io, cum_io_incr, res_cum_io; unsigned int cum_io, cum_io_incr, res_cum_io;
int op, oflags, r, block_spec, char_spec, regular; int op, oflags, r;
mode_t mode_word;
position = f->filp_pos; position = f->filp_pos;
oflags = f->filp_flags; oflags = f->filp_flags;
@ -128,23 +127,14 @@ int read_write(int rw_flag, struct filp *f, char *buf, size_t size,
} }
op = (rw_flag == READING ? VFS_DEV_READ : VFS_DEV_WRITE); op = (rw_flag == READING ? VFS_DEV_READ : VFS_DEV_WRITE);
mode_word = vp->v_mode & I_TYPE;
regular = mode_word == I_REGULAR;
if ((char_spec = (mode_word == I_CHAR_SPECIAL ? 1 : 0))) { if (S_ISCHR(vp->v_mode)) { /* Character special files. */
if (vp->v_sdev == NO_DEV)
panic("VFS: read_write tries to access char dev NO_DEV");
}
if ((block_spec = (mode_word == I_BLOCK_SPECIAL ? 1 : 0))) {
if (vp->v_sdev == NO_DEV)
panic("VFS: read_write tries to access block dev NO_DEV");
}
if (char_spec) { /* Character special files. */
dev_t dev; dev_t dev;
int suspend_reopen; int suspend_reopen;
if (vp->v_sdev == NO_DEV)
panic("VFS: read_write tries to access char dev NO_DEV");
suspend_reopen = (f->filp_state != FS_NORMAL); suspend_reopen = (f->filp_state != FS_NORMAL);
dev = (dev_t) vp->v_sdev; dev = (dev_t) vp->v_sdev;
@ -155,7 +145,10 @@ int read_write(int rw_flag, struct filp *f, char *buf, size_t size,
position = add64ul(position, r); position = add64ul(position, r);
r = OK; r = OK;
} }
} else if (block_spec) { /* Block special files. */ } else if (S_ISBLK(vp->v_mode)) { /* Block special files. */
if (vp->v_sdev == NO_DEV)
panic("VFS: read_write tries to access block dev NO_DEV");
lock_bsf(); lock_bsf();
r = req_breadwrite(vp->v_bfs_e, for_e, vp->v_sdev, position, size, r = req_breadwrite(vp->v_bfs_e, for_e, vp->v_sdev, position, size,
@ -167,7 +160,7 @@ int read_write(int rw_flag, struct filp *f, char *buf, size_t size,
unlock_bsf(); unlock_bsf();
} else { /* Regular files */ } else { /* Regular files */
if (rw_flag == WRITING && block_spec == 0) { if (rw_flag == WRITING) {
/* Check for O_APPEND flag. */ /* Check for O_APPEND flag. */
if (oflags & O_APPEND) position = cvul64(vp->v_size); if (oflags & O_APPEND) position = cvul64(vp->v_size);
} }
@ -187,7 +180,7 @@ int read_write(int rw_flag, struct filp *f, char *buf, size_t size,
/* On write, update file size and access time. */ /* On write, update file size and access time. */
if (rw_flag == WRITING) { if (rw_flag == WRITING) {
if (regular || mode_word == I_DIRECTORY) { if (S_ISREG(vp->v_mode) || S_ISDIR(vp->v_mode)) {
if (cmp64ul(position, vp->v_size) > 0) { if (cmp64ul(position, vp->v_size) > 0) {
if (ex64hi(position) != 0) { if (ex64hi(position) != 0) {
panic("read_write: file size too big "); panic("read_write: file size too big ");
@ -223,7 +216,7 @@ int do_getdents()
if (!(rfilp->filp_mode & R_BIT)) if (!(rfilp->filp_mode & R_BIT))
r = EBADF; r = EBADF;
else if ((rfilp->filp_vno->v_mode & I_TYPE) != I_DIRECTORY) else if (!S_ISDIR(rfilp->filp_vno->v_mode))
r = EBADF; r = EBADF;
if (r == OK) { if (r == OK) {

View File

@ -294,7 +294,7 @@ static int is_deferred(struct selectentry *se)
*===========================================================================*/ *===========================================================================*/
static int is_regular_file(struct filp *f) static int is_regular_file(struct filp *f)
{ {
return(f && f->filp_vno && (f->filp_vno->v_mode & I_TYPE) == I_REGULAR); return(f && f->filp_vno && S_ISREG(f->filp_vno->v_mode));
} }
/*===========================================================================* /*===========================================================================*
@ -315,7 +315,7 @@ static int is_supported_major(struct filp *f)
unsigned int m; unsigned int m;
if (!(f && f->filp_vno)) return(FALSE); if (!(f && f->filp_vno)) return(FALSE);
if ((f->filp_vno->v_mode & I_TYPE) != I_CHAR_SPECIAL) return(FALSE); if (!S_ISCHR(f->filp_vno->v_mode)) return(FALSE);
for (m = 0; m < SEL_MAJORS; m++) for (m = 0; m < SEL_MAJORS; m++)
if (major(f->filp_vno->v_sdev) == select_majors[m]) if (major(f->filp_vno->v_sdev) == select_majors[m])
@ -785,7 +785,7 @@ int status;
/* Find vnode and check we got a reply from the device we expected */ /* Find vnode and check we got a reply from the device we expected */
vp = f->filp_vno; vp = f->filp_vno;
assert(vp != NULL); assert(vp != NULL);
assert((vp->v_mode & I_TYPE) == I_CHAR_SPECIAL); assert(S_ISCHR(vp->v_mode));
if (vp->v_sdev != dev) { if (vp->v_sdev != dev) {
printf("VFS (%s:%d): expected reply from dev %d not %d\n", printf("VFS (%s:%d): expected reply from dev %d not %d\n",
__FILE__, __LINE__, vp->v_sdev, dev); __FILE__, __LINE__, vp->v_sdev, dev);
@ -882,7 +882,7 @@ int status;
for (fd = 0; fd < se->nfds; fd++) { for (fd = 0; fd < se->nfds; fd++) {
if ((f = se->filps[fd]) == NULL) continue; if ((f = se->filps[fd]) == NULL) continue;
if ((vp = f->filp_vno) == NULL) continue; if ((vp = f->filp_vno) == NULL) continue;
if ((vp->v_mode & I_TYPE) != I_CHAR_SPECIAL) continue; if (!S_ISCHR(vp->v_mode)) continue;
if (vp->v_sdev != dev) continue; if (vp->v_sdev != dev) continue;
select_lock_filp(f, f->filp_select_ops); select_lock_filp(f, f->filp_select_ops);
@ -945,7 +945,7 @@ static void select_restart_filps()
wantops = ops = f->filp_select_ops; wantops = ops = f->filp_select_ops;
vp = f->filp_vno; vp = f->filp_vno;
assert((vp->v_mode & I_TYPE) == I_CHAR_SPECIAL); assert(S_ISCHR(vp->v_mode));
r = do_select_request(se, fd, &wantops); r = do_select_request(se, fd, &wantops);
if (r != OK && r != SUSPEND) if (r != OK && r != SUSPEND)
break; /* Error or bogus return code; abort */ break; /* Error or bogus return code; abort */

View File

@ -140,7 +140,7 @@ static int change_into(struct vnode **result, struct vnode *vp)
if (*result == vp) return(OK); /* Nothing to do */ if (*result == vp) return(OK); /* Nothing to do */
/* It must be a directory and also be searchable */ /* It must be a directory and also be searchable */
if ((vp->v_mode & I_TYPE) != I_DIRECTORY) if (!S_ISDIR(vp->v_mode))
r = ENOTDIR; r = ENOTDIR;
else else
r = forbidden(fp, vp, X_BIT); /* Check if dir is searchable*/ r = forbidden(fp, vp, X_BIT); /* Check if dir is searchable*/