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);
if(fp == NULL)
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);
if(ip == NULL)
return;
stat1(ip, uap->sb);
stat1(ip, uap->sb, (off_t)0);
iput(ip);
}
@ -76,15 +76,15 @@ stat()
* The basic routine for fstat and stat:
* get the inode and pass appropriate parts back.
*/
stat1(ip, ub)
stat1(ip, ub, pipeadj)
register struct inode *ip;
struct stat *ub;
off_t pipeadj;
{
register struct dinode *dp;
register struct buf *bp;
struct stat ds;
if(ip->i_flag&(IACC|IUPD|ICHG))
iupdat(ip, &time, &time);
/*
* first copy from inode table
@ -96,7 +96,7 @@ struct stat *ub;
ds.st_uid = ip->i_uid;
ds.st_gid = ip->i_gid;
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
*/
@ -117,20 +117,37 @@ struct stat *ub;
dup()
{
register struct file *fp;
register i;
register struct a {
int fdes;
int fdes2;
} *uap;
register i, m;
int foo1,foo2,foo3;
uap = (struct a *)u.u_ap;
m = uap->fdes & ~077;
uap->fdes &= 077;
fp = getf(uap->fdes);
if(fp == NULL)
return;
if ((m&0100) == 0) {
if ((i = ufalloc(0)) < 0)
return;
} 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++;
}
}
/*
* the file control system call.
@ -189,7 +206,7 @@ fcntl()
*/
smount()
{
dev_t dev;
register dev_t dev;
register struct inode *ip;
register struct mount *mp;
struct mount *smp;
@ -202,26 +219,20 @@ smount()
} *uap;
uap = (struct a *)u.u_ap;
if(!suser())
return;
dev = getmdev();
if(u.u_error)
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);
if(ip == NULL)
return;
if ((ip->i_mode&IFMT) != IFDIR) {
u.u_error = ENOTDIR;
goto out;
}
if (ip->i_count != 1)
goto out;
if (ip->i_number == ROOTINO)
if (ip->i_mode&2000)
goto out;
smp = NULL;
for(mp = &mount[0]; mp < &mount[Nmount]; mp++) {
if(mp->m_flags != MFREE) {
if(mp->m_bufp) {
if(dev == mp->m_dev)
goto out;
} else
@ -231,9 +242,7 @@ smount()
mp = smp;
if(mp == NULL)
goto out;
mp->m_flags = MINTER;
mp->m_dev = dev;
(*bdevsw[major(dev)].d_open)(minor(dev), !uap->ronly);
(*bdevsw[major(dev)].d_open)(dev, !uap->ronly);
if(u.u_error)
goto out1;
bp = bread(dev, SUPERB);
@ -242,14 +251,13 @@ smount()
goto out1;
}
mp->m_inodp = ip;
mp->m_dev = dev;
mp->m_bufp = geteblk();
bcopy((caddr_t)bp->b_un.b_addr, mp->m_bufp->b_un.b_addr, BSIZE);
fp = mp->m_bufp->b_un.b_filsys;
mp->m_flags = MINUSE;
fp->s_ilock = 0;
fp->s_flock = 0;
fp->s_ninode = 0;
fp->s_inode[0] = 0;
fp->s_ronly = uap->ronly & 1;
brelse(bp);
ip->i_flag |= IMOUNT;
@ -269,22 +277,21 @@ out:
*/
sumount()
{
dev_t dev;
register dev_t dev;
register struct inode *ip;
register struct mount *mp;
struct buf *bp;
register struct a {
char *fspec;
};
if(!suser())
return;
dev = getmdev();
if(u.u_error)
return;
xumount(dev); /* remove unused sticky files from text table */
update();
for(mp = &mount[0]; mp < &mount[Nmount]; mp++)
if(mp->m_flags == MINUSE && dev == mp->m_dev)
if(mp->m_bufp)
goto found;
u.u_error = EINVAL;
return;
@ -295,17 +302,19 @@ found:
u.u_error = EBUSY;
return;
}
(*bdevsw[major(dev)].d_close)(minor(dev), 0);
(*bdevsw[major(dev)].d_close)(dev, 0);
binval(dev);
ip = mp->m_inodp;
ip->i_flag &= ~IMOUNT;
plock(ip);
iput(ip);
brelse(mp->m_bufp);
bp = mp->m_bufp;
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.
* Check that the user's argument is a reasonable
@ -314,7 +323,7 @@ found:
dev_t
getmdev()
{
dev_t dev;
register dev_t dev;
register struct inode *ip;
ip = namei(uchar, 0);
@ -323,12 +332,13 @@ getmdev()
if((ip->i_mode&IFMT) != IFBLK)
u.u_error = ENOTBLK;
dev = (dev_t)ip->i_rdev;
/* if(major(dev) >= bdevcnt)
if(major(dev) >= nblkdev)
u.u_error = ENXIO;
*/ iput(ip);
iput(ip);
return(dev);
}
/*
* character special i/o control
*/