STATUS: 50%

0000 T _fstat		compatible
    0044 T _stat		compatible
    0086 T _stat1		compatible
    0172 T _dup			compatible
    022e T _fcntl		compatible
    02fc T _smount		not compatible
    04bc T _sumount		not compatible
    05be T _getmdev		compatible
    062a T _ioctl		not compatible
    06c2 T _stty		not compatible
    06e2 T _gtty		not compatible
    0702 T _mdmctl		not existing
This commit is contained in:
Oliver Lehmann 2008-05-23 22:38:57 +00:00
parent 06cad5919e
commit 114fa234f7
1 changed files with 46 additions and 36 deletions

View File

@ -50,7 +50,7 @@ fstat()
fp = getf(uap->fdes); fp = getf(uap->fdes);
if(fp == NULL) if(fp == NULL)
return; return;
stat1(fp->f_inode, uap->sb); stat1(fp->f_inode, uap->sb, fp->f_flag&FPIPE? fp->f_un.f_off: 0);
} }
/* /*
@ -68,7 +68,7 @@ stat()
ip = namei(uchar, 0); ip = namei(uchar, 0);
if(ip == NULL) if(ip == NULL)
return; return;
stat1(ip, uap->sb); stat1(ip, uap->sb, (off_t)0);
iput(ip); iput(ip);
} }
@ -76,16 +76,16 @@ stat()
* The basic routine for fstat and stat: * The basic routine for fstat and stat:
* get the inode and pass appropriate parts back. * get the inode and pass appropriate parts back.
*/ */
stat1(ip, ub) stat1(ip, ub, pipeadj)
register struct inode *ip; register struct inode *ip;
struct stat *ub; struct stat *ub;
off_t pipeadj;
{ {
register struct dinode *dp; register struct dinode *dp;
register struct buf *bp; register struct buf *bp;
struct stat ds; struct stat ds;
if(ip->i_flag&(IACC|IUPD|ICHG)) iupdat(ip, &time, &time);
iupdat(ip, &time, &time);
/* /*
* first copy from inode table * first copy from inode table
*/ */
@ -96,7 +96,7 @@ struct stat *ub;
ds.st_uid = ip->i_uid; ds.st_uid = ip->i_uid;
ds.st_gid = ip->i_gid; ds.st_gid = ip->i_gid;
ds.st_rdev = (dev_t)ip->i_rdev; ds.st_rdev = (dev_t)ip->i_rdev;
ds.st_size = ip->i_size; ds.st_size = ip->i_size - pipeadj;
/* /*
* next the dates in the disk * next the dates in the disk
*/ */
@ -117,19 +117,36 @@ struct stat *ub;
dup() dup()
{ {
register struct file *fp; register struct file *fp;
register i;
register struct a { register struct a {
int fdes; int fdes;
int fdes2;
} *uap; } *uap;
register i, m;
int foo1,foo2,foo3;
uap = (struct a *)u.u_ap; uap = (struct a *)u.u_ap;
m = uap->fdes & ~077;
uap->fdes &= 077;
fp = getf(uap->fdes); fp = getf(uap->fdes);
if(fp == NULL) if(fp == NULL)
return; return;
if ((i = ufalloc(0)) < 0) if ((m&0100) == 0) {
return; if ((i = ufalloc(0)) < 0)
u.u_ofile[i] = fp; return;
fp->f_count++; } else {
i = uap->fdes2;
if (i<0 || i>=NOFILE) {
u.u_error = EBADF;
return;
}
u.u_r.r_val1 = i;
}
if (i!=uap->fdes) {
if (u.u_ofile[i]!=NULL)
closef(u.u_ofile[i]);
u.u_ofile[i] = fp;
fp->f_count++;
}
} }
/* /*
@ -189,7 +206,7 @@ fcntl()
*/ */
smount() smount()
{ {
dev_t dev; register dev_t dev;
register struct inode *ip; register struct inode *ip;
register struct mount *mp; register struct mount *mp;
struct mount *smp; struct mount *smp;
@ -202,26 +219,20 @@ smount()
} *uap; } *uap;
uap = (struct a *)u.u_ap; uap = (struct a *)u.u_ap;
if(!suser())
return;
dev = getmdev(); dev = getmdev();
if(u.u_error) if(u.u_error)
return; return;
u.u_dirp.l = (caddr_t)uap->freg; u.u_dirp.l = (caddr_t)(((long)uap->freg) & 0x7F00FFFF); /* FIXME: this is not 100% compatible */
ip = namei(uchar, 0); ip = namei(uchar, 0);
if(ip == NULL) if(ip == NULL)
return; return;
if ((ip->i_mode&IFMT) != IFDIR) {
u.u_error = ENOTDIR;
goto out;
}
if (ip->i_count != 1) if (ip->i_count != 1)
goto out; goto out;
if (ip->i_number == ROOTINO) if (ip->i_mode&2000)
goto out; goto out;
smp = NULL; smp = NULL;
for(mp = &mount[0]; mp < &mount[Nmount]; mp++) { for(mp = &mount[0]; mp < &mount[Nmount]; mp++) {
if(mp->m_flags != MFREE) { if(mp->m_bufp) {
if(dev == mp->m_dev) if(dev == mp->m_dev)
goto out; goto out;
} else } else
@ -231,9 +242,7 @@ smount()
mp = smp; mp = smp;
if(mp == NULL) if(mp == NULL)
goto out; goto out;
mp->m_flags = MINTER; (*bdevsw[major(dev)].d_open)(dev, !uap->ronly);
mp->m_dev = dev;
(*bdevsw[major(dev)].d_open)(minor(dev), !uap->ronly);
if(u.u_error) if(u.u_error)
goto out1; goto out1;
bp = bread(dev, SUPERB); bp = bread(dev, SUPERB);
@ -242,14 +251,13 @@ smount()
goto out1; goto out1;
} }
mp->m_inodp = ip; mp->m_inodp = ip;
mp->m_dev = dev;
mp->m_bufp = geteblk(); mp->m_bufp = geteblk();
bcopy((caddr_t)bp->b_un.b_addr, mp->m_bufp->b_un.b_addr, BSIZE); bcopy((caddr_t)bp->b_un.b_addr, mp->m_bufp->b_un.b_addr, BSIZE);
fp = mp->m_bufp->b_un.b_filsys; fp = mp->m_bufp->b_un.b_filsys;
mp->m_flags = MINUSE; mp->m_flags = MINUSE;
fp->s_ilock = 0; fp->s_ilock = 0;
fp->s_flock = 0; fp->s_flock = 0;
fp->s_ninode = 0;
fp->s_inode[0] = 0;
fp->s_ronly = uap->ronly & 1; fp->s_ronly = uap->ronly & 1;
brelse(bp); brelse(bp);
ip->i_flag |= IMOUNT; ip->i_flag |= IMOUNT;
@ -269,22 +277,21 @@ out:
*/ */
sumount() sumount()
{ {
dev_t dev; register dev_t dev;
register struct inode *ip; register struct inode *ip;
register struct mount *mp; register struct mount *mp;
struct buf *bp;
register struct a { register struct a {
char *fspec; char *fspec;
}; };
if(!suser())
return;
dev = getmdev(); dev = getmdev();
if(u.u_error) if(u.u_error)
return; return;
xumount(dev); /* remove unused sticky files from text table */ xumount(dev); /* remove unused sticky files from text table */
update(); update();
for(mp = &mount[0]; mp < &mount[Nmount]; mp++) for(mp = &mount[0]; mp < &mount[Nmount]; mp++)
if(mp->m_flags == MINUSE && dev == mp->m_dev) if(mp->m_bufp)
goto found; goto found;
u.u_error = EINVAL; u.u_error = EINVAL;
return; return;
@ -295,17 +302,19 @@ found:
u.u_error = EBUSY; u.u_error = EBUSY;
return; return;
} }
(*bdevsw[major(dev)].d_close)(minor(dev), 0); (*bdevsw[major(dev)].d_close)(dev, 0);
binval(dev); binval(dev);
ip = mp->m_inodp; ip = mp->m_inodp;
ip->i_flag &= ~IMOUNT; ip->i_flag &= ~IMOUNT;
plock(ip); plock(ip);
iput(ip); iput(ip);
brelse(mp->m_bufp); bp = mp->m_bufp;
mp->m_bufp = NULL; mp->m_bufp = NULL;
mp->m_flags = MFREE; brelse(bp);
/* FIXME: here has to be a clr @r8 - rr8 is mp */
} }
/* /*
* Common code for mount and umount. * Common code for mount and umount.
* Check that the user's argument is a reasonable * Check that the user's argument is a reasonable
@ -314,7 +323,7 @@ found:
dev_t dev_t
getmdev() getmdev()
{ {
dev_t dev; register dev_t dev;
register struct inode *ip; register struct inode *ip;
ip = namei(uchar, 0); ip = namei(uchar, 0);
@ -323,12 +332,13 @@ getmdev()
if((ip->i_mode&IFMT) != IFBLK) if((ip->i_mode&IFMT) != IFBLK)
u.u_error = ENOTBLK; u.u_error = ENOTBLK;
dev = (dev_t)ip->i_rdev; dev = (dev_t)ip->i_rdev;
/* if(major(dev) >= bdevcnt) if(major(dev) >= nblkdev)
u.u_error = ENXIO; u.u_error = ENXIO;
*/ iput(ip); iput(ip);
return(dev); return(dev);
} }
/* /*
* character special i/o control * character special i/o control
*/ */