^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) // SPDX-License-Identifier: GPL-2.0
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) * linux/fs/minix/namei.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4) *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) * Copyright (C) 1991, 1992 Linus Torvalds
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) #include "minix.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) static int add_nondir(struct dentry *dentry, struct inode *inode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12) int err = minix_add_link(dentry, inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) if (!err) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) d_instantiate(dentry, inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) inode_dec_link_count(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) iput(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) static struct dentry *minix_lookup(struct inode * dir, struct dentry *dentry, unsigned int flags)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) struct inode * inode = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) ino_t ino;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) if (dentry->d_name.len > minix_sb(dir->i_sb)->s_namelen)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) return ERR_PTR(-ENAMETOOLONG);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) ino = minix_inode_by_name(dentry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) if (ino)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32) inode = minix_iget(dir->i_sb, ino);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) return d_splice_alias(inode, dentry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) static int minix_mknod(struct inode * dir, struct dentry *dentry, umode_t mode, dev_t rdev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) int error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) struct inode *inode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) if (!old_valid_dev(rdev))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 44) inode = minix_new_inode(dir, mode, &error);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 45)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 46) if (inode) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 47) minix_set_inode(inode, rdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 48) mark_inode_dirty(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 49) error = add_nondir(dentry, inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 50) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 51) return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 52) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 53)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 54) static int minix_tmpfile(struct inode *dir, struct dentry *dentry, umode_t mode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 55) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 56) int error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 57) struct inode *inode = minix_new_inode(dir, mode, &error);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 58) if (inode) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 59) minix_set_inode(inode, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 60) mark_inode_dirty(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 61) d_tmpfile(dentry, inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 62) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 63) return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 64) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 65)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 66) static int minix_create(struct inode *dir, struct dentry *dentry, umode_t mode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 67) bool excl)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 68) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 69) return minix_mknod(dir, dentry, mode, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 70) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 71)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 72) static int minix_symlink(struct inode * dir, struct dentry *dentry,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 73) const char * symname)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 74) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 75) int err = -ENAMETOOLONG;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 76) int i = strlen(symname)+1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 77) struct inode * inode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 78)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 79) if (i > dir->i_sb->s_blocksize)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 80) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 81)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 82) inode = minix_new_inode(dir, S_IFLNK | 0777, &err);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 83) if (!inode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 84) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 85)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 86) minix_set_inode(inode, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 87) err = page_symlink(inode, symname, i);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 88) if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 89) goto out_fail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 90)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 91) err = add_nondir(dentry, inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 92) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 93) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 94)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 95) out_fail:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 96) inode_dec_link_count(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 97) iput(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 98) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 99) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) static int minix_link(struct dentry * old_dentry, struct inode * dir,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) struct dentry *dentry)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) struct inode *inode = d_inode(old_dentry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) inode->i_ctime = current_time(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) inode_inc_link_count(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) ihold(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) return add_nondir(dentry, inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) static int minix_mkdir(struct inode * dir, struct dentry *dentry, umode_t mode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) struct inode * inode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) int err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) inode_inc_link_count(dir);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) inode = minix_new_inode(dir, S_IFDIR | mode, &err);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) if (!inode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) goto out_dir;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) minix_set_inode(inode, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) inode_inc_link_count(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) err = minix_make_empty(inode, dir);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) goto out_fail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) err = minix_add_link(dentry, inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) goto out_fail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) d_instantiate(dentry, inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) out_fail:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) inode_dec_link_count(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) inode_dec_link_count(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) iput(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) out_dir:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) inode_dec_link_count(dir);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 146) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 147)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 148) static int minix_unlink(struct inode * dir, struct dentry *dentry)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) int err = -ENOENT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) struct inode * inode = d_inode(dentry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) struct page * page;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) struct minix_dir_entry * de;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) de = minix_find_entry(dentry, &page);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) if (!de)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) goto end_unlink;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) err = minix_delete_entry(de, page);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) goto end_unlink;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) inode->i_ctime = dir->i_ctime;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) inode_dec_link_count(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) end_unlink:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) static int minix_rmdir(struct inode * dir, struct dentry *dentry)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) struct inode * inode = d_inode(dentry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) int err = -ENOTEMPTY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) if (minix_empty_dir(inode)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) err = minix_unlink(dir, dentry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) if (!err) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) inode_dec_link_count(dir);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) inode_dec_link_count(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 179) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 180) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 181) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) static int minix_rename(struct inode * old_dir, struct dentry *old_dentry,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) struct inode * new_dir, struct dentry *new_dentry,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) unsigned int flags)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) struct inode * old_inode = d_inode(old_dentry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) struct inode * new_inode = d_inode(new_dentry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) struct page * dir_page = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) struct minix_dir_entry * dir_de = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) struct page * old_page;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) struct minix_dir_entry * old_de;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) int err = -ENOENT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) if (flags & ~RENAME_NOREPLACE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) return -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) old_de = minix_find_entry(old_dentry, &old_page);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) if (!old_de)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) if (S_ISDIR(old_inode->i_mode)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) err = -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) dir_de = minix_dotdot(old_inode, &dir_page);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) if (!dir_de)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) goto out_old;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) if (new_inode) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) struct page * new_page;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) struct minix_dir_entry * new_de;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) err = -ENOTEMPTY;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) if (dir_de && !minix_empty_dir(new_inode))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) goto out_dir;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) err = -ENOENT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) new_de = minix_find_entry(new_dentry, &new_page);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) if (!new_de)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) goto out_dir;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) minix_set_link(new_de, new_page, old_inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) new_inode->i_ctime = current_time(new_inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) if (dir_de)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) drop_nlink(new_inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) inode_dec_link_count(new_inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) } else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) err = minix_add_link(new_dentry, old_inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) goto out_dir;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) if (dir_de)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) inode_inc_link_count(new_dir);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) minix_delete_entry(old_de, old_page);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) mark_inode_dirty(old_inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) if (dir_de) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) minix_set_link(dir_de, dir_page, new_dir);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) inode_dec_link_count(old_dir);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) out_dir:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) if (dir_de) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) kunmap(dir_page);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) put_page(dir_page);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) out_old:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) kunmap(old_page);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) put_page(old_page);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) * directories can handle most operations...
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) const struct inode_operations minix_dir_inode_operations = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) .create = minix_create,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) .lookup = minix_lookup,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) .link = minix_link,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) .unlink = minix_unlink,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) .symlink = minix_symlink,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) .mkdir = minix_mkdir,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) .rmdir = minix_rmdir,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) .mknod = minix_mknod,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) .rename = minix_rename,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) .getattr = minix_getattr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) .tmpfile = minix_tmpfile,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) };