From: David van Moolenbroek Date: Thu, 24 Nov 2011 12:57:36 +0000 (+0100) Subject: vfs/avfs: map O_ACCMODE to R_BIT|W_BIT on recovery X-Git-Tag: v3.2.0~221 X-Git-Url: http://zhaoyanbai.com/repos/%22http:/www.isc.org/icons/Bv9ARM.ch10.html?a=commitdiff_plain;h=a9f89a72902af893c0a7df409aa9f476fff3189b;p=minix.git vfs/avfs: map O_ACCMODE to R_BIT|W_BIT on recovery --- diff --git a/servers/avfs/device.c b/servers/avfs/device.c index c3af865a4..bc6b0d90c 100644 --- a/servers/avfs/device.c +++ b/servers/avfs/device.c @@ -911,7 +911,7 @@ PUBLIC void bdev_up(int maj) /* A new block device driver has been mapped in. This may affect both mounted * file systems and open block-special files. */ - int r, new_driver_e, found; + int r, new_driver_e, found, bits; struct filp *rfilp; struct vmnt *vmp; struct vnode *vp; @@ -941,7 +941,8 @@ PUBLIC void bdev_up(int maj) if (!S_ISBLK(vp->v_mode)) continue; /* Reopen the device on the driver, once per filp. */ - if ((r = bdev_open(vp->v_sdev, rfilp->filp_mode & O_ACCMODE)) != OK) + bits = mode_map[rfilp->filp_mode & O_ACCMODE]; + if ((r = bdev_open(vp->v_sdev, bits)) != OK) printf("VFS: mounted dev %d/%d re-open failed: %d.\n", maj, minor(vp->v_sdev), r); diff --git a/servers/avfs/glo.h b/servers/avfs/glo.h index ed50c1b5a..95a38f02b 100644 --- a/servers/avfs/glo.h +++ b/servers/avfs/glo.h @@ -53,5 +53,6 @@ extern _PROTOTYPE (int (*call_vec[]), (void) ); /* sys call table */ extern _PROTOTYPE (int (*pfs_call_vec[]), (void) ); /* pfs callback table */ extern char dot1[2]; /* dot1 (&dot1[0]) and dot2 (&dot2[0]) have a special */ extern char dot2[3]; /* meaning to search_dir: no access permission check. */ +extern char mode_map[]; /* mapping from O_ACCMODE mask to R_BIT/W_BIT flags */ #endif diff --git a/servers/avfs/open.c b/servers/avfs/open.c index a85e2b50a..f3bb7331e 100644 --- a/servers/avfs/open.c +++ b/servers/avfs/open.c @@ -31,7 +31,7 @@ #include "vmnt.h" #include "path.h" -PRIVATE char mode_map[] = {R_BIT, W_BIT, R_BIT|W_BIT, 0}; +PUBLIC char mode_map[] = {R_BIT, W_BIT, R_BIT|W_BIT, 0}; FORWARD _PROTOTYPE( int common_open, (char path[PATH_MAX], int oflags, mode_t omode) ); @@ -158,7 +158,8 @@ PRIVATE int common_open(char path[PATH_MAX], int oflags, mode_t omode) case I_CHAR_SPECIAL: /* Invoke the driver for special processing. */ dev = (dev_t) vp->v_sdev; - r = dev_open(dev, who_e, bits | (oflags & ~O_ACCMODE)); + /* TTY needs to know about the O_NOCTTY flag. */ + r = dev_open(dev, who_e, bits | (oflags & O_NOCTTY)); if (r == SUSPEND) suspend(FP_BLOCKED_ON_DOPEN); else vp = filp->filp_vno; /* Might be updated by * dev_open/clone_opcl */ diff --git a/servers/vfs/device.c b/servers/vfs/device.c index d53825e46..f6f936835 100644 --- a/servers/vfs/device.c +++ b/servers/vfs/device.c @@ -976,7 +976,7 @@ PUBLIC void bdev_up(int maj) /* A new block device driver has been mapped in. This may affect both mounted * file systems and open block-special files. */ - int r, new_driver_e, found; + int r, new_driver_e, found, bits; struct filp *fp; struct vmnt *vmp; struct vnode *vp; @@ -1005,7 +1005,8 @@ PUBLIC void bdev_up(int maj) if(!S_ISBLK(vp->v_mode)) continue; /* Reopen the device on the driver, once per filp. */ - if ((r = bdev_open(vp->v_sdev, fp->filp_mode & O_ACCMODE)) != OK) + bits = mode_map[fp->filp_mode & O_ACCMODE]; + if ((r = bdev_open(vp->v_sdev, bits)) != OK) printf("VFS: mounted dev %d/%d re-open failed: %d.\n", maj, minor(vp->v_sdev), r); diff --git a/servers/vfs/glo.h b/servers/vfs/glo.h index 8df434d5d..6ecb0a4cd 100644 --- a/servers/vfs/glo.h +++ b/servers/vfs/glo.h @@ -34,3 +34,4 @@ extern _PROTOTYPE (int (*call_vec[]), (void) ); /* sys call table */ extern _PROTOTYPE (int (*pfs_call_vec[]), (void) ); /* pfs callback table */ extern char dot1[2]; /* dot1 (&dot1[0]) and dot2 (&dot2[0]) have a special */ extern char dot2[3]; /* meaning to search_dir: no access permission check. */ +extern char mode_map[]; /* mapping from O_ACCMODE mask to R_BIT/W_BIT flags */ diff --git a/servers/vfs/open.c b/servers/vfs/open.c index f5aa12b1f..2a949b31f 100644 --- a/servers/vfs/open.c +++ b/servers/vfs/open.c @@ -28,7 +28,7 @@ #include "vnode.h" #include "vmnt.h" -PRIVATE char mode_map[] = {R_BIT, W_BIT, R_BIT|W_BIT, 0}; +PUBLIC char mode_map[] = {R_BIT, W_BIT, R_BIT|W_BIT, 0}; FORWARD _PROTOTYPE( struct vnode *new_node, (int oflags, mode_t bits) ); FORWARD _PROTOTYPE( int pipe_open, (struct vnode *vp,mode_t bits,int oflags)); @@ -134,7 +134,8 @@ PUBLIC int common_open(register int oflags, mode_t omode) case I_CHAR_SPECIAL: /* Invoke the driver for special processing. */ dev = (dev_t) vp->v_sdev; - r = dev_open(dev, who_e, bits | (oflags & ~O_ACCMODE)); + /* TTY needs to know about the O_NOCTTY flag. */ + r = dev_open(dev, who_e, bits | (oflags & O_NOCTTY)); if (r == SUSPEND) suspend(FP_BLOCKED_ON_DOPEN); break; case I_BLOCK_SPECIAL: