1b2441318SGreg Kroah-Hartman // SPDX-License-Identifier: GPL-2.0 21da177e4SLinus Torvalds /* 31da177e4SLinus Torvalds * linux/fs/ext2/namei.c 41da177e4SLinus Torvalds * 51da177e4SLinus Torvalds * Rewrite to pagecache. Almost all code had been changed, so blame me 61da177e4SLinus Torvalds * if the things go wrong. Please, send bug reports to 71da177e4SLinus Torvalds * viro@parcelfarce.linux.theplanet.co.uk 81da177e4SLinus Torvalds * 91da177e4SLinus Torvalds * Stuff here is basically a glue between the VFS and generic UNIXish 101da177e4SLinus Torvalds * filesystem that keeps everything in pagecache. All knowledge of the 111da177e4SLinus Torvalds * directory layout is in fs/ext2/dir.c - it turned out to be easily separatable 121da177e4SLinus Torvalds * and it's easier to debug that way. In principle we might want to 131da177e4SLinus Torvalds * generalize that a bit and turn it into a library. Or not. 141da177e4SLinus Torvalds * 151da177e4SLinus Torvalds * The only non-static object here is ext2_dir_inode_operations. 161da177e4SLinus Torvalds * 171da177e4SLinus Torvalds * TODO: get rid of kmap() use, add readahead. 181da177e4SLinus Torvalds * 191da177e4SLinus Torvalds * Copyright (C) 1992, 1993, 1994, 1995 201da177e4SLinus Torvalds * Remy Card (card@masi.ibp.fr) 211da177e4SLinus Torvalds * Laboratoire MASI - Institut Blaise Pascal 221da177e4SLinus Torvalds * Universite Pierre et Marie Curie (Paris VI) 231da177e4SLinus Torvalds * 241da177e4SLinus Torvalds * from 251da177e4SLinus Torvalds * 261da177e4SLinus Torvalds * linux/fs/minix/namei.c 271da177e4SLinus Torvalds * 281da177e4SLinus Torvalds * Copyright (C) 1991, 1992 Linus Torvalds 291da177e4SLinus Torvalds * 301da177e4SLinus Torvalds * Big-endian to little-endian byte-swapping/bitmaps by 311da177e4SLinus Torvalds * David S. Miller (davem@caip.rutgers.edu), 1995 321da177e4SLinus Torvalds */ 331da177e4SLinus Torvalds 341da177e4SLinus Torvalds #include <linux/pagemap.h> 35907f4554SChristoph Hellwig #include <linux/quotaops.h> 361da177e4SLinus Torvalds #include "ext2.h" 371da177e4SLinus Torvalds #include "xattr.h" 381da177e4SLinus Torvalds #include "acl.h" 391da177e4SLinus Torvalds 401da177e4SLinus Torvalds static inline int ext2_add_nondir(struct dentry *dentry, struct inode *inode) 411da177e4SLinus Torvalds { 421da177e4SLinus Torvalds int err = ext2_add_link(dentry, inode); 431da177e4SLinus Torvalds if (!err) { 441e2e547aSAl Viro d_instantiate_new(dentry, inode); 451da177e4SLinus Torvalds return 0; 461da177e4SLinus Torvalds } 47a513b035SAlexey Dobriyan inode_dec_link_count(inode); 482e5afe54SAl Viro discard_new_inode(inode); 491da177e4SLinus Torvalds return err; 501da177e4SLinus Torvalds } 511da177e4SLinus Torvalds 521da177e4SLinus Torvalds /* 531da177e4SLinus Torvalds * Methods themselves. 541da177e4SLinus Torvalds */ 551da177e4SLinus Torvalds 5600cd8dd3SAl Viro static struct dentry *ext2_lookup(struct inode * dir, struct dentry *dentry, unsigned int flags) 571da177e4SLinus Torvalds { 581da177e4SLinus Torvalds struct inode * inode; 59a43850a3Szhangyi (F) ino_t ino; 60b4962091Szhangyi (F) int res; 611da177e4SLinus Torvalds 621da177e4SLinus Torvalds if (dentry->d_name.len > EXT2_NAME_LEN) 631da177e4SLinus Torvalds return ERR_PTR(-ENAMETOOLONG); 641da177e4SLinus Torvalds 65b4962091Szhangyi (F) res = ext2_inode_by_name(dir, &dentry->d_name, &ino); 66a43850a3Szhangyi (F) if (res) { 67a43850a3Szhangyi (F) if (res != -ENOENT) 68b4962091Szhangyi (F) return ERR_PTR(res); 691da177e4SLinus Torvalds inode = NULL; 70a43850a3Szhangyi (F) } else { 7152fcf703SDavid Howells inode = ext2_iget(dir->i_sb, ino); 72a9049376SAl Viro if (inode == ERR_PTR(-ESTALE)) { 734d6c13f8SBryan Donlan ext2_error(dir->i_sb, __func__, 744d6c13f8SBryan Donlan "deleted inode referenced: %lu", 75a4255e4cSHeiko Carstens (unsigned long) ino); 764d6c13f8SBryan Donlan return ERR_PTR(-EIO); 774d6c13f8SBryan Donlan } 784d6c13f8SBryan Donlan } 791da177e4SLinus Torvalds return d_splice_alias(inode, dentry); 801da177e4SLinus Torvalds } 811da177e4SLinus Torvalds 821da177e4SLinus Torvalds struct dentry *ext2_get_parent(struct dentry *child) 831da177e4SLinus Torvalds { 84a43850a3Szhangyi (F) ino_t ino; 85b4962091Szhangyi (F) int res; 86b4962091Szhangyi (F) 8780e5d1ffSAl Viro res = ext2_inode_by_name(d_inode(child), &dotdot_name, &ino); 88b4962091Szhangyi (F) if (res) 89b4962091Szhangyi (F) return ERR_PTR(res); 90a43850a3Szhangyi (F) 91fc64005cSAl Viro return d_obtain_alias(ext2_iget(child->d_sb, ino)); 921da177e4SLinus Torvalds } 931da177e4SLinus Torvalds 941da177e4SLinus Torvalds /* 951da177e4SLinus Torvalds * By the time this is called, we already have created 961da177e4SLinus Torvalds * the directory cache entry for the new file, but it 971da177e4SLinus Torvalds * is so far negative - it has no inode. 981da177e4SLinus Torvalds * 991da177e4SLinus Torvalds * If the create succeeds, we fill in the inode information 1001da177e4SLinus Torvalds * with d_instantiate(). 1011da177e4SLinus Torvalds */ 102549c7297SChristian Brauner static int ext2_create (struct user_namespace * mnt_userns, 103549c7297SChristian Brauner struct inode * dir, struct dentry * dentry, 104549c7297SChristian Brauner umode_t mode, bool excl) 1051da177e4SLinus Torvalds { 106907f4554SChristoph Hellwig struct inode *inode; 107c2edb305SJan Kara int err; 108907f4554SChristoph Hellwig 109c2edb305SJan Kara err = dquot_initialize(dir); 110c2edb305SJan Kara if (err) 111c2edb305SJan Kara return err; 112907f4554SChristoph Hellwig 1132a7dba39SEric Paris inode = ext2_new_inode(dir, mode, &dentry->d_name); 114907f4554SChristoph Hellwig if (IS_ERR(inode)) 115907f4554SChristoph Hellwig return PTR_ERR(inode); 116907f4554SChristoph Hellwig 117fb094c90SDan Williams ext2_set_file_ops(inode); 1181da177e4SLinus Torvalds mark_inode_dirty(inode); 119907f4554SChristoph Hellwig return ext2_add_nondir(dentry, inode); 1201da177e4SLinus Torvalds } 1211da177e4SLinus Torvalds 122549c7297SChristian Brauner static int ext2_tmpfile(struct user_namespace *mnt_userns, struct inode *dir, 123549c7297SChristian Brauner struct dentry *dentry, umode_t mode) 12460545d0dSAl Viro { 12560545d0dSAl Viro struct inode *inode = ext2_new_inode(dir, mode, NULL); 12660545d0dSAl Viro if (IS_ERR(inode)) 12760545d0dSAl Viro return PTR_ERR(inode); 12860545d0dSAl Viro 129fb094c90SDan Williams ext2_set_file_ops(inode); 13060545d0dSAl Viro mark_inode_dirty(inode); 13160545d0dSAl Viro d_tmpfile(dentry, inode); 13260545d0dSAl Viro unlock_new_inode(inode); 13360545d0dSAl Viro return 0; 13460545d0dSAl Viro } 13560545d0dSAl Viro 136549c7297SChristian Brauner static int ext2_mknod (struct user_namespace * mnt_userns, struct inode * dir, 137549c7297SChristian Brauner struct dentry *dentry, umode_t mode, dev_t rdev) 1381da177e4SLinus Torvalds { 1391da177e4SLinus Torvalds struct inode * inode; 1401da177e4SLinus Torvalds int err; 1411da177e4SLinus Torvalds 142c2edb305SJan Kara err = dquot_initialize(dir); 143c2edb305SJan Kara if (err) 144c2edb305SJan Kara return err; 145907f4554SChristoph Hellwig 1462a7dba39SEric Paris inode = ext2_new_inode (dir, mode, &dentry->d_name); 1471da177e4SLinus Torvalds err = PTR_ERR(inode); 1481da177e4SLinus Torvalds if (!IS_ERR(inode)) { 1491da177e4SLinus Torvalds init_special_inode(inode, inode->i_mode, rdev); 1501da177e4SLinus Torvalds inode->i_op = &ext2_special_inode_operations; 1511da177e4SLinus Torvalds mark_inode_dirty(inode); 1521da177e4SLinus Torvalds err = ext2_add_nondir(dentry, inode); 1531da177e4SLinus Torvalds } 1541da177e4SLinus Torvalds return err; 1551da177e4SLinus Torvalds } 1561da177e4SLinus Torvalds 157549c7297SChristian Brauner static int ext2_symlink (struct user_namespace * mnt_userns, struct inode * dir, 158549c7297SChristian Brauner struct dentry * dentry, const char * symname) 1591da177e4SLinus Torvalds { 1601da177e4SLinus Torvalds struct super_block * sb = dir->i_sb; 1611da177e4SLinus Torvalds int err = -ENAMETOOLONG; 1621da177e4SLinus Torvalds unsigned l = strlen(symname)+1; 1631da177e4SLinus Torvalds struct inode * inode; 1641da177e4SLinus Torvalds 1651da177e4SLinus Torvalds if (l > sb->s_blocksize) 1661da177e4SLinus Torvalds goto out; 1671da177e4SLinus Torvalds 168c2edb305SJan Kara err = dquot_initialize(dir); 169c2edb305SJan Kara if (err) 170c2edb305SJan Kara goto out; 171907f4554SChristoph Hellwig 1722a7dba39SEric Paris inode = ext2_new_inode (dir, S_IFLNK | S_IRWXUGO, &dentry->d_name); 1731da177e4SLinus Torvalds err = PTR_ERR(inode); 1741da177e4SLinus Torvalds if (IS_ERR(inode)) 1751da177e4SLinus Torvalds goto out; 1761da177e4SLinus Torvalds 1771da177e4SLinus Torvalds if (l > sizeof (EXT2_I(inode)->i_data)) { 1781da177e4SLinus Torvalds /* slow symlink */ 1791da177e4SLinus Torvalds inode->i_op = &ext2_symlink_inode_operations; 18021fc61c7SAl Viro inode_nohighmem(inode); 1811da177e4SLinus Torvalds if (test_opt(inode->i_sb, NOBH)) 1821da177e4SLinus Torvalds inode->i_mapping->a_ops = &ext2_nobh_aops; 1831da177e4SLinus Torvalds else 1841da177e4SLinus Torvalds inode->i_mapping->a_ops = &ext2_aops; 1851da177e4SLinus Torvalds err = page_symlink(inode, symname, l); 1861da177e4SLinus Torvalds if (err) 1871da177e4SLinus Torvalds goto out_fail; 1881da177e4SLinus Torvalds } else { 1891da177e4SLinus Torvalds /* fast symlink */ 1901da177e4SLinus Torvalds inode->i_op = &ext2_fast_symlink_inode_operations; 191cbe0fa38SAl Viro inode->i_link = (char*)EXT2_I(inode)->i_data; 192cbe0fa38SAl Viro memcpy(inode->i_link, symname, l); 1931da177e4SLinus Torvalds inode->i_size = l-1; 1941da177e4SLinus Torvalds } 1951da177e4SLinus Torvalds mark_inode_dirty(inode); 1961da177e4SLinus Torvalds 1971da177e4SLinus Torvalds err = ext2_add_nondir(dentry, inode); 1981da177e4SLinus Torvalds out: 1991da177e4SLinus Torvalds return err; 2001da177e4SLinus Torvalds 2011da177e4SLinus Torvalds out_fail: 202a513b035SAlexey Dobriyan inode_dec_link_count(inode); 2032e5afe54SAl Viro discard_new_inode(inode); 2041da177e4SLinus Torvalds goto out; 2051da177e4SLinus Torvalds } 2061da177e4SLinus Torvalds 2071da177e4SLinus Torvalds static int ext2_link (struct dentry * old_dentry, struct inode * dir, 2081da177e4SLinus Torvalds struct dentry *dentry) 2091da177e4SLinus Torvalds { 2102b0143b5SDavid Howells struct inode *inode = d_inode(old_dentry); 21141080b5aSAl Viro int err; 2121da177e4SLinus Torvalds 213c2edb305SJan Kara err = dquot_initialize(dir); 214c2edb305SJan Kara if (err) 215c2edb305SJan Kara return err; 216907f4554SChristoph Hellwig 21702027d42SDeepa Dinamani inode->i_ctime = current_time(inode); 218a513b035SAlexey Dobriyan inode_inc_link_count(inode); 2197de9c6eeSAl Viro ihold(inode); 2201da177e4SLinus Torvalds 22141080b5aSAl Viro err = ext2_add_link(dentry, inode); 22241080b5aSAl Viro if (!err) { 22341080b5aSAl Viro d_instantiate(dentry, inode); 22441080b5aSAl Viro return 0; 22541080b5aSAl Viro } 22641080b5aSAl Viro inode_dec_link_count(inode); 22741080b5aSAl Viro iput(inode); 22841080b5aSAl Viro return err; 2291da177e4SLinus Torvalds } 2301da177e4SLinus Torvalds 231549c7297SChristian Brauner static int ext2_mkdir(struct user_namespace * mnt_userns, 232549c7297SChristian Brauner struct inode * dir, struct dentry * dentry, umode_t mode) 2331da177e4SLinus Torvalds { 2341da177e4SLinus Torvalds struct inode * inode; 2358de52778SAl Viro int err; 2361da177e4SLinus Torvalds 237c2edb305SJan Kara err = dquot_initialize(dir); 238c2edb305SJan Kara if (err) 239c2edb305SJan Kara return err; 240907f4554SChristoph Hellwig 241a513b035SAlexey Dobriyan inode_inc_link_count(dir); 2421da177e4SLinus Torvalds 2432a7dba39SEric Paris inode = ext2_new_inode(dir, S_IFDIR | mode, &dentry->d_name); 2441da177e4SLinus Torvalds err = PTR_ERR(inode); 2451da177e4SLinus Torvalds if (IS_ERR(inode)) 2461da177e4SLinus Torvalds goto out_dir; 2471da177e4SLinus Torvalds 2481da177e4SLinus Torvalds inode->i_op = &ext2_dir_inode_operations; 2491da177e4SLinus Torvalds inode->i_fop = &ext2_dir_operations; 2501da177e4SLinus Torvalds if (test_opt(inode->i_sb, NOBH)) 2511da177e4SLinus Torvalds inode->i_mapping->a_ops = &ext2_nobh_aops; 2521da177e4SLinus Torvalds else 2531da177e4SLinus Torvalds inode->i_mapping->a_ops = &ext2_aops; 2541da177e4SLinus Torvalds 255a513b035SAlexey Dobriyan inode_inc_link_count(inode); 2561da177e4SLinus Torvalds 2571da177e4SLinus Torvalds err = ext2_make_empty(inode, dir); 2581da177e4SLinus Torvalds if (err) 2591da177e4SLinus Torvalds goto out_fail; 2601da177e4SLinus Torvalds 2611da177e4SLinus Torvalds err = ext2_add_link(dentry, inode); 2621da177e4SLinus Torvalds if (err) 2631da177e4SLinus Torvalds goto out_fail; 2641da177e4SLinus Torvalds 2651e2e547aSAl Viro d_instantiate_new(dentry, inode); 2661da177e4SLinus Torvalds out: 2671da177e4SLinus Torvalds return err; 2681da177e4SLinus Torvalds 2691da177e4SLinus Torvalds out_fail: 270a513b035SAlexey Dobriyan inode_dec_link_count(inode); 271a513b035SAlexey Dobriyan inode_dec_link_count(inode); 2722e5afe54SAl Viro discard_new_inode(inode); 2731da177e4SLinus Torvalds out_dir: 274a513b035SAlexey Dobriyan inode_dec_link_count(dir); 2751da177e4SLinus Torvalds goto out; 2761da177e4SLinus Torvalds } 2771da177e4SLinus Torvalds 2781da177e4SLinus Torvalds static int ext2_unlink(struct inode * dir, struct dentry *dentry) 2791da177e4SLinus Torvalds { 2802b0143b5SDavid Howells struct inode * inode = d_inode(dentry); 2811da177e4SLinus Torvalds struct ext2_dir_entry_2 * de; 2821da177e4SLinus Torvalds struct page * page; 283782b76d7SIra Weiny void *page_addr; 284c2edb305SJan Kara int err; 2851da177e4SLinus Torvalds 286c2edb305SJan Kara err = dquot_initialize(dir); 287c2edb305SJan Kara if (err) 288c2edb305SJan Kara goto out; 289907f4554SChristoph Hellwig 290782b76d7SIra Weiny de = ext2_find_entry(dir, &dentry->d_name, &page, &page_addr); 291b4962091Szhangyi (F) if (IS_ERR(de)) { 292b4962091Szhangyi (F) err = PTR_ERR(de); 293b4962091Szhangyi (F) goto out; 294b4962091Szhangyi (F) } 2951da177e4SLinus Torvalds 296*728d392fSJavier Pello err = ext2_delete_entry (de, page, page_addr); 297782b76d7SIra Weiny ext2_put_page(page, page_addr); 2981da177e4SLinus Torvalds if (err) 2991da177e4SLinus Torvalds goto out; 3001da177e4SLinus Torvalds 3011da177e4SLinus Torvalds inode->i_ctime = dir->i_ctime; 302a513b035SAlexey Dobriyan inode_dec_link_count(inode); 3031da177e4SLinus Torvalds err = 0; 3041da177e4SLinus Torvalds out: 3051da177e4SLinus Torvalds return err; 3061da177e4SLinus Torvalds } 3071da177e4SLinus Torvalds 3081da177e4SLinus Torvalds static int ext2_rmdir (struct inode * dir, struct dentry *dentry) 3091da177e4SLinus Torvalds { 3102b0143b5SDavid Howells struct inode * inode = d_inode(dentry); 3111da177e4SLinus Torvalds int err = -ENOTEMPTY; 3121da177e4SLinus Torvalds 3131da177e4SLinus Torvalds if (ext2_empty_dir(inode)) { 3141da177e4SLinus Torvalds err = ext2_unlink(dir, dentry); 3151da177e4SLinus Torvalds if (!err) { 3161da177e4SLinus Torvalds inode->i_size = 0; 317a513b035SAlexey Dobriyan inode_dec_link_count(inode); 318a513b035SAlexey Dobriyan inode_dec_link_count(dir); 3191da177e4SLinus Torvalds } 3201da177e4SLinus Torvalds } 3211da177e4SLinus Torvalds return err; 3221da177e4SLinus Torvalds } 3231da177e4SLinus Torvalds 324549c7297SChristian Brauner static int ext2_rename (struct user_namespace * mnt_userns, 325549c7297SChristian Brauner struct inode * old_dir, struct dentry * old_dentry, 326f03b8ad8SMiklos Szeredi struct inode * new_dir, struct dentry * new_dentry, 327f03b8ad8SMiklos Szeredi unsigned int flags) 3281da177e4SLinus Torvalds { 3292b0143b5SDavid Howells struct inode * old_inode = d_inode(old_dentry); 3302b0143b5SDavid Howells struct inode * new_inode = d_inode(new_dentry); 3311da177e4SLinus Torvalds struct page * dir_page = NULL; 332782b76d7SIra Weiny void *dir_page_addr; 3331da177e4SLinus Torvalds struct ext2_dir_entry_2 * dir_de = NULL; 3341da177e4SLinus Torvalds struct page * old_page; 335782b76d7SIra Weiny void *old_page_addr; 3361da177e4SLinus Torvalds struct ext2_dir_entry_2 * old_de; 337c2edb305SJan Kara int err; 3381da177e4SLinus Torvalds 339f03b8ad8SMiklos Szeredi if (flags & ~RENAME_NOREPLACE) 340f03b8ad8SMiklos Szeredi return -EINVAL; 341f03b8ad8SMiklos Szeredi 342c2edb305SJan Kara err = dquot_initialize(old_dir); 343c2edb305SJan Kara if (err) 344c2edb305SJan Kara goto out; 345c2edb305SJan Kara 346c2edb305SJan Kara err = dquot_initialize(new_dir); 347c2edb305SJan Kara if (err) 348c2edb305SJan Kara goto out; 349907f4554SChristoph Hellwig 350782b76d7SIra Weiny old_de = ext2_find_entry(old_dir, &old_dentry->d_name, &old_page, 351782b76d7SIra Weiny &old_page_addr); 352b4962091Szhangyi (F) if (IS_ERR(old_de)) { 353b4962091Szhangyi (F) err = PTR_ERR(old_de); 354b4962091Szhangyi (F) goto out; 355b4962091Szhangyi (F) } 3561da177e4SLinus Torvalds 3571da177e4SLinus Torvalds if (S_ISDIR(old_inode->i_mode)) { 3581da177e4SLinus Torvalds err = -EIO; 359782b76d7SIra Weiny dir_de = ext2_dotdot(old_inode, &dir_page, &dir_page_addr); 3601da177e4SLinus Torvalds if (!dir_de) 3611da177e4SLinus Torvalds goto out_old; 3621da177e4SLinus Torvalds } 3631da177e4SLinus Torvalds 3641da177e4SLinus Torvalds if (new_inode) { 365782b76d7SIra Weiny void *page_addr; 3661da177e4SLinus Torvalds struct page *new_page; 3671da177e4SLinus Torvalds struct ext2_dir_entry_2 *new_de; 3681da177e4SLinus Torvalds 3691da177e4SLinus Torvalds err = -ENOTEMPTY; 3701da177e4SLinus Torvalds if (dir_de && !ext2_empty_dir (new_inode)) 3711da177e4SLinus Torvalds goto out_dir; 3721da177e4SLinus Torvalds 373782b76d7SIra Weiny new_de = ext2_find_entry(new_dir, &new_dentry->d_name, 374782b76d7SIra Weiny &new_page, &page_addr); 375b4962091Szhangyi (F) if (IS_ERR(new_de)) { 376b4962091Szhangyi (F) err = PTR_ERR(new_de); 377b4962091Szhangyi (F) goto out_dir; 378b4962091Szhangyi (F) } 379782b76d7SIra Weiny ext2_set_link(new_dir, new_de, new_page, page_addr, old_inode, 1); 380782b76d7SIra Weiny ext2_put_page(new_page, page_addr); 38102027d42SDeepa Dinamani new_inode->i_ctime = current_time(new_inode); 3821da177e4SLinus Torvalds if (dir_de) 3839a53c3a7SDave Hansen drop_nlink(new_inode); 384a513b035SAlexey Dobriyan inode_dec_link_count(new_inode); 3851da177e4SLinus Torvalds } else { 3861da177e4SLinus Torvalds err = ext2_add_link(new_dentry, old_inode); 387e8a80c6fSJosh Hunt if (err) 3881da177e4SLinus Torvalds goto out_dir; 3891da177e4SLinus Torvalds if (dir_de) 390a513b035SAlexey Dobriyan inode_inc_link_count(new_dir); 3911da177e4SLinus Torvalds } 3921da177e4SLinus Torvalds 3931da177e4SLinus Torvalds /* 3941da177e4SLinus Torvalds * Like most other Unix systems, set the ctime for inodes on a 3951da177e4SLinus Torvalds * rename. 3961da177e4SLinus Torvalds */ 39702027d42SDeepa Dinamani old_inode->i_ctime = current_time(old_inode); 398e8a80c6fSJosh Hunt mark_inode_dirty(old_inode); 3991da177e4SLinus Torvalds 400*728d392fSJavier Pello ext2_delete_entry(old_de, old_page, old_page_addr); 4011da177e4SLinus Torvalds 4021da177e4SLinus Torvalds if (dir_de) { 40339fe7557SJan Kara if (old_dir != new_dir) 404782b76d7SIra Weiny ext2_set_link(old_inode, dir_de, dir_page, 405782b76d7SIra Weiny dir_page_addr, new_dir, 0); 406e2ebb123SIra Weiny 407782b76d7SIra Weiny ext2_put_page(dir_page, dir_page_addr); 408a513b035SAlexey Dobriyan inode_dec_link_count(old_dir); 4091da177e4SLinus Torvalds } 4101da177e4SLinus Torvalds 411782b76d7SIra Weiny ext2_put_page(old_page, old_page_addr); 412782b76d7SIra Weiny return 0; 4131da177e4SLinus Torvalds 4141da177e4SLinus Torvalds out_dir: 415a6fbd0abSIra Weiny if (dir_de) 416782b76d7SIra Weiny ext2_put_page(dir_page, dir_page_addr); 4171da177e4SLinus Torvalds out_old: 418782b76d7SIra Weiny ext2_put_page(old_page, old_page_addr); 4191da177e4SLinus Torvalds out: 4201da177e4SLinus Torvalds return err; 4211da177e4SLinus Torvalds } 4221da177e4SLinus Torvalds 423754661f1SArjan van de Ven const struct inode_operations ext2_dir_inode_operations = { 4241da177e4SLinus Torvalds .create = ext2_create, 4251da177e4SLinus Torvalds .lookup = ext2_lookup, 4261da177e4SLinus Torvalds .link = ext2_link, 4271da177e4SLinus Torvalds .unlink = ext2_unlink, 4281da177e4SLinus Torvalds .symlink = ext2_symlink, 4291da177e4SLinus Torvalds .mkdir = ext2_mkdir, 4301da177e4SLinus Torvalds .rmdir = ext2_rmdir, 4311da177e4SLinus Torvalds .mknod = ext2_mknod, 4321da177e4SLinus Torvalds .rename = ext2_rename, 4331da177e4SLinus Torvalds .listxattr = ext2_listxattr, 43493bc420eSyangerkun .getattr = ext2_getattr, 4351da177e4SLinus Torvalds .setattr = ext2_setattr, 4364e34e719SChristoph Hellwig .get_acl = ext2_get_acl, 43764e178a7SChristoph Hellwig .set_acl = ext2_set_acl, 43860545d0dSAl Viro .tmpfile = ext2_tmpfile, 439aba405e3SMiklos Szeredi .fileattr_get = ext2_fileattr_get, 440aba405e3SMiklos Szeredi .fileattr_set = ext2_fileattr_set, 4411da177e4SLinus Torvalds }; 4421da177e4SLinus Torvalds 443754661f1SArjan van de Ven const struct inode_operations ext2_special_inode_operations = { 4441da177e4SLinus Torvalds .listxattr = ext2_listxattr, 44593bc420eSyangerkun .getattr = ext2_getattr, 4461da177e4SLinus Torvalds .setattr = ext2_setattr, 4474e34e719SChristoph Hellwig .get_acl = ext2_get_acl, 44864e178a7SChristoph Hellwig .set_acl = ext2_set_acl, 4491da177e4SLinus Torvalds }; 450