Hi, Opening, closing and creation of named pipes and sockets is now possible. This functionality resulted as a side effect of a reorganization of inode structures creation. Now, fs/inode.c and fs/minix/*.c know very little about pipes, fifos and sockets. The special behavior when opening named pipes is not implemented yet. Data size was increased by 20 bytes.
diff -Nur elks-2m/fs/inode.c elks/fs/inode.c --- elks-2m/fs/inode.c 2015-03-10 01:12:54.000000000 -0600 +++ elks/fs/inode.c 2015-03-10 09:07:38.632998326 -0600 @@ -172,14 +172,34 @@ unlock_inode(inode); } +static void set_ops(register struct inode *inode) +{ + static unsigned char tabc[] = { + 0, 1, 2, 0, 0, 0, 3, 0, + 0, 0, 0, 0, 4, 0, 0, 0, + }; + static struct inode_operations *inop[] = { + NULL, /* Invalid */ + &pipe_inode_operations, /* FIFO */ + &chrdev_inode_operations, + &blkdev_inode_operations, + &sock_inode_operations, /* Socket */ + }; + + inode->i_op = inop[(int)tabc[(inode->i_mode & S_IFMT) >> 12]]; +} + static void read_inode(register struct inode *inode) { struct super_block *sb = inode->i_sb; register struct super_operations *sop; lock_inode(inode); - if (sb && (sop = sb->s_op) && sop->read_inode) + if (sb && (sop = sb->s_op) && sop->read_inode) { sop->read_inode(inode); + if(inode->i_op == NULL) + set_ops(inode); + } unlock_inode(inode); } @@ -425,26 +445,34 @@ return inode; } -#if CONFIG_PIPE -struct inode *get_pipe_inode(void) +struct inode *new_inode(register struct inode *dir, __u16 mode) { register struct inode *inode; - extern struct inode_operations pipe_inode_operations; - if ((inode = get_empty_inode())) { - inode->i_mode = S_IFIFO | S_IRUSR | S_IWUSR; - inode->i_op = &pipe_inode_operations; - inode->i_gid = (__u8) current->egid; - inode->i_atime = inode->i_mtime = inode->i_ctime = CURRENT_TIME; + if(!(inode = get_empty_inode())) + return NULL; + inode->i_gid =(__u8) current->egid; + if(dir) { + inode->i_sb = dir->i_sb; + inode->i_dev = inode->i_sb->s_dev; + inode->i_flags = inode->i_sb->s_flags; + if(dir->i_mode & S_ISGID) { + inode->i_gid = dir->i_gid; + if(S_ISDIR(mode)) + mode |= S_ISGID; + } + } + + inode->i_mode = mode; + inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME; -#if 0 - inode->i_blksize = PAGE_SIZE; +#ifdef BLOAT_FS + inode->i_blocks = inode->i_blksize = 0; #endif - } + set_ops(inode); return inode; } -#endif struct inode *__iget(register struct super_block *sb, ino_t inr /*,int crossmntp */ ) diff -Nur elks-2m/fs/minix/bitmap.c elks/fs/minix/bitmap.c --- elks-2m/fs/minix/bitmap.c 2015-03-04 23:05:16.000000000 -0600 +++ elks/fs/minix/bitmap.c 2015-03-10 09:07:38.632998326 -0600 @@ -203,13 +203,9 @@ /* Adding an sb here does not make the code smaller */ block_t i, j; - if (!dir || !(inode = get_empty_inode())) + if(!dir || !(inode = new_inode(dir, mode))) return NULL; - inode->i_sb = dir->i_sb; - inode->i_flags = inode->i_sb->s_flags; - if((S_ISDIR(mode)) && (dir->i_mode & S_ISGID)) - mode |= S_ISGID; - inode->i_mode = mode; + minix_set_ops(inode); j = 8192; for (i = 0; i < 8; i++) @@ -234,12 +230,8 @@ goto iputfail; } unmap_buffer(bh); - inode->i_dev = inode->i_sb->s_dev; - inode->i_gid = (dir->i_mode & S_ISGID) ? dir->i_gid - : (__u8) current->egid; - inode->i_dirt = 1; inode->i_ino = j; - inode->i_mtime = inode->i_atime = inode->i_ctime = CURRENT_TIME; + inode->i_dirt = 1; #ifdef BLOAT_FS inode->i_blocks = inode->i_blksize = 0; diff -Nur elks-2m/fs/minix/inode.c elks/fs/minix/inode.c --- elks-2m/fs/minix/inode.c 2015-03-04 23:05:16.000000000 -0600 +++ elks/fs/minix/inode.c 2015-03-10 09:07:38.632998326 -0600 @@ -401,21 +401,18 @@ void minix_set_ops(struct inode *inode) { static unsigned char tabc[] = { - 0, 1, 2, 0, 3, 0, 4, 0, - 5, 0, 6, 0, 7, 0, 0, 0, + 0, 0, 0, 0, 1, 0, 0, 0, + 2, 0, 3, 0, 0, 0, 0, 0, }; static struct inode_operations *inop[] = { NULL, /* Invalid */ - &pipe_inode_operations, /* FIFO (init_fifo(inode);) */ - &chrdev_inode_operations, &minix_dir_inode_operations, - &blkdev_inode_operations, &minix_file_inode_operations, &minix_symlink_inode_operations, - &sock_inode_operations, /* Socket */ }; - inode->i_op = inop[(int)tabc[(inode->i_mode & S_IFMT) >> 12]]; + if(inode->i_op == NULL) + inode->i_op = inop[(int)tabc[(inode->i_mode & S_IFMT) >> 12]]; } /* diff -Nur elks-2m/fs/pipe.c elks/fs/pipe.c --- elks-2m/fs/pipe.c 2015-03-10 01:03:24.000000000 -0600 +++ elks/fs/pipe.c 2015-03-10 09:07:38.632998326 -0600 @@ -328,8 +328,7 @@ int error = -ENOMEM; int i; - inode = get_pipe_inode(); /* Create inode */ - if (!inode) + if(!(inode = new_inode(NULL, S_IFIFO | S_IRUSR | S_IWUSR))) /* Create inode */ goto no_inodes; /* read file */ diff -Nur elks-2m/include/linuxmt/fs.h elks/include/linuxmt/fs.h --- elks-2m/include/linuxmt/fs.h 2015-03-10 01:03:24.884614762 -0600 +++ elks/include/linuxmt/fs.h 2015-03-10 09:07:38.632998326 -0600 @@ -457,9 +457,9 @@ extern void iput(struct inode *); extern struct inode *get_empty_inode(void); +extern struct inode *new_inode(struct inode *dir, __u16 mode); extern void insert_inode_hash(struct inode *); extern void clear_inode(struct inode *); -extern struct inode *get_pipe_inode(void); extern int open_filp(unsigned short, struct inode *, struct file **); extern void close_filp(struct inode *, struct file *); diff -Nur elks-2m/net/socket.c elks/net/socket.c --- elks-2m/net/socket.c 2015-03-10 01:03:24.884614762 -0600 +++ elks/net/socket.c 2015-03-10 09:07:38.636998326 -0600 @@ -98,14 +98,9 @@ register struct inode *inode; register struct socket *sock; - inode = get_empty_inode(); - if (!inode) + if(!(inode = new_inode(NULL, S_IFSOCK))) return NULL; - inode->i_mode = S_IFSOCK; - inode->i_op = &sock_inode_operations; - inode->i_gid = (__u8) current->egid; - sock = &inode->u.socket_i; sock->state = SS_UNCONNECTED; sock->flags = 0;