static int sysv_symlink(struct inode * dir, struct dentry * dentry, const char * symname) { int err = -ENAMETOOLONG; int l = strlen(symname)+1; struct inode * inode; if (l > dir->i_sb->s_blocksize) goto out; inode = sysv_new_inode(dir, S_IFLNK|0777); err = PTR_ERR(inode); if (IS_ERR(inode)) goto out; sysv_set_inode(inode, 0); err = page_symlink(inode, symname, l); if (err) goto out_fail; mark_inode_dirty(inode); err = add_nondir(dentry, inode); out: return err; out_fail: inode_dec_link_count(inode); iput(inode); goto out; }
static int sysv_mknod(struct inode * dir, struct dentry * dentry, int mode, int rdev) { int error; struct inode * inode; struct buffer_head * bh; struct sysv_dir_entry * de; bh = sysv_find_entry(dir, dentry->d_name.name, dentry->d_name.len, &de); if (bh) { brelse(bh); return -EEXIST; } inode = sysv_new_inode(dir); if (!inode) return -ENOSPC; inode->i_uid = current->fsuid; init_special_inode(inode, mode, rdev); mark_inode_dirty(inode); error = sysv_add_entry(dir, dentry->d_name.name, dentry->d_name.len, &bh, &de); if (error) { inode->i_nlink--; mark_inode_dirty(inode); iput(inode); return error; } de->inode = inode->i_ino; mark_buffer_dirty(bh); brelse(bh); d_instantiate(dentry, inode); return 0; }
static int sysv_create(struct inode * dir, struct dentry * dentry, int mode) { int error; struct inode * inode; struct buffer_head * bh; struct sysv_dir_entry * de; inode = sysv_new_inode(dir); if (!inode) return -ENOSPC; inode->i_op = &sysv_file_inode_operations; inode->i_fop = &sysv_file_operations; inode->i_mapping->a_ops = &sysv_aops; inode->i_mode = mode; mark_inode_dirty(inode); error = sysv_add_entry(dir, dentry->d_name.name, dentry->d_name.len, &bh, &de); if (error) { inode->i_nlink--; mark_inode_dirty(inode); iput(inode); return error; } de->inode = inode->i_ino; mark_buffer_dirty(bh); brelse(bh); d_instantiate(dentry, inode); return 0; }
int sysv_symlink(struct inode * dir, struct dentry * dentry, const char * symname) { struct sysv_dir_entry * de; struct inode * inode; struct buffer_head * name_block; char * name_block_data; struct super_block * sb; int i; char c; struct buffer_head * bh; if (!(inode = sysv_new_inode(dir))) return -ENOSPC; inode->i_mode = S_IFLNK | 0777; inode->i_op = &sysv_symlink_inode_operations; name_block = sysv_file_bread(inode, 0, 1); if (!name_block) { inode->i_nlink--; mark_inode_dirty(inode); iput(inode); return -ENOSPC; } sb = inode->i_sb; name_block_data = name_block->b_data; i = 0; while (i < sb->sv_block_size_1 && (c = *(symname++))) name_block_data[i++] = c; name_block_data[i] = 0; mark_buffer_dirty(name_block, 1); brelse(name_block); inode->i_size = i; mark_inode_dirty(inode); bh = sysv_find_entry(dir, dentry->d_name.name, dentry->d_name.len, &de); if (bh) { inode->i_nlink--; mark_inode_dirty(inode); iput(inode); brelse(bh); return -EEXIST; } i = sysv_add_entry(dir, dentry->d_name.name, dentry->d_name.len, &bh, &de); if (i) { inode->i_nlink--; mark_inode_dirty(inode); iput(inode); return i; } de->inode = inode->i_ino; mark_buffer_dirty(bh, 1); brelse(bh); d_instantiate(dentry, inode); return 0; }
int sysv_mkdir(struct inode * dir, struct dentry *dentry, int mode) { int error; struct inode * inode; struct buffer_head * bh, *dir_block; struct sysv_dir_entry * de; if (!dir) return -EINVAL; bh = sysv_find_entry(dir, dentry->d_name.name, dentry->d_name.len, &de); if (bh) { brelse(bh); return -EEXIST; } if (dir->i_nlink >= dir->i_sb->sv_link_max) return -EMLINK; inode = sysv_new_inode(dir); if (!inode) return -ENOSPC; inode->i_op = &sysv_dir_inode_operations; inode->i_size = 2 * SYSV_DIRSIZE; dir_block = sysv_file_bread(inode,0,1); if (!dir_block) { inode->i_nlink--; mark_inode_dirty(inode); iput(inode); return -ENOSPC; } de = (struct sysv_dir_entry *) (dir_block->b_data + 0*SYSV_DIRSIZE); de->inode = inode->i_ino; strcpy(de->name,"."); /* rest of de->name is zero, see sysv_new_block */ de = (struct sysv_dir_entry *) (dir_block->b_data + 1*SYSV_DIRSIZE); de->inode = dir->i_ino; strcpy(de->name,".."); /* rest of de->name is zero, see sysv_new_block */ inode->i_nlink = 2; mark_buffer_dirty(dir_block, 1); brelse(dir_block); inode->i_mode = S_IFDIR | (mode & 0777 & ~current->fs->umask); if (dir->i_mode & S_ISGID) inode->i_mode |= S_ISGID; mark_inode_dirty(inode); error = sysv_add_entry(dir, dentry->d_name.name, dentry->d_name.len, &bh, &de); if (error) { inode->i_nlink=0; iput(inode); return error; } de->inode = inode->i_ino; mark_buffer_dirty(bh, 1); dir->i_nlink++; mark_inode_dirty(dir); brelse(bh); d_instantiate(dentry, inode); return 0; }
static int sysv_mknod(struct inode * dir, struct dentry * dentry, int mode, int rdev) { struct inode * inode = sysv_new_inode(dir, mode); int err = PTR_ERR(inode); if (!IS_ERR(inode)) { sysv_set_inode(inode, rdev); mark_inode_dirty(inode); err = add_nondir(dentry, inode); } return err; }
int sysv_mknod(struct inode * dir, struct dentry * dentry, int mode, int rdev) { int error; struct inode * inode; struct buffer_head * bh; struct sysv_dir_entry * de; if (!dir) return -ENOENT; bh = sysv_find_entry(dir, dentry->d_name.name, dentry->d_name.len, &de); if (bh) { brelse(bh); return -EEXIST; } inode = sysv_new_inode(dir); if (!inode) return -ENOSPC; inode->i_uid = current->fsuid; inode->i_mode = mode; inode->i_op = NULL; if (S_ISREG(inode->i_mode)) inode->i_op = &sysv_file_inode_operations; else if (S_ISCHR(inode->i_mode)) inode->i_op = &chrdev_inode_operations; else if (S_ISBLK(inode->i_mode)) inode->i_op = &blkdev_inode_operations; else if (S_ISFIFO(inode->i_mode)) init_fifo(inode); if (S_ISBLK(mode) || S_ISCHR(mode)) inode->i_rdev = to_kdev_t(rdev); mark_inode_dirty(inode); error = sysv_add_entry(dir, dentry->d_name.name, dentry->d_name.len, &bh, &de); if (error) { inode->i_nlink--; mark_inode_dirty(inode); iput(inode); return error; } de->inode = inode->i_ino; mark_buffer_dirty(bh, 1); brelse(bh); d_instantiate(dentry, inode); return 0; }
static int sysv_mknod(struct inode * dir, struct dentry * dentry, umode_t mode, dev_t rdev) { struct inode * inode; int err; if (!old_valid_dev(rdev)) return -EINVAL; inode = sysv_new_inode(dir, mode); err = PTR_ERR(inode); if (!IS_ERR(inode)) { sysv_set_inode(inode, rdev); mark_inode_dirty(inode); err = add_nondir(dentry, inode); } return err; }
static int sysv_symlink(struct inode * dir, struct dentry * dentry, const char * symname) { struct inode * inode; struct sysv_dir_entry * de; struct buffer_head * bh; int err; int l; err = -ENAMETOOLONG; l = strlen(symname)+1; if (l > dir->i_sb->sv_block_size_1) goto out; err = -ENOSPC; if (!(inode = sysv_new_inode(dir))) goto out; inode->i_mode = S_IFLNK | 0777; inode->i_op = &sysv_symlink_inode_operations; inode->i_mapping->a_ops = &sysv_aops; err = block_symlink(inode, symname, l); if (err) goto out_no_entry; mark_inode_dirty(inode); err = sysv_add_entry(dir, dentry->d_name.name, dentry->d_name.len, &bh, &de); if (err) goto out_no_entry; de->inode = inode->i_ino; mark_buffer_dirty(bh); brelse(bh); d_instantiate(dentry, inode); out: return err; out_no_entry: inode->i_nlink--; mark_inode_dirty(inode); iput(inode); goto out; }
static int sysv_mkdir(struct inode * dir, struct dentry *dentry, int mode) { struct inode * inode; int err = -EMLINK; if (dir->i_nlink >= SYSV_SB(dir->i_sb)->s_link_max) goto out; inode_inc_link_count(dir); inode = sysv_new_inode(dir, S_IFDIR|mode); err = PTR_ERR(inode); if (IS_ERR(inode)) goto out_dir; sysv_set_inode(inode, 0); inode_inc_link_count(inode); err = sysv_make_empty(inode, dir); if (err) goto out_fail; err = sysv_add_link(dentry, inode); if (err) goto out_fail; d_instantiate(dentry, inode); out: return err; out_fail: inode_dec_link_count(inode); inode_dec_link_count(inode); iput(inode); out_dir: inode_dec_link_count(dir); goto out; }