Esempio n. 1
0
File: devio.c Progetto: 8l/FUZIX
void validchk(uint16_t dev, const char *p)
{
        if (!validdev(dev)) {
                kputs(p);
                kputchar(':');
                panic(PANIC_INVD);
        }
}
Esempio n. 2
0
File: devio.c Progetto: 8l/FUZIX
int d_open(uint16_t dev, uint8_t flag)
{
	if (!validdev(dev)) {
	        udata.u_error = ENXIO;
		return -1;
        }
	return ((*dev_tab[major(dev)].dev_open) (minor(dev), flag));
}
Esempio n. 3
0
File: devio.c Progetto: 8l/FUZIX
int d_ioctl(uint16_t dev, uint16_t request, char *data)
{
	int ret;

	if (!validdev(dev)) {
		udata.u_error = ENXIO;
		return -1;
	}

	ret =  (*dev_tab[major(dev)].dev_ioctl) (minor(dev), request, data);
	if (ret == -1 && !udata.u_error)	// maybe the ioctl routine might set this?
			udata.u_error = ENOTTY;
	return ret;
}
Esempio n. 4
0
inoptr i_open(uint16_t dev, uint16_t ino)
{
    struct dinode *buf;
    inoptr nindex, j;
    bool isnew = false;

    if(!validdev(dev))
        panic("i_open: bad dev");

    if(!ino){        /* ino==0 means we want a new one */
        isnew = true;
        ino = i_alloc(dev);
        if(!ino) {
            udata.u_error = ENOSPC;
            return NULLINODE;
        }
    }

    /* Maybe make this DEBUG only eventually - the fs_tab_get cost
       is higher than ideal */
    if(ino < ROOTINODE || ino >= (fs_tab_get(dev)->m_fs->s_isize - 2) * 8) {
        kputs("i_open: bad inode number\n");
        return NULLINODE;
    }

    nindex = NULLINODE;
    for(j=i_tab; j<i_tab+ITABSIZE; j++){
        if(!j->c_refs) // free slot?
            nindex = j;

        if(j->c_dev == dev && j->c_num == ino) {
            nindex = j;
            goto found;
        }
    }
    /* Not already in the table. */

    if(!nindex){      /* No unrefed slots in inode table */
        udata.u_error = ENFILE;
        return(NULLINODE);
    }

    buf =(struct dinode *)bread(dev,(ino>>3)+2, 0);
    memcpy((char *)&(nindex->c_node), (char *)&(buf[ino & 0x07]), 64);
    brelse(buf);

    nindex->c_dev = dev;
    nindex->c_num = ino;
    nindex->c_magic = CMAGIC;

found:
    if(isnew) {
        if(nindex->c_node.i_nlink || nindex->c_node.i_mode & F_MASK)
            goto badino;
    } else {
        if(!(nindex->c_node.i_nlink && nindex->c_node.i_mode & F_MASK))
            goto badino;
    }
    nindex->c_refs++;
    return nindex;

badino:
    kputs("i_open: bad disk inode\n");
    return NULLINODE;
}