Move allocation of temporary inodes for cloned character special devices from

MFS to PFS.
This commit is contained in:
Thomas Veerman 2010-03-30 15:00:09 +00:00
parent 4865e3f4f9
commit 4d686f1616
10 changed files with 28 additions and 62 deletions

View File

@ -243,46 +243,6 @@ PUBLIC int fs_slink()
return(r); 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 * * new_node *
*===========================================================================*/ *===========================================================================*/

View File

@ -68,7 +68,6 @@ _PROTOTYPE( int fs_create, (void) );
_PROTOTYPE( int fs_inhibread, (void) ); _PROTOTYPE( int fs_inhibread, (void) );
_PROTOTYPE( int fs_mkdir, (void) ); _PROTOTYPE( int fs_mkdir, (void) );
_PROTOTYPE( int fs_mknod, (void) ); _PROTOTYPE( int fs_mknod, (void) );
_PROTOTYPE( int fs_newnode, (void) );
_PROTOTYPE( int fs_slink, (void) ); _PROTOTYPE( int fs_slink, (void) );
/* path.c */ /* path.c */

View File

@ -43,7 +43,7 @@ PUBLIC _PROTOTYPE (int (*fs_call_vec[]), (void) ) = {
fs_lookup, /* 26 */ fs_lookup, /* 26 */
fs_mountpoint, /* 27 */ fs_mountpoint, /* 27 */
fs_readsuper, /* 28 */ fs_readsuper, /* 28 */
fs_newnode, /* 29 */ no_sys, /* 29 */ /* Was: fs_newnode */
fs_rdlink, /* 30 */ fs_rdlink, /* 30 */
fs_getdents, /* 31 */ fs_getdents, /* 31 */
}; };

View File

@ -226,6 +226,8 @@ register struct inode *rip; /* pointer to inode to be released */
/* free, put at the front of the LRU list */ /* free, put at the front of the LRU list */
unhash_inode(rip); unhash_inode(rip);
rip->i_num = 0; rip->i_num = 0;
rip->i_dev = NO_DEV;
rip->i_rdev = NO_DEV;
TAILQ_INSERT_HEAD(&unused_inodes, rip, i_unused); TAILQ_INSERT_HEAD(&unused_inodes, rip, i_unused);
} else { } else {
/* unused, put at the back of the LRU (cache it) */ /* unused, put at the back of the LRU (cache it) */

View File

@ -15,6 +15,7 @@ EXTERN struct inode {
/* The following items are not present on the disk. */ /* The following items are not present on the disk. */
dev_t i_dev; /* which device is the inode on */ 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 */ ino_t i_num; /* inode number on its (minor) device */
int i_count; /* # times inode used; 0 means slot is free */ int i_count; /* # times inode used; 0 means slot is free */
char i_update; /* the ATIME, CTIME, and MTIME bits are here */ char i_update; /* the ATIME, CTIME, and MTIME bits are here */

View File

@ -26,10 +26,18 @@ PUBLIC int fs_newnode()
/* Try to allocate the inode */ /* Try to allocate the inode */
if( (rip = alloc_inode(dev, bits) ) == NIL_INODE) return(err_code); if( (rip = alloc_inode(dev, bits) ) == NIL_INODE) return(err_code);
if ((bits & S_IFMT) != S_IFIFO) { switch (bits & S_IFMT) {
r = EIO; /* We only support pipes */ case S_IFBLK:
} else if ((get_block(dev, rip->i_num)) == NIL_BUF) 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; r = EIO;
break;
default:
r = EIO; /* Unsupported file type */
}
if (r != OK) { if (r != OK) {
free_inode(rip); free_inode(rip);

View File

@ -25,9 +25,6 @@ PUBLIC int fs_readwrite(void)
cum_io = 0; cum_io = 0;
inumb = fs_m_in.REQ_INODE_NR; inumb = fs_m_in.REQ_INODE_NR;
rw_flag = (fs_m_in.m_type == REQ_READ ? READING : WRITING); 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 */ /* Find the inode referred */
if ((rip = find_inode(inumb)) == NIL_INODE) return(EINVAL); if ((rip = find_inode(inumb)) == NIL_INODE) return(EINVAL);

View File

@ -13,10 +13,13 @@ PRIVATE int stat_inode(
) )
{ {
/* Common code for stat and fstat system calls. */ /* Common code for stat and fstat system calls. */
mode_t type;
struct stat statbuf; struct stat statbuf;
int r, s; 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. */ /* Update the atime, ctime, and mtime fields in the inode, if need be. */
if (rip->i_update) update_times(rip); if (rip->i_update) update_times(rip);
@ -26,9 +29,9 @@ PRIVATE int stat_inode(
statbuf.st_nlink = rip->i_nlinks; statbuf.st_nlink = rip->i_nlinks;
statbuf.st_uid = rip->i_uid; statbuf.st_uid = rip->i_uid;
statbuf.st_gid = rip->i_gid; 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_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_atime = rip->i_atime;
statbuf.st_mtime = rip->i_mtime; statbuf.st_mtime = rip->i_mtime;
statbuf.st_ctime = rip->i_ctime; statbuf.st_ctime = rip->i_ctime;

View File

@ -775,15 +775,14 @@ int flags; /* mode bits and flags */
struct node_details res; struct node_details res;
/* A new minor device number has been returned. /* A new minor device number has been returned.
* Request the root FS to create a temporary device file to * Request PFS to create a temporary device file to hold it.
* hold it.
*/ */
/* Device number of the new device. */ /* Device number of the new device. */
dev = (dev & ~(BYTE << MINOR)) | (dev_mess.REP_STATUS << MINOR); dev = (dev & ~(BYTE << MINOR)) | (dev_mess.REP_STATUS << MINOR);
/* Issue request */ /* 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); ALL_MODES | I_CHAR_SPECIAL, dev, &res);
if (r != OK) { if (r != OK) {
(void) clone_opcl(DEV_CLOSE, dev, proc_e, 0); (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 = fp->fp_filp[m_in.fd]->filp_vno;
vp->v_fs_e = res.fs_e; vp->v_fs_e = res.fs_e;
if ((vmp = find_vmnt(vp->v_fs_e)) == NIL_VMNT) vp->v_vmnt = NIL_VMNT;
printf("VFS clone_opcl: no vmnt found\n"); vp->v_dev = NO_DEV;
vp->v_vmnt = vmp;
vp->v_dev = vmp->m_dev;
vp->v_fs_e = res.fs_e; vp->v_fs_e = res.fs_e;
vp->v_inode_nr = res.inode_nr; vp->v_inode_nr = res.inode_nr;
vp->v_mode = res.fmode; vp->v_mode = res.fmode;

View File

@ -640,7 +640,7 @@ struct filp *fp;
/* If a write has been done, the inode is already marked as DIRTY. */ /* If a write has been done, the inode is already marked as DIRTY. */
if (--fp->filp_count == 0) { if (--fp->filp_count == 0) {
if (vp->v_pipe == I_PIPE) { 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. * pipe size.
*/ */
truncate_vnode(vp, vp->v_size); truncate_vnode(vp, vp->v_size);