vfs/avfs: map O_ACCMODE to R_BIT|W_BIT on recovery
This commit is contained in:
parent
e8f944d3ca
commit
a9f89a7290
6 changed files with 14 additions and 8 deletions
|
@ -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);
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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);
|
||||
|
||||
|
|
|
@ -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 */
|
||||
|
|
|
@ -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:
|
||||
|
|
Loading…
Reference in a new issue