/* TODO: consider making this only deal with the inode */ struct file *make_device(char *path, int mode, int type, struct file_operations *fop) { struct file *f_dev = do_file_open(path, O_CREAT | O_RDWR, mode); assert(f_dev); /* Overwrite the f_op with our own f_ops */ f_dev->f_dentry->d_inode->i_fop = fop; f_dev->f_op = fop; SET_FTYPE(f_dev->f_dentry->d_inode->i_mode, type); return f_dev; }
void bindfunc(char *name, ftype ftype, int func){ int addr; addr = freshcell(); SET_NAME(addr,name); SET_TAG(addr,FUN); SET_FTYPE(addr,ftype); switch(ftype){ case SUBR: case FSUBR: SET_SUBR(addr,func); case LAMBDA: SET_BIND(addr,func); } SET_CDR(addr,E); E = addr; }