From 4d686f16168ef32e9b7e7a7dba194f86debedc68 Mon Sep 17 00:00:00 2001 From: Thomas Veerman Date: Tue, 30 Mar 2010 15:00:09 +0000 Subject: [PATCH] Move allocation of temporary inodes for cloned character special devices from MFS to PFS. --- servers/mfs/open.c | 40 ---------------------------------------- servers/mfs/proto.h | 1 - servers/mfs/table.c | 4 ++-- servers/pfs/inode.c | 2 ++ servers/pfs/inode.h | 1 + servers/pfs/open.c | 16 ++++++++++++---- servers/pfs/read.c | 3 --- servers/pfs/stadir.c | 9 ++++++--- servers/vfs/device.c | 12 ++++-------- servers/vfs/open.c | 2 +- 10 files changed, 28 insertions(+), 62 deletions(-) diff --git a/servers/mfs/open.c b/servers/mfs/open.c index 270cf1368..c07e34318 100644 --- a/servers/mfs/open.c +++ b/servers/mfs/open.c @@ -243,46 +243,6 @@ PUBLIC int fs_slink() return(r); } - -/*===========================================================================* - * fs_newnode * - *===========================================================================*/ -PUBLIC int fs_newnode() -{ - register int r; - mode_t bits; - struct inode *rip; - - caller_uid = fs_m_in.REQ_UID; - caller_gid = fs_m_in.REQ_GID; - bits = fs_m_in.REQ_MODE; - - /* Try to allocate the inode */ - if( (rip = alloc_inode(fs_dev, bits) ) == NIL_INODE) - return err_code; - - switch (bits & S_IFMT) { - case S_IFBLK: - case S_IFCHR: - rip->i_zone[0] = fs_m_in.REQ_DEV; /* major/minor dev numbers*/ - break; - } - - rw_inode(rip, WRITING); /* mark inode as allocated */ - rip->i_update = ATIME | CTIME | MTIME; - - /* Fill in the fields of the response message */ - fs_m_out.RES_INODE_NR = rip->i_num; - fs_m_out.RES_MODE = rip->i_mode; - fs_m_out.RES_FILE_SIZE_LO = rip->i_size; - fs_m_out.RES_UID = rip->i_uid; - fs_m_out.RES_GID = rip->i_gid; - fs_m_out.RES_DEV = (dev_t) rip->i_zone[0]; - - return(OK); -} - - /*===========================================================================* * new_node * *===========================================================================*/ diff --git a/servers/mfs/proto.h b/servers/mfs/proto.h index ea350cc4a..f8fb1263c 100644 --- a/servers/mfs/proto.h +++ b/servers/mfs/proto.h @@ -68,7 +68,6 @@ _PROTOTYPE( int fs_create, (void) ); _PROTOTYPE( int fs_inhibread, (void) ); _PROTOTYPE( int fs_mkdir, (void) ); _PROTOTYPE( int fs_mknod, (void) ); -_PROTOTYPE( int fs_newnode, (void) ); _PROTOTYPE( int fs_slink, (void) ); /* path.c */ diff --git a/servers/mfs/table.c b/servers/mfs/table.c index 53c04f8d6..ee8d456b9 100644 --- a/servers/mfs/table.c +++ b/servers/mfs/table.c @@ -15,7 +15,7 @@ PUBLIC _PROTOTYPE (int (*fs_call_vec[]), (void) ) = { no_sys, /* 0 not used */ - no_sys, /* 1 */ /* Was: fs_getnode */ + no_sys, /* 1 */ /* Was: fs_getnode */ fs_putnode, /* 2 */ fs_slink, /* 3 */ fs_ftrunc, /* 4 */ @@ -43,7 +43,7 @@ PUBLIC _PROTOTYPE (int (*fs_call_vec[]), (void) ) = { fs_lookup, /* 26 */ fs_mountpoint, /* 27 */ fs_readsuper, /* 28 */ - fs_newnode, /* 29 */ + no_sys, /* 29 */ /* Was: fs_newnode */ fs_rdlink, /* 30 */ fs_getdents, /* 31 */ }; diff --git a/servers/pfs/inode.c b/servers/pfs/inode.c index 31ed005d1..0544e8611 100644 --- a/servers/pfs/inode.c +++ b/servers/pfs/inode.c @@ -226,6 +226,8 @@ register struct inode *rip; /* pointer to inode to be released */ /* free, put at the front of the LRU list */ unhash_inode(rip); rip->i_num = 0; + rip->i_dev = NO_DEV; + rip->i_rdev = NO_DEV; TAILQ_INSERT_HEAD(&unused_inodes, rip, i_unused); } else { /* unused, put at the back of the LRU (cache it) */ diff --git a/servers/pfs/inode.h b/servers/pfs/inode.h index 40805fbe1..605cbee82 100644 --- a/servers/pfs/inode.h +++ b/servers/pfs/inode.h @@ -15,6 +15,7 @@ EXTERN struct inode { /* The following items are not present on the disk. */ dev_t i_dev; /* which device is the inode on */ + dev_t i_rdev; /* which special device is the inode on */ ino_t i_num; /* inode number on its (minor) device */ int i_count; /* # times inode used; 0 means slot is free */ char i_update; /* the ATIME, CTIME, and MTIME bits are here */ diff --git a/servers/pfs/open.c b/servers/pfs/open.c index 59d2e1625..4eecf72cd 100644 --- a/servers/pfs/open.c +++ b/servers/pfs/open.c @@ -26,10 +26,18 @@ PUBLIC int fs_newnode() /* Try to allocate the inode */ if( (rip = alloc_inode(dev, bits) ) == NIL_INODE) return(err_code); - if ((bits & S_IFMT) != S_IFIFO) { - r = EIO; /* We only support pipes */ - } else if ((get_block(dev, rip->i_num)) == NIL_BUF) - r = EIO; + switch (bits & S_IFMT) { + case S_IFBLK: + case S_IFCHR: + rip->i_rdev = dev; /* Major/minor dev numbers */ + break; + case S_IFIFO: + if ((get_block(dev, rip->i_num)) == NIL_BUF) + r = EIO; + break; + default: + r = EIO; /* Unsupported file type */ + } if (r != OK) { free_inode(rip); diff --git a/servers/pfs/read.c b/servers/pfs/read.c index 54bd1f934..215b35f71 100644 --- a/servers/pfs/read.c +++ b/servers/pfs/read.c @@ -25,9 +25,6 @@ PUBLIC int fs_readwrite(void) cum_io = 0; inumb = fs_m_in.REQ_INODE_NR; rw_flag = (fs_m_in.m_type == REQ_READ ? READING : WRITING); -#if 0 - printf("PFS: going to %s inode %d\n", (rw_flag == READING? "read from": "write to"), inumb); -#endif /* Find the inode referred */ if ((rip = find_inode(inumb)) == NIL_INODE) return(EINVAL); diff --git a/servers/pfs/stadir.c b/servers/pfs/stadir.c index 8c2a79b68..2eaec09db 100644 --- a/servers/pfs/stadir.c +++ b/servers/pfs/stadir.c @@ -13,10 +13,13 @@ PRIVATE int stat_inode( ) { /* Common code for stat and fstat system calls. */ - + mode_t type; struct stat statbuf; int r, s; + type = rip->i_mode & I_TYPE; + s = (type == I_CHAR_SPECIAL || type == I_BLOCK_SPECIAL); + /* Update the atime, ctime, and mtime fields in the inode, if need be. */ if (rip->i_update) update_times(rip); @@ -26,9 +29,9 @@ PRIVATE int stat_inode( statbuf.st_nlink = rip->i_nlinks; statbuf.st_uid = rip->i_uid; statbuf.st_gid = rip->i_gid; - statbuf.st_rdev = (dev_t) 0; + statbuf.st_rdev = (dev_t) (s ? rip->i_rdev : NO_DEV); statbuf.st_size = rip->i_size; - statbuf.st_mode &= ~I_REGULAR; /* wipe out I_REGULAR bit for pipes */ + if (!s) statbuf.st_mode &= ~I_REGULAR;/* wipe out I_REGULAR bit for pipes */ statbuf.st_atime = rip->i_atime; statbuf.st_mtime = rip->i_mtime; statbuf.st_ctime = rip->i_ctime; diff --git a/servers/vfs/device.c b/servers/vfs/device.c index 93ecb27ff..8f30e0ee1 100644 --- a/servers/vfs/device.c +++ b/servers/vfs/device.c @@ -775,15 +775,14 @@ int flags; /* mode bits and flags */ struct node_details res; /* A new minor device number has been returned. - * Request the root FS to create a temporary device file to - * hold it. + * Request PFS to create a temporary device file to hold it. */ /* Device number of the new device. */ dev = (dev & ~(BYTE << MINOR)) | (dev_mess.REP_STATUS << MINOR); /* Issue request */ - r = req_newnode(ROOT_FS_E, fp->fp_effuid, fp->fp_effgid, + r = req_newnode(PFS_PROC_NR, fp->fp_effuid, fp->fp_effgid, ALL_MODES | I_CHAR_SPECIAL, dev, &res); if (r != OK) { (void) clone_opcl(DEV_CLOSE, dev, proc_e, 0); @@ -798,11 +797,8 @@ int flags; /* mode bits and flags */ vp = fp->fp_filp[m_in.fd]->filp_vno; vp->v_fs_e = res.fs_e; - if ((vmp = find_vmnt(vp->v_fs_e)) == NIL_VMNT) - printf("VFS clone_opcl: no vmnt found\n"); - - vp->v_vmnt = vmp; - vp->v_dev = vmp->m_dev; + vp->v_vmnt = NIL_VMNT; + vp->v_dev = NO_DEV; vp->v_fs_e = res.fs_e; vp->v_inode_nr = res.inode_nr; vp->v_mode = res.fmode; diff --git a/servers/vfs/open.c b/servers/vfs/open.c index b051cd0c0..2952f1604 100644 --- a/servers/vfs/open.c +++ b/servers/vfs/open.c @@ -640,7 +640,7 @@ struct filp *fp; /* If a write has been done, the inode is already marked as DIRTY. */ if (--fp->filp_count == 0) { if (vp->v_pipe == I_PIPE) { - /* Last reader or writer is going. Tell MFS about latest + /* Last reader or writer is going. Tell PFS about latest * pipe size. */ truncate_vnode(vp, vp->v_size); -- 2.44.0