diff --git a/sys/fs/vfs/inode.c b/sys/fs/vfs/inode.c index 190f475..bcfaab3 100644 --- a/sys/fs/vfs/inode.c +++ b/sys/fs/vfs/inode.c @@ -1,14 +1,23 @@ #include +#include + +static struct inode *first_inode; +static struct wait_queue *inode_wait = NULL; +static int nr_inodes = 0, nr_free_inodes = 0; void iput(struct inode * inode) { if (!inode) return; wait_on_inode(inode); + +#ifdef _BALLS if (!inode->i_count) { printk("VFS: iput: trying to free free inode\n"); printk("VFS: device %d/%d, inode %lu, mode=0%07o\n", MAJOR(inode->i_rdev), MINOR(inode->i_rdev), inode->i_ino, inode->i_mode); return; } +#endif + if (inode->i_pipe) wake_up_interruptible(&PIPE_WAIT(*inode)); repeat: if (inode->i_count > 1) { @@ -18,7 +27,7 @@ wake_up(&inode_wait); if (inode->i_pipe) { unsigned long page = (unsigned long) PIPE_BASE(*inode); - PIPE_BASE(*inode) = NULL; + PIPE_BASE (*inode) = NULL; free_page(page); } if (inode->i_sb && inode->i_sb->s_op && inode->i_sb->s_op->put_inode) { diff --git a/sys/fs/vfs/namei.c b/sys/fs/vfs/namei.c index a128331..34153eb 100644 --- a/sys/fs/vfs/namei.c +++ b/sys/fs/vfs/namei.c @@ -1,6 +1,21 @@ #include #include +int follow_link(struct inode * dir, struct inode * inode, int flag, int mode, struct inode ** res_inode) { + if (!dir || !inode) { + iput(dir); + iput(inode); + *res_inode = NULL; + return -ENOENT; + } + if (!inode->i_op || !inode->i_op->follow_link) { + iput(dir); + *res_inode = inode; + return 0; + } + return inode->i_op->follow_link(dir, inode, flag, mode, res_inode); +} + int permission(struct inode * inode, int mask) { int mode = inode->i_mode; @@ -10,7 +25,7 @@ mode >>= 6; else if (in_group_p(inode->i_gid)) mode >>= 3; - if (((mode & mask & 0007) == mask))// || suser()) + if (((mode & mask & 0007) == mask)) // || suser()) return 1; return 0; } @@ -20,6 +35,7 @@ int perm; *result = NULL; + if (!dir) return -ENOENT; /* check permissions before traversing mount-points */ @@ -28,8 +44,7 @@ if (dir == _current->root) { *result = dir; return 0; - } - else if ((sb = dir->i_sb) && (dir == sb->s_mounted)) { + } else if ((sb = dir->i_sb) && (dir == sb->s_mounted)) { sb = dir->i_sb; iput(dir); dir = sb->s_covered; @@ -53,7 +68,6 @@ return dir->i_op->lookup(dir, name, len, result); } - static int dir_namei(const char * pathname, int * namelen, const char ** name, struct inode * base, struct inode ** res_inode) { char c; const char * thisname; @@ -121,8 +135,7 @@ error = follow_link(base, inode, 0, 0, &inode); if (error) return error; - } - else + } else iput(base); *res_inode = inode; diff --git a/sys/include/fs/pipe_fs.h b/sys/include/fs/pipe_fs.h index 42882b9..d87f50a 100644 --- a/sys/include/fs/pipe_fs.h +++ b/sys/include/fs/pipe_fs.h @@ -2,15 +2,34 @@ #define _FS_PIPE_FS_H struct pipe_inode_info { - struct wait_queue *wait; - char *base; - unsigned int start; - unsigned int len; - unsigned int lock; - unsigned int rd_openers; - unsigned int wr_openers; - unsigned int readers; - unsigned int writers; + struct wait_queue *wait; + char *base; + unsigned int start; + unsigned int len; + unsigned int lock; + unsigned int rd_openers; + unsigned int wr_openers; + unsigned int readers; + unsigned int writers; }; +#define PIPE_WAIT(inode) ((inode).u.pipe_i.wait) +#define PIPE_BASE(inode) ((inode).u.pipe_i.base) +#define PIPE_START(inode) ((inode).u.pipe_i.start) +#define PIPE_LEN(inode) ((inode).u.pipe_i.len) +#define PIPE_RD_OPENERS(inode) ((inode).u.pipe_i.rd_openers) +#define PIPE_WR_OPENERS(inode) ((inode).u.pipe_i.wr_openers) +#define PIPE_READERS(inode) ((inode).u.pipe_i.readers) +#define PIPE_WRITERS(inode) ((inode).u.pipe_i.writers) +#define PIPE_LOCK(inode) ((inode).u.pipe_i.lock) +#define PIPE_SIZE(inode) PIPE_LEN(inode) + +#define PIPE_EMPTY(inode) (PIPE_SIZE(inode)==0) +#define PIPE_FULL(inode) (PIPE_SIZE(inode)==PIPE_BUF) +#define PIPE_FREE(inode) (PIPE_BUF - PIPE_LEN(inode)) +#define PIPE_END(inode) ((PIPE_START(inode)+PIPE_LEN(inode))&\ + (PIPE_BUF-1)) +#define PIPE_MAX_RCHUNK(inode) (PIPE_BUF - PIPE_START(inode)) +#define PIPE_MAX_WCHUNK(inode) (PIPE_BUF - PIPE_END(inode)) + #endif diff --git a/sys/include/vfs/vfs.h b/sys/include/vfs/vfs.h index 77035f4..ddec899 100644 --- a/sys/include/vfs/vfs.h +++ b/sys/include/vfs/vfs.h @@ -101,6 +101,17 @@ #include #include +struct super_operations { + void (*read_inode) (struct inode *); + int (*notify_change) (int flags, struct inode *); + void (*write_inode) (struct inode *); + void (*put_inode) (struct inode *); + void (*put_super) (struct super_block *); + void (*write_super) (struct super_block *); + void (*statfs) (struct super_block *, struct statfs *); + int (*remount_fs) (struct super_block *, int *, char *); +}; + struct super_block { __dev_t s_dev; unsigned long s_blocksize;