VisionFive2 Linux kernel

StarFive Tech Linux Kernel for VisionFive (JH7110) boards (mirror)

More than 9999 Commits   32 Branches   54 Tags
b24413180f560 (Greg Kroah-Hartman   2017-11-01 15:07:57 +0100   1) // SPDX-License-Identifier: GPL-2.0
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700   2) /*
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700   3)  *  linux/fs/hfsplus/dir.c
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700   4)  *
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700   5)  * Copyright (C) 2001
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700   6)  * Brad Boyer (flar@allandria.com)
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700   7)  * (C) 2003 Ardis Technologies <roman@ardistech.com>
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700   8)  *
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700   9)  * Handling of directories
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700  10)  */
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700  11) 
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700  12) #include <linux/errno.h>
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700  13) #include <linux/fs.h>
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700  14) #include <linux/slab.h>
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700  15) #include <linux/random.h>
017f8da43e92d (Hin-Tak Leung        2014-06-06 14:36:21 -0700  16) #include <linux/nls.h>
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700  17) 
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700  18) #include "hfsplus_fs.h"
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700  19) #include "hfsplus_raw.h"
324ef39a8a4f6 (Vyacheslav Dubeyko   2013-02-27 17:03:04 -0800  20) #include "xattr.h"
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700  21) 
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700  22) static inline void hfsplus_instantiate(struct dentry *dentry,
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700  23) 				       struct inode *inode, u32 cnid)
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700  24) {
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700  25) 	dentry->d_fsdata = (void *)(unsigned long)cnid;
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700  26) 	d_instantiate(dentry, inode);
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700  27) }
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700  28) 
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700  29) /* Find the entry inside dir named dentry->d_name */
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700  30) static struct dentry *hfsplus_lookup(struct inode *dir, struct dentry *dentry,
00cd8dd3bf95f (Al Viro              2012-06-10 17:13:09 -0400  31) 				     unsigned int flags)
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700  32) {
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700  33) 	struct inode *inode = NULL;
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700  34) 	struct hfs_find_data fd;
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700  35) 	struct super_block *sb;
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700  36) 	hfsplus_cat_entry entry;
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700  37) 	int err;
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700  38) 	u32 cnid, linkid = 0;
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700  39) 	u16 type;
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700  40) 
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700  41) 	sb = dir->i_sb;
d45bce8faf555 (Duane Griffin        2007-07-15 23:41:23 -0700  42) 
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700  43) 	dentry->d_fsdata = NULL;
5bd9d99d107c5 (Alexey Khoroshilov   2011-07-06 02:29:59 +0400  44) 	err = hfs_find_init(HFSPLUS_SB(sb)->cat_tree, &fd);
5bd9d99d107c5 (Alexey Khoroshilov   2011-07-06 02:29:59 +0400  45) 	if (err)
5bd9d99d107c5 (Alexey Khoroshilov   2011-07-06 02:29:59 +0400  46) 		return ERR_PTR(err);
89ac9b4d3d1a0 (Sougata Santra       2014-12-18 16:17:12 -0800  47) 	err = hfsplus_cat_build_key(sb, fd.search_key, dir->i_ino,
89ac9b4d3d1a0 (Sougata Santra       2014-12-18 16:17:12 -0800  48) 			&dentry->d_name);
89ac9b4d3d1a0 (Sougata Santra       2014-12-18 16:17:12 -0800  49) 	if (unlikely(err < 0))
89ac9b4d3d1a0 (Sougata Santra       2014-12-18 16:17:12 -0800  50) 		goto fail;
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700  51) again:
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700  52) 	err = hfs_brec_read(&fd, &entry, sizeof(entry));
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700  53) 	if (err) {
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700  54) 		if (err == -ENOENT) {
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700  55) 			hfs_find_exit(&fd);
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700  56) 			/* No such entry */
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700  57) 			inode = NULL;
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700  58) 			goto out;
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700  59) 		}
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700  60) 		goto fail;
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700  61) 	}
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700  62) 	type = be16_to_cpu(entry.type);
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700  63) 	if (type == HFSPLUS_FOLDER) {
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700  64) 		if (fd.entrylength < sizeof(struct hfsplus_cat_folder)) {
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700  65) 			err = -EIO;
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700  66) 			goto fail;
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700  67) 		}
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700  68) 		cnid = be32_to_cpu(entry.folder.id);
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700  69) 		dentry->d_fsdata = (void *)(unsigned long)cnid;
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700  70) 	} else if (type == HFSPLUS_FILE) {
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700  71) 		if (fd.entrylength < sizeof(struct hfsplus_cat_file)) {
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700  72) 			err = -EIO;
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700  73) 			goto fail;
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700  74) 		}
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700  75) 		cnid = be32_to_cpu(entry.file.id);
2753cc281c9a0 (Anton Salikhmetov    2010-12-16 18:08:38 +0200  76) 		if (entry.file.user_info.fdType ==
2753cc281c9a0 (Anton Salikhmetov    2010-12-16 18:08:38 +0200  77) 				cpu_to_be32(HFSP_HARDLINK_TYPE) &&
2753cc281c9a0 (Anton Salikhmetov    2010-12-16 18:08:38 +0200  78) 				entry.file.user_info.fdCreator ==
2753cc281c9a0 (Anton Salikhmetov    2010-12-16 18:08:38 +0200  79) 				cpu_to_be32(HFSP_HFSPLUS_CREATOR) &&
a7ec7a4193a2e (Ernesto A. Fernández 2018-08-23 17:00:25 -0700  80) 				HFSPLUS_SB(sb)->hidden_dir &&
2753cc281c9a0 (Anton Salikhmetov    2010-12-16 18:08:38 +0200  81) 				(entry.file.create_date ==
2753cc281c9a0 (Anton Salikhmetov    2010-12-16 18:08:38 +0200  82) 					HFSPLUS_I(HFSPLUS_SB(sb)->hidden_dir)->
2753cc281c9a0 (Anton Salikhmetov    2010-12-16 18:08:38 +0200  83) 						create_date ||
2753cc281c9a0 (Anton Salikhmetov    2010-12-16 18:08:38 +0200  84) 				entry.file.create_date ==
2b0143b5c986b (David Howells        2015-03-17 22:25:59 +0000  85) 					HFSPLUS_I(d_inode(sb->s_root))->
a7ec7a4193a2e (Ernesto A. Fernández 2018-08-23 17:00:25 -0700  86) 						create_date)) {
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700  87) 			struct qstr str;
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700  88) 			char name[32];
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700  89) 
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700  90) 			if (dentry->d_fsdata) {
af8c85bb6d4e5 (Roman Zippel         2006-01-18 17:43:10 -0800  91) 				/*
af8c85bb6d4e5 (Roman Zippel         2006-01-18 17:43:10 -0800  92) 				 * We found a link pointing to another link,
af8c85bb6d4e5 (Roman Zippel         2006-01-18 17:43:10 -0800  93) 				 * so ignore it and treat it as regular file.
af8c85bb6d4e5 (Roman Zippel         2006-01-18 17:43:10 -0800  94) 				 */
af8c85bb6d4e5 (Roman Zippel         2006-01-18 17:43:10 -0800  95) 				cnid = (unsigned long)dentry->d_fsdata;
af8c85bb6d4e5 (Roman Zippel         2006-01-18 17:43:10 -0800  96) 				linkid = 0;
af8c85bb6d4e5 (Roman Zippel         2006-01-18 17:43:10 -0800  97) 			} else {
af8c85bb6d4e5 (Roman Zippel         2006-01-18 17:43:10 -0800  98) 				dentry->d_fsdata = (void *)(unsigned long)cnid;
2753cc281c9a0 (Anton Salikhmetov    2010-12-16 18:08:38 +0200  99) 				linkid =
2753cc281c9a0 (Anton Salikhmetov    2010-12-16 18:08:38 +0200 100) 					be32_to_cpu(entry.file.permissions.dev);
af8c85bb6d4e5 (Roman Zippel         2006-01-18 17:43:10 -0800 101) 				str.len = sprintf(name, "iNode%d", linkid);
af8c85bb6d4e5 (Roman Zippel         2006-01-18 17:43:10 -0800 102) 				str.name = name;
89ac9b4d3d1a0 (Sougata Santra       2014-12-18 16:17:12 -0800 103) 				err = hfsplus_cat_build_key(sb, fd.search_key,
2753cc281c9a0 (Anton Salikhmetov    2010-12-16 18:08:38 +0200 104) 					HFSPLUS_SB(sb)->hidden_dir->i_ino,
2753cc281c9a0 (Anton Salikhmetov    2010-12-16 18:08:38 +0200 105) 					&str);
89ac9b4d3d1a0 (Sougata Santra       2014-12-18 16:17:12 -0800 106) 				if (unlikely(err < 0))
89ac9b4d3d1a0 (Sougata Santra       2014-12-18 16:17:12 -0800 107) 					goto fail;
af8c85bb6d4e5 (Roman Zippel         2006-01-18 17:43:10 -0800 108) 				goto again;
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 109) 			}
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 110) 		} else if (!dentry->d_fsdata)
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 111) 			dentry->d_fsdata = (void *)(unsigned long)cnid;
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 112) 	} else {
d614267329f2b (Joe Perches          2013-04-30 15:27:55 -0700 113) 		pr_err("invalid catalog entry type in lookup\n");
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 114) 		err = -EIO;
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 115) 		goto fail;
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 116) 	}
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 117) 	hfs_find_exit(&fd);
635253915b329 (David Howells        2008-02-07 00:15:40 -0800 118) 	inode = hfsplus_iget(dir->i_sb, cnid);
635253915b329 (David Howells        2008-02-07 00:15:40 -0800 119) 	if (IS_ERR(inode))
635253915b329 (David Howells        2008-02-07 00:15:40 -0800 120) 		return ERR_CAST(inode);
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 121) 	if (S_ISREG(inode->i_mode))
f6089ff87d309 (Christoph Hellwig    2010-10-14 09:54:28 -0400 122) 		HFSPLUS_I(inode)->linkid = linkid;
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 123) out:
293542d8e501d (Al Viro              2018-05-03 09:49:02 -0400 124) 	return d_splice_alias(inode, dentry);
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 125) fail:
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 126) 	hfs_find_exit(&fd);
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 127) 	return ERR_PTR(err);
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 128) }
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 129) 
e72514e7adcfb (Al Viro              2013-05-22 14:59:39 -0400 130) static int hfsplus_readdir(struct file *file, struct dir_context *ctx)
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 131) {
e72514e7adcfb (Al Viro              2013-05-22 14:59:39 -0400 132) 	struct inode *inode = file_inode(file);
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 133) 	struct super_block *sb = inode->i_sb;
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 134) 	int len, err;
017f8da43e92d (Hin-Tak Leung        2014-06-06 14:36:21 -0700 135) 	char *strbuf;
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 136) 	hfsplus_cat_entry entry;
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 137) 	struct hfs_find_data fd;
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 138) 	struct hfsplus_readdir_data *rd;
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 139) 	u16 type;
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 140) 
e72514e7adcfb (Al Viro              2013-05-22 14:59:39 -0400 141) 	if (file->f_pos >= inode->i_size)
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 142) 		return 0;
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 143) 
5bd9d99d107c5 (Alexey Khoroshilov   2011-07-06 02:29:59 +0400 144) 	err = hfs_find_init(HFSPLUS_SB(sb)->cat_tree, &fd);
5bd9d99d107c5 (Alexey Khoroshilov   2011-07-06 02:29:59 +0400 145) 	if (err)
5bd9d99d107c5 (Alexey Khoroshilov   2011-07-06 02:29:59 +0400 146) 		return err;
017f8da43e92d (Hin-Tak Leung        2014-06-06 14:36:21 -0700 147) 	strbuf = kmalloc(NLS_MAX_CHARSET_SIZE * HFSPLUS_MAX_STRLEN + 1, GFP_KERNEL);
017f8da43e92d (Hin-Tak Leung        2014-06-06 14:36:21 -0700 148) 	if (!strbuf) {
017f8da43e92d (Hin-Tak Leung        2014-06-06 14:36:21 -0700 149) 		err = -ENOMEM;
017f8da43e92d (Hin-Tak Leung        2014-06-06 14:36:21 -0700 150) 		goto out;
017f8da43e92d (Hin-Tak Leung        2014-06-06 14:36:21 -0700 151) 	}
89ac9b4d3d1a0 (Sougata Santra       2014-12-18 16:17:12 -0800 152) 	hfsplus_cat_build_key_with_cnid(sb, fd.search_key, inode->i_ino);
324ef39a8a4f6 (Vyacheslav Dubeyko   2013-02-27 17:03:04 -0800 153) 	err = hfs_brec_find(&fd, hfs_find_rec_by_key);
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 154) 	if (err)
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 155) 		goto out;
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 156) 
e72514e7adcfb (Al Viro              2013-05-22 14:59:39 -0400 157) 	if (ctx->pos == 0) {
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 158) 		/* This is completely artificial... */
e72514e7adcfb (Al Viro              2013-05-22 14:59:39 -0400 159) 		if (!dir_emit_dot(file, ctx))
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 160) 			goto out;
e72514e7adcfb (Al Viro              2013-05-22 14:59:39 -0400 161) 		ctx->pos = 1;
e72514e7adcfb (Al Viro              2013-05-22 14:59:39 -0400 162) 	}
e72514e7adcfb (Al Viro              2013-05-22 14:59:39 -0400 163) 	if (ctx->pos == 1) {
6f24f892871ac (Greg Kroah-Hartman   2012-05-04 12:09:39 -0700 164) 		if (fd.entrylength > sizeof(entry) || fd.entrylength < 0) {
6f24f892871ac (Greg Kroah-Hartman   2012-05-04 12:09:39 -0700 165) 			err = -EIO;
6f24f892871ac (Greg Kroah-Hartman   2012-05-04 12:09:39 -0700 166) 			goto out;
6f24f892871ac (Greg Kroah-Hartman   2012-05-04 12:09:39 -0700 167) 		}
6f24f892871ac (Greg Kroah-Hartman   2012-05-04 12:09:39 -0700 168) 
2753cc281c9a0 (Anton Salikhmetov    2010-12-16 18:08:38 +0200 169) 		hfs_bnode_read(fd.bnode, &entry, fd.entryoffset,
2753cc281c9a0 (Anton Salikhmetov    2010-12-16 18:08:38 +0200 170) 			fd.entrylength);
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 171) 		if (be16_to_cpu(entry.type) != HFSPLUS_FOLDER_THREAD) {
d614267329f2b (Joe Perches          2013-04-30 15:27:55 -0700 172) 			pr_err("bad catalog folder thread\n");
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 173) 			err = -EIO;
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 174) 			goto out;
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 175) 		}
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 176) 		if (fd.entrylength < HFSPLUS_MIN_THREAD_SZ) {
d614267329f2b (Joe Perches          2013-04-30 15:27:55 -0700 177) 			pr_err("truncated catalog thread\n");
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 178) 			err = -EIO;
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 179) 			goto out;
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 180) 		}
e72514e7adcfb (Al Viro              2013-05-22 14:59:39 -0400 181) 		if (!dir_emit(ctx, "..", 2,
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 182) 			    be32_to_cpu(entry.thread.parentID), DT_DIR))
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 183) 			goto out;
e72514e7adcfb (Al Viro              2013-05-22 14:59:39 -0400 184) 		ctx->pos = 2;
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 185) 	}
e72514e7adcfb (Al Viro              2013-05-22 14:59:39 -0400 186) 	if (ctx->pos >= inode->i_size)
e72514e7adcfb (Al Viro              2013-05-22 14:59:39 -0400 187) 		goto out;
e72514e7adcfb (Al Viro              2013-05-22 14:59:39 -0400 188) 	err = hfs_brec_goto(&fd, ctx->pos - 1);
e72514e7adcfb (Al Viro              2013-05-22 14:59:39 -0400 189) 	if (err)
e72514e7adcfb (Al Viro              2013-05-22 14:59:39 -0400 190) 		goto out;
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 191) 	for (;;) {
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 192) 		if (be32_to_cpu(fd.key->cat.parent) != inode->i_ino) {
d614267329f2b (Joe Perches          2013-04-30 15:27:55 -0700 193) 			pr_err("walked past end of dir\n");
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 194) 			err = -EIO;
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 195) 			goto out;
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 196) 		}
6f24f892871ac (Greg Kroah-Hartman   2012-05-04 12:09:39 -0700 197) 
6f24f892871ac (Greg Kroah-Hartman   2012-05-04 12:09:39 -0700 198) 		if (fd.entrylength > sizeof(entry) || fd.entrylength < 0) {
6f24f892871ac (Greg Kroah-Hartman   2012-05-04 12:09:39 -0700 199) 			err = -EIO;
6f24f892871ac (Greg Kroah-Hartman   2012-05-04 12:09:39 -0700 200) 			goto out;
6f24f892871ac (Greg Kroah-Hartman   2012-05-04 12:09:39 -0700 201) 		}
6f24f892871ac (Greg Kroah-Hartman   2012-05-04 12:09:39 -0700 202) 
2753cc281c9a0 (Anton Salikhmetov    2010-12-16 18:08:38 +0200 203) 		hfs_bnode_read(fd.bnode, &entry, fd.entryoffset,
2753cc281c9a0 (Anton Salikhmetov    2010-12-16 18:08:38 +0200 204) 			fd.entrylength);
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 205) 		type = be16_to_cpu(entry.type);
017f8da43e92d (Hin-Tak Leung        2014-06-06 14:36:21 -0700 206) 		len = NLS_MAX_CHARSET_SIZE * HFSPLUS_MAX_STRLEN;
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 207) 		err = hfsplus_uni2asc(sb, &fd.key->cat.name, strbuf, &len);
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 208) 		if (err)
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 209) 			goto out;
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 210) 		if (type == HFSPLUS_FOLDER) {
2753cc281c9a0 (Anton Salikhmetov    2010-12-16 18:08:38 +0200 211) 			if (fd.entrylength <
2753cc281c9a0 (Anton Salikhmetov    2010-12-16 18:08:38 +0200 212) 					sizeof(struct hfsplus_cat_folder)) {
d614267329f2b (Joe Perches          2013-04-30 15:27:55 -0700 213) 				pr_err("small dir entry\n");
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 214) 				err = -EIO;
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 215) 				goto out;
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 216) 			}
dd73a01a30d72 (Christoph Hellwig    2010-10-01 05:42:59 +0200 217) 			if (HFSPLUS_SB(sb)->hidden_dir &&
dd73a01a30d72 (Christoph Hellwig    2010-10-01 05:42:59 +0200 218) 			    HFSPLUS_SB(sb)->hidden_dir->i_ino ==
dd73a01a30d72 (Christoph Hellwig    2010-10-01 05:42:59 +0200 219) 					be32_to_cpu(entry.folder.id))
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 220) 				goto next;
e72514e7adcfb (Al Viro              2013-05-22 14:59:39 -0400 221) 			if (!dir_emit(ctx, strbuf, len,
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 222) 				    be32_to_cpu(entry.folder.id), DT_DIR))
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 223) 				break;
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 224) 		} else if (type == HFSPLUS_FILE) {
97a62eaefdc19 (Sergei Antonov       2014-06-06 14:36:24 -0700 225) 			u16 mode;
97a62eaefdc19 (Sergei Antonov       2014-06-06 14:36:24 -0700 226) 			unsigned type = DT_UNKNOWN;
97a62eaefdc19 (Sergei Antonov       2014-06-06 14:36:24 -0700 227) 
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 228) 			if (fd.entrylength < sizeof(struct hfsplus_cat_file)) {
d614267329f2b (Joe Perches          2013-04-30 15:27:55 -0700 229) 				pr_err("small file entry\n");
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 230) 				err = -EIO;
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 231) 				goto out;
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 232) 			}
97a62eaefdc19 (Sergei Antonov       2014-06-06 14:36:24 -0700 233) 
97a62eaefdc19 (Sergei Antonov       2014-06-06 14:36:24 -0700 234) 			mode = be16_to_cpu(entry.file.permissions.mode);
97a62eaefdc19 (Sergei Antonov       2014-06-06 14:36:24 -0700 235) 			if (S_ISREG(mode))
97a62eaefdc19 (Sergei Antonov       2014-06-06 14:36:24 -0700 236) 				type = DT_REG;
97a62eaefdc19 (Sergei Antonov       2014-06-06 14:36:24 -0700 237) 			else if (S_ISLNK(mode))
97a62eaefdc19 (Sergei Antonov       2014-06-06 14:36:24 -0700 238) 				type = DT_LNK;
97a62eaefdc19 (Sergei Antonov       2014-06-06 14:36:24 -0700 239) 			else if (S_ISFIFO(mode))
97a62eaefdc19 (Sergei Antonov       2014-06-06 14:36:24 -0700 240) 				type = DT_FIFO;
97a62eaefdc19 (Sergei Antonov       2014-06-06 14:36:24 -0700 241) 			else if (S_ISCHR(mode))
97a62eaefdc19 (Sergei Antonov       2014-06-06 14:36:24 -0700 242) 				type = DT_CHR;
97a62eaefdc19 (Sergei Antonov       2014-06-06 14:36:24 -0700 243) 			else if (S_ISBLK(mode))
97a62eaefdc19 (Sergei Antonov       2014-06-06 14:36:24 -0700 244) 				type = DT_BLK;
97a62eaefdc19 (Sergei Antonov       2014-06-06 14:36:24 -0700 245) 			else if (S_ISSOCK(mode))
97a62eaefdc19 (Sergei Antonov       2014-06-06 14:36:24 -0700 246) 				type = DT_SOCK;
97a62eaefdc19 (Sergei Antonov       2014-06-06 14:36:24 -0700 247) 
e72514e7adcfb (Al Viro              2013-05-22 14:59:39 -0400 248) 			if (!dir_emit(ctx, strbuf, len,
97a62eaefdc19 (Sergei Antonov       2014-06-06 14:36:24 -0700 249) 				      be32_to_cpu(entry.file.id), type))
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 250) 				break;
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 251) 		} else {
d614267329f2b (Joe Perches          2013-04-30 15:27:55 -0700 252) 			pr_err("bad catalog entry type\n");
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 253) 			err = -EIO;
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 254) 			goto out;
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 255) 		}
20b7643d8ee44 (Anton Salikhmetov    2010-12-16 18:08:40 +0200 256) next:
e72514e7adcfb (Al Viro              2013-05-22 14:59:39 -0400 257) 		ctx->pos++;
e72514e7adcfb (Al Viro              2013-05-22 14:59:39 -0400 258) 		if (ctx->pos >= inode->i_size)
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 259) 			goto out;
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 260) 		err = hfs_brec_goto(&fd, 1);
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 261) 		if (err)
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 262) 			goto out;
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 263) 	}
e72514e7adcfb (Al Viro              2013-05-22 14:59:39 -0400 264) 	rd = file->private_data;
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 265) 	if (!rd) {
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 266) 		rd = kmalloc(sizeof(struct hfsplus_readdir_data), GFP_KERNEL);
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 267) 		if (!rd) {
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 268) 			err = -ENOMEM;
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 269) 			goto out;
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 270) 		}
e72514e7adcfb (Al Viro              2013-05-22 14:59:39 -0400 271) 		file->private_data = rd;
e72514e7adcfb (Al Viro              2013-05-22 14:59:39 -0400 272) 		rd->file = file;
323ee8fc544d4 (Al Viro              2016-05-12 20:02:09 -0400 273) 		spin_lock(&HFSPLUS_I(inode)->open_dir_lock);
6af502de224c3 (Christoph Hellwig    2010-10-01 05:43:31 +0200 274) 		list_add(&rd->list, &HFSPLUS_I(inode)->open_dir_list);
323ee8fc544d4 (Al Viro              2016-05-12 20:02:09 -0400 275) 		spin_unlock(&HFSPLUS_I(inode)->open_dir_lock);
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 276) 	}
323ee8fc544d4 (Al Viro              2016-05-12 20:02:09 -0400 277) 	/*
323ee8fc544d4 (Al Viro              2016-05-12 20:02:09 -0400 278) 	 * Can be done after the list insertion; exclusion with
323ee8fc544d4 (Al Viro              2016-05-12 20:02:09 -0400 279) 	 * hfsplus_delete_cat() is provided by directory lock.
323ee8fc544d4 (Al Viro              2016-05-12 20:02:09 -0400 280) 	 */
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 281) 	memcpy(&rd->key, fd.key, sizeof(struct hfsplus_cat_key));
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 282) out:
017f8da43e92d (Hin-Tak Leung        2014-06-06 14:36:21 -0700 283) 	kfree(strbuf);
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 284) 	hfs_find_exit(&fd);
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 285) 	return err;
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 286) }
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 287) 
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 288) static int hfsplus_dir_release(struct inode *inode, struct file *file)
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 289) {
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 290) 	struct hfsplus_readdir_data *rd = file->private_data;
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 291) 	if (rd) {
323ee8fc544d4 (Al Viro              2016-05-12 20:02:09 -0400 292) 		spin_lock(&HFSPLUS_I(inode)->open_dir_lock);
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 293) 		list_del(&rd->list);
323ee8fc544d4 (Al Viro              2016-05-12 20:02:09 -0400 294) 		spin_unlock(&HFSPLUS_I(inode)->open_dir_lock);
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 295) 		kfree(rd);
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 296) 	}
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 297) 	return 0;
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 298) }
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 299) 
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 300) static int hfsplus_link(struct dentry *src_dentry, struct inode *dst_dir,
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 301) 			struct dentry *dst_dentry)
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 302) {
dd73a01a30d72 (Christoph Hellwig    2010-10-01 05:42:59 +0200 303) 	struct hfsplus_sb_info *sbi = HFSPLUS_SB(dst_dir->i_sb);
2b0143b5c986b (David Howells        2015-03-17 22:25:59 +0000 304) 	struct inode *inode = d_inode(src_dentry);
2b0143b5c986b (David Howells        2015-03-17 22:25:59 +0000 305) 	struct inode *src_dir = d_inode(src_dentry->d_parent);
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 306) 	struct qstr str;
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 307) 	char name[32];
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 308) 	u32 cnid, id;
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 309) 	int res;
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 310) 
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 311) 	if (HFSPLUS_IS_RSRC(inode))
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 312) 		return -EPERM;
f6089ff87d309 (Christoph Hellwig    2010-10-14 09:54:28 -0400 313) 	if (!S_ISREG(inode->i_mode))
f6089ff87d309 (Christoph Hellwig    2010-10-14 09:54:28 -0400 314) 		return -EPERM;
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 315) 
7ac9fb9c2a509 (Christoph Hellwig    2010-10-01 05:45:08 +0200 316) 	mutex_lock(&sbi->vh_mutex);
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 317) 	if (inode->i_ino == (u32)(unsigned long)src_dentry->d_fsdata) {
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 318) 		for (;;) {
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 319) 			get_random_bytes(&id, sizeof(cnid));
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 320) 			id &= 0x3fffffff;
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 321) 			str.name = name;
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 322) 			str.len = sprintf(name, "iNode%d", id);
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 323) 			res = hfsplus_rename_cat(inode->i_ino,
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 324) 						 src_dir, &src_dentry->d_name,
dd73a01a30d72 (Christoph Hellwig    2010-10-01 05:42:59 +0200 325) 						 sbi->hidden_dir, &str);
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 326) 			if (!res)
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 327) 				break;
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 328) 			if (res != -EEXIST)
7ac9fb9c2a509 (Christoph Hellwig    2010-10-01 05:45:08 +0200 329) 				goto out;
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 330) 		}
f6089ff87d309 (Christoph Hellwig    2010-10-14 09:54:28 -0400 331) 		HFSPLUS_I(inode)->linkid = id;
dd73a01a30d72 (Christoph Hellwig    2010-10-01 05:42:59 +0200 332) 		cnid = sbi->next_cnid++;
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 333) 		src_dentry->d_fsdata = (void *)(unsigned long)cnid;
2753cc281c9a0 (Anton Salikhmetov    2010-12-16 18:08:38 +0200 334) 		res = hfsplus_create_cat(cnid, src_dir,
2753cc281c9a0 (Anton Salikhmetov    2010-12-16 18:08:38 +0200 335) 			&src_dentry->d_name, inode);
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 336) 		if (res)
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 337) 			/* panic? */
7ac9fb9c2a509 (Christoph Hellwig    2010-10-01 05:45:08 +0200 338) 			goto out;
dd73a01a30d72 (Christoph Hellwig    2010-10-01 05:42:59 +0200 339) 		sbi->file_count++;
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 340) 	}
dd73a01a30d72 (Christoph Hellwig    2010-10-01 05:42:59 +0200 341) 	cnid = sbi->next_cnid++;
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 342) 	res = hfsplus_create_cat(cnid, dst_dir, &dst_dentry->d_name, inode);
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 343) 	if (res)
7ac9fb9c2a509 (Christoph Hellwig    2010-10-01 05:45:08 +0200 344) 		goto out;
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 345) 
d8c76e6f45c11 (Dave Hansen          2006-09-30 23:29:04 -0700 346) 	inc_nlink(inode);
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 347) 	hfsplus_instantiate(dst_dentry, inode, cnid);
7de9c6ee3ecff (Al Viro              2010-10-23 11:11:40 -0400 348) 	ihold(inode);
02027d42c3f74 (Deepa Dinamani       2016-09-14 07:48:05 -0700 349) 	inode->i_ctime = current_time(inode);
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 350) 	mark_inode_dirty(inode);
dd73a01a30d72 (Christoph Hellwig    2010-10-01 05:42:59 +0200 351) 	sbi->file_count++;
9e6c5829b07c9 (Artem Bityutskiy     2012-07-12 17:26:31 +0300 352) 	hfsplus_mark_mdb_dirty(dst_dir->i_sb);
7ac9fb9c2a509 (Christoph Hellwig    2010-10-01 05:45:08 +0200 353) out:
7ac9fb9c2a509 (Christoph Hellwig    2010-10-01 05:45:08 +0200 354) 	mutex_unlock(&sbi->vh_mutex);
7ac9fb9c2a509 (Christoph Hellwig    2010-10-01 05:45:08 +0200 355) 	return res;
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 356) }
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 357) 
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 358) static int hfsplus_unlink(struct inode *dir, struct dentry *dentry)
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 359) {
dd73a01a30d72 (Christoph Hellwig    2010-10-01 05:42:59 +0200 360) 	struct hfsplus_sb_info *sbi = HFSPLUS_SB(dir->i_sb);
2b0143b5c986b (David Howells        2015-03-17 22:25:59 +0000 361) 	struct inode *inode = d_inode(dentry);
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 362) 	struct qstr str;
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 363) 	char name[32];
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 364) 	u32 cnid;
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 365) 	int res;
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 366) 
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 367) 	if (HFSPLUS_IS_RSRC(inode))
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 368) 		return -EPERM;
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 369) 
7ac9fb9c2a509 (Christoph Hellwig    2010-10-01 05:45:08 +0200 370) 	mutex_lock(&sbi->vh_mutex);
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 371) 	cnid = (u32)(unsigned long)dentry->d_fsdata;
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 372) 	if (inode->i_ino == cnid &&
6af502de224c3 (Christoph Hellwig    2010-10-01 05:43:31 +0200 373) 	    atomic_read(&HFSPLUS_I(inode)->opencnt)) {
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 374) 		str.name = name;
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 375) 		str.len = sprintf(name, "temp%lu", inode->i_ino);
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 376) 		res = hfsplus_rename_cat(inode->i_ino,
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 377) 					 dir, &dentry->d_name,
dd73a01a30d72 (Christoph Hellwig    2010-10-01 05:42:59 +0200 378) 					 sbi->hidden_dir, &str);
85b8fe8cc47b0 (Christoph Hellwig    2010-10-27 13:45:50 +0200 379) 		if (!res) {
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 380) 			inode->i_flags |= S_DEAD;
85b8fe8cc47b0 (Christoph Hellwig    2010-10-27 13:45:50 +0200 381) 			drop_nlink(inode);
85b8fe8cc47b0 (Christoph Hellwig    2010-10-27 13:45:50 +0200 382) 		}
7ac9fb9c2a509 (Christoph Hellwig    2010-10-01 05:45:08 +0200 383) 		goto out;
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 384) 	}
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 385) 	res = hfsplus_delete_cat(cnid, dir, &dentry->d_name);
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 386) 	if (res)
7ac9fb9c2a509 (Christoph Hellwig    2010-10-01 05:45:08 +0200 387) 		goto out;
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 388) 
af8c85bb6d4e5 (Roman Zippel         2006-01-18 17:43:10 -0800 389) 	if (inode->i_nlink > 0)
9a53c3a783c2f (Dave Hansen          2006-09-30 23:29:03 -0700 390) 		drop_nlink(inode);
76b0c26af2736 (Roman Zippel         2008-04-09 17:44:07 +0200 391) 	if (inode->i_ino == cnid)
76b0c26af2736 (Roman Zippel         2008-04-09 17:44:07 +0200 392) 		clear_nlink(inode);
76b0c26af2736 (Roman Zippel         2008-04-09 17:44:07 +0200 393) 	if (!inode->i_nlink) {
76b0c26af2736 (Roman Zippel         2008-04-09 17:44:07 +0200 394) 		if (inode->i_ino != cnid) {
dd73a01a30d72 (Christoph Hellwig    2010-10-01 05:42:59 +0200 395) 			sbi->file_count--;
6af502de224c3 (Christoph Hellwig    2010-10-01 05:43:31 +0200 396) 			if (!atomic_read(&HFSPLUS_I(inode)->opencnt)) {
76b0c26af2736 (Roman Zippel         2008-04-09 17:44:07 +0200 397) 				res = hfsplus_delete_cat(inode->i_ino,
dd73a01a30d72 (Christoph Hellwig    2010-10-01 05:42:59 +0200 398) 							 sbi->hidden_dir,
76b0c26af2736 (Roman Zippel         2008-04-09 17:44:07 +0200 399) 							 NULL);
76b0c26af2736 (Roman Zippel         2008-04-09 17:44:07 +0200 400) 				if (!res)
76b0c26af2736 (Roman Zippel         2008-04-09 17:44:07 +0200 401) 					hfsplus_delete_inode(inode);
76b0c26af2736 (Roman Zippel         2008-04-09 17:44:07 +0200 402) 			} else
76b0c26af2736 (Roman Zippel         2008-04-09 17:44:07 +0200 403) 				inode->i_flags |= S_DEAD;
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 404) 		} else
76b0c26af2736 (Roman Zippel         2008-04-09 17:44:07 +0200 405) 			hfsplus_delete_inode(inode);
af8c85bb6d4e5 (Roman Zippel         2006-01-18 17:43:10 -0800 406) 	} else
dd73a01a30d72 (Christoph Hellwig    2010-10-01 05:42:59 +0200 407) 		sbi->file_count--;
02027d42c3f74 (Deepa Dinamani       2016-09-14 07:48:05 -0700 408) 	inode->i_ctime = current_time(inode);
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 409) 	mark_inode_dirty(inode);
7ac9fb9c2a509 (Christoph Hellwig    2010-10-01 05:45:08 +0200 410) out:
7ac9fb9c2a509 (Christoph Hellwig    2010-10-01 05:45:08 +0200 411) 	mutex_unlock(&sbi->vh_mutex);
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 412) 	return res;
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 413) }
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 414) 
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 415) static int hfsplus_rmdir(struct inode *dir, struct dentry *dentry)
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 416) {
7ac9fb9c2a509 (Christoph Hellwig    2010-10-01 05:45:08 +0200 417) 	struct hfsplus_sb_info *sbi = HFSPLUS_SB(dir->i_sb);
2b0143b5c986b (David Howells        2015-03-17 22:25:59 +0000 418) 	struct inode *inode = d_inode(dentry);
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 419) 	int res;
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 420) 
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 421) 	if (inode->i_size != 2)
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 422) 		return -ENOTEMPTY;
7ac9fb9c2a509 (Christoph Hellwig    2010-10-01 05:45:08 +0200 423) 
7ac9fb9c2a509 (Christoph Hellwig    2010-10-01 05:45:08 +0200 424) 	mutex_lock(&sbi->vh_mutex);
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 425) 	res = hfsplus_delete_cat(inode->i_ino, dir, &dentry->d_name);
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 426) 	if (res)
7ac9fb9c2a509 (Christoph Hellwig    2010-10-01 05:45:08 +0200 427) 		goto out;
ce71ec3684036 (Dave Hansen          2006-09-30 23:29:06 -0700 428) 	clear_nlink(inode);
02027d42c3f74 (Deepa Dinamani       2016-09-14 07:48:05 -0700 429) 	inode->i_ctime = current_time(inode);
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 430) 	hfsplus_delete_inode(inode);
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 431) 	mark_inode_dirty(inode);
7ac9fb9c2a509 (Christoph Hellwig    2010-10-01 05:45:08 +0200 432) out:
7ac9fb9c2a509 (Christoph Hellwig    2010-10-01 05:45:08 +0200 433) 	mutex_unlock(&sbi->vh_mutex);
7ac9fb9c2a509 (Christoph Hellwig    2010-10-01 05:45:08 +0200 434) 	return res;
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 435) }
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 436) 
549c7297717c3 (Christian Brauner    2021-01-21 14:19:43 +0100 437) static int hfsplus_symlink(struct user_namespace *mnt_userns, struct inode *dir,
549c7297717c3 (Christian Brauner    2021-01-21 14:19:43 +0100 438) 			   struct dentry *dentry, const char *symname)
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 439) {
7ac9fb9c2a509 (Christoph Hellwig    2010-10-01 05:45:08 +0200 440) 	struct hfsplus_sb_info *sbi = HFSPLUS_SB(dir->i_sb);
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 441) 	struct inode *inode;
27a4e3884e9c6 (Chengyu Song         2015-04-16 12:47:12 -0700 442) 	int res = -ENOMEM;
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 443) 
7ac9fb9c2a509 (Christoph Hellwig    2010-10-01 05:45:08 +0200 444) 	mutex_lock(&sbi->vh_mutex);
b0cd38c7f54c9 (Ernesto A. Fernandez 2018-02-06 15:49:02 -0800 445) 	inode = hfsplus_new_inode(dir->i_sb, dir, S_IFLNK | S_IRWXUGO);
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 446) 	if (!inode)
7ac9fb9c2a509 (Christoph Hellwig    2010-10-01 05:45:08 +0200 447) 		goto out;
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 448) 
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 449) 	res = page_symlink(inode, symname, strlen(symname) + 1);
f17c89bfcc9cc (Christoph Hellwig    2010-10-01 05:43:54 +0200 450) 	if (res)
f17c89bfcc9cc (Christoph Hellwig    2010-10-01 05:43:54 +0200 451) 		goto out_err;
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 452) 
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 453) 	res = hfsplus_create_cat(inode->i_ino, dir, &dentry->d_name, inode);
f17c89bfcc9cc (Christoph Hellwig    2010-10-01 05:43:54 +0200 454) 	if (res)
f17c89bfcc9cc (Christoph Hellwig    2010-10-01 05:43:54 +0200 455) 		goto out_err;
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 456) 
f168d9fd634a4 (Ernesto A. Fernández 2018-08-21 21:59:23 -0700 457) 	res = hfsplus_init_security(inode, dir, &dentry->d_name);
324ef39a8a4f6 (Vyacheslav Dubeyko   2013-02-27 17:03:04 -0800 458) 	if (res == -EOPNOTSUPP)
324ef39a8a4f6 (Vyacheslav Dubeyko   2013-02-27 17:03:04 -0800 459) 		res = 0; /* Operation is not supported. */
324ef39a8a4f6 (Vyacheslav Dubeyko   2013-02-27 17:03:04 -0800 460) 	else if (res) {
324ef39a8a4f6 (Vyacheslav Dubeyko   2013-02-27 17:03:04 -0800 461) 		/* Try to delete anyway without error analysis. */
324ef39a8a4f6 (Vyacheslav Dubeyko   2013-02-27 17:03:04 -0800 462) 		hfsplus_delete_cat(inode->i_ino, dir, &dentry->d_name);
324ef39a8a4f6 (Vyacheslav Dubeyko   2013-02-27 17:03:04 -0800 463) 		goto out_err;
324ef39a8a4f6 (Vyacheslav Dubeyko   2013-02-27 17:03:04 -0800 464) 	}
324ef39a8a4f6 (Vyacheslav Dubeyko   2013-02-27 17:03:04 -0800 465) 
f17c89bfcc9cc (Christoph Hellwig    2010-10-01 05:43:54 +0200 466) 	hfsplus_instantiate(dentry, inode, inode->i_ino);
f17c89bfcc9cc (Christoph Hellwig    2010-10-01 05:43:54 +0200 467) 	mark_inode_dirty(inode);
7ac9fb9c2a509 (Christoph Hellwig    2010-10-01 05:45:08 +0200 468) 	goto out;
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 469) 
f17c89bfcc9cc (Christoph Hellwig    2010-10-01 05:43:54 +0200 470) out_err:
6d6b77f163c7e (Miklos Szeredi       2011-10-28 14:13:28 +0200 471) 	clear_nlink(inode);
f17c89bfcc9cc (Christoph Hellwig    2010-10-01 05:43:54 +0200 472) 	hfsplus_delete_inode(inode);
f17c89bfcc9cc (Christoph Hellwig    2010-10-01 05:43:54 +0200 473) 	iput(inode);
7ac9fb9c2a509 (Christoph Hellwig    2010-10-01 05:45:08 +0200 474) out:
7ac9fb9c2a509 (Christoph Hellwig    2010-10-01 05:45:08 +0200 475) 	mutex_unlock(&sbi->vh_mutex);
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 476) 	return res;
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 477) }
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 478) 
549c7297717c3 (Christian Brauner    2021-01-21 14:19:43 +0100 479) static int hfsplus_mknod(struct user_namespace *mnt_userns, struct inode *dir,
549c7297717c3 (Christian Brauner    2021-01-21 14:19:43 +0100 480) 			 struct dentry *dentry, umode_t mode, dev_t rdev)
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 481) {
7ac9fb9c2a509 (Christoph Hellwig    2010-10-01 05:45:08 +0200 482) 	struct hfsplus_sb_info *sbi = HFSPLUS_SB(dir->i_sb);
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 483) 	struct inode *inode;
27a4e3884e9c6 (Chengyu Song         2015-04-16 12:47:12 -0700 484) 	int res = -ENOMEM;
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 485) 
7ac9fb9c2a509 (Christoph Hellwig    2010-10-01 05:45:08 +0200 486) 	mutex_lock(&sbi->vh_mutex);
b0cd38c7f54c9 (Ernesto A. Fernandez 2018-02-06 15:49:02 -0800 487) 	inode = hfsplus_new_inode(dir->i_sb, dir, mode);
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 488) 	if (!inode)
7ac9fb9c2a509 (Christoph Hellwig    2010-10-01 05:45:08 +0200 489) 		goto out;
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 490) 
90e616905a423 (Christoph Hellwig    2010-10-14 09:54:39 -0400 491) 	if (S_ISBLK(mode) || S_ISCHR(mode) || S_ISFIFO(mode) || S_ISSOCK(mode))
90e616905a423 (Christoph Hellwig    2010-10-14 09:54:39 -0400 492) 		init_special_inode(inode, mode, rdev);
90e616905a423 (Christoph Hellwig    2010-10-14 09:54:39 -0400 493) 
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 494) 	res = hfsplus_create_cat(inode->i_ino, dir, &dentry->d_name, inode);
324ef39a8a4f6 (Vyacheslav Dubeyko   2013-02-27 17:03:04 -0800 495) 	if (res)
324ef39a8a4f6 (Vyacheslav Dubeyko   2013-02-27 17:03:04 -0800 496) 		goto failed_mknod;
324ef39a8a4f6 (Vyacheslav Dubeyko   2013-02-27 17:03:04 -0800 497) 
f168d9fd634a4 (Ernesto A. Fernández 2018-08-21 21:59:23 -0700 498) 	res = hfsplus_init_security(inode, dir, &dentry->d_name);
324ef39a8a4f6 (Vyacheslav Dubeyko   2013-02-27 17:03:04 -0800 499) 	if (res == -EOPNOTSUPP)
324ef39a8a4f6 (Vyacheslav Dubeyko   2013-02-27 17:03:04 -0800 500) 		res = 0; /* Operation is not supported. */
324ef39a8a4f6 (Vyacheslav Dubeyko   2013-02-27 17:03:04 -0800 501) 	else if (res) {
324ef39a8a4f6 (Vyacheslav Dubeyko   2013-02-27 17:03:04 -0800 502) 		/* Try to delete anyway without error analysis. */
324ef39a8a4f6 (Vyacheslav Dubeyko   2013-02-27 17:03:04 -0800 503) 		hfsplus_delete_cat(inode->i_ino, dir, &dentry->d_name);
324ef39a8a4f6 (Vyacheslav Dubeyko   2013-02-27 17:03:04 -0800 504) 		goto failed_mknod;
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 505) 	}
30d3abbec730a (Christoph Hellwig    2010-10-01 05:43:50 +0200 506) 
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 507) 	hfsplus_instantiate(dentry, inode, inode->i_ino);
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 508) 	mark_inode_dirty(inode);
324ef39a8a4f6 (Vyacheslav Dubeyko   2013-02-27 17:03:04 -0800 509) 	goto out;
324ef39a8a4f6 (Vyacheslav Dubeyko   2013-02-27 17:03:04 -0800 510) 
324ef39a8a4f6 (Vyacheslav Dubeyko   2013-02-27 17:03:04 -0800 511) failed_mknod:
324ef39a8a4f6 (Vyacheslav Dubeyko   2013-02-27 17:03:04 -0800 512) 	clear_nlink(inode);
324ef39a8a4f6 (Vyacheslav Dubeyko   2013-02-27 17:03:04 -0800 513) 	hfsplus_delete_inode(inode);
324ef39a8a4f6 (Vyacheslav Dubeyko   2013-02-27 17:03:04 -0800 514) 	iput(inode);
7ac9fb9c2a509 (Christoph Hellwig    2010-10-01 05:45:08 +0200 515) out:
7ac9fb9c2a509 (Christoph Hellwig    2010-10-01 05:45:08 +0200 516) 	mutex_unlock(&sbi->vh_mutex);
7ac9fb9c2a509 (Christoph Hellwig    2010-10-01 05:45:08 +0200 517) 	return res;
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 518) }
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 519) 
549c7297717c3 (Christian Brauner    2021-01-21 14:19:43 +0100 520) static int hfsplus_create(struct user_namespace *mnt_userns, struct inode *dir,
549c7297717c3 (Christian Brauner    2021-01-21 14:19:43 +0100 521) 			  struct dentry *dentry, umode_t mode, bool excl)
30d3abbec730a (Christoph Hellwig    2010-10-01 05:43:50 +0200 522) {
549c7297717c3 (Christian Brauner    2021-01-21 14:19:43 +0100 523) 	return hfsplus_mknod(&init_user_ns, dir, dentry, mode, 0);
30d3abbec730a (Christoph Hellwig    2010-10-01 05:43:50 +0200 524) }
30d3abbec730a (Christoph Hellwig    2010-10-01 05:43:50 +0200 525) 
549c7297717c3 (Christian Brauner    2021-01-21 14:19:43 +0100 526) static int hfsplus_mkdir(struct user_namespace *mnt_userns, struct inode *dir,
549c7297717c3 (Christian Brauner    2021-01-21 14:19:43 +0100 527) 			 struct dentry *dentry, umode_t mode)
30d3abbec730a (Christoph Hellwig    2010-10-01 05:43:50 +0200 528) {
549c7297717c3 (Christian Brauner    2021-01-21 14:19:43 +0100 529) 	return hfsplus_mknod(&init_user_ns, dir, dentry, mode | S_IFDIR, 0);
30d3abbec730a (Christoph Hellwig    2010-10-01 05:43:50 +0200 530) }
30d3abbec730a (Christoph Hellwig    2010-10-01 05:43:50 +0200 531) 
549c7297717c3 (Christian Brauner    2021-01-21 14:19:43 +0100 532) static int hfsplus_rename(struct user_namespace *mnt_userns,
549c7297717c3 (Christian Brauner    2021-01-21 14:19:43 +0100 533) 			  struct inode *old_dir, struct dentry *old_dentry,
f03b8ad8d3863 (Miklos Szeredi       2016-09-27 11:03:57 +0200 534) 			  struct inode *new_dir, struct dentry *new_dentry,
f03b8ad8d3863 (Miklos Szeredi       2016-09-27 11:03:57 +0200 535) 			  unsigned int flags)
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 536) {
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 537) 	int res;
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 538) 
f03b8ad8d3863 (Miklos Szeredi       2016-09-27 11:03:57 +0200 539) 	if (flags & ~RENAME_NOREPLACE)
f03b8ad8d3863 (Miklos Szeredi       2016-09-27 11:03:57 +0200 540) 		return -EINVAL;
f03b8ad8d3863 (Miklos Szeredi       2016-09-27 11:03:57 +0200 541) 
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 542) 	/* Unlink destination if it already exists */
2b0143b5c986b (David Howells        2015-03-17 22:25:59 +0000 543) 	if (d_really_is_positive(new_dentry)) {
e36cb0b89ce20 (David Howells        2015-01-29 12:02:35 +0000 544) 		if (d_is_dir(new_dentry))
40de9a7cebc4e (Christoph Hellwig    2010-10-01 09:12:08 +0200 545) 			res = hfsplus_rmdir(new_dir, new_dentry);
e3911785b8ae6 (Sage Weil            2011-05-27 13:42:06 -0700 546) 		else
40de9a7cebc4e (Christoph Hellwig    2010-10-01 09:12:08 +0200 547) 			res = hfsplus_unlink(new_dir, new_dentry);
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 548) 		if (res)
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 549) 			return res;
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 550) 	}
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 551) 
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 552) 	res = hfsplus_rename_cat((u32)(unsigned long)old_dentry->d_fsdata,
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 553) 				 old_dir, &old_dentry->d_name,
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 554) 				 new_dir, &new_dentry->d_name);
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 555) 	if (!res)
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 556) 		new_dentry->d_fsdata = old_dentry->d_fsdata;
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 557) 	return res;
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 558) }
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 559) 
92e1d5be91a0e (Arjan van de Ven     2007-02-12 00:55:39 -0800 560) const struct inode_operations hfsplus_dir_inode_operations = {
324ef39a8a4f6 (Vyacheslav Dubeyko   2013-02-27 17:03:04 -0800 561) 	.lookup			= hfsplus_lookup,
324ef39a8a4f6 (Vyacheslav Dubeyko   2013-02-27 17:03:04 -0800 562) 	.create			= hfsplus_create,
324ef39a8a4f6 (Vyacheslav Dubeyko   2013-02-27 17:03:04 -0800 563) 	.link			= hfsplus_link,
324ef39a8a4f6 (Vyacheslav Dubeyko   2013-02-27 17:03:04 -0800 564) 	.unlink			= hfsplus_unlink,
324ef39a8a4f6 (Vyacheslav Dubeyko   2013-02-27 17:03:04 -0800 565) 	.mkdir			= hfsplus_mkdir,
324ef39a8a4f6 (Vyacheslav Dubeyko   2013-02-27 17:03:04 -0800 566) 	.rmdir			= hfsplus_rmdir,
324ef39a8a4f6 (Vyacheslav Dubeyko   2013-02-27 17:03:04 -0800 567) 	.symlink		= hfsplus_symlink,
324ef39a8a4f6 (Vyacheslav Dubeyko   2013-02-27 17:03:04 -0800 568) 	.mknod			= hfsplus_mknod,
324ef39a8a4f6 (Vyacheslav Dubeyko   2013-02-27 17:03:04 -0800 569) 	.rename			= hfsplus_rename,
f93ca1ed9ba09 (Ernesto A. Fernández 2019-01-03 15:27:46 -0800 570) 	.getattr		= hfsplus_getattr,
324ef39a8a4f6 (Vyacheslav Dubeyko   2013-02-27 17:03:04 -0800 571) 	.listxattr		= hfsplus_listxattr,
9cbae74838e62 (Miklos Szeredi       2021-04-07 14:36:44 +0200 572) 	.fileattr_get		= hfsplus_fileattr_get,
9cbae74838e62 (Miklos Szeredi       2021-04-07 14:36:44 +0200 573) 	.fileattr_set		= hfsplus_fileattr_set,
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 574) };
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 575) 
4b6f5d20b04dc (Arjan van de Ven     2006-03-28 01:56:42 -0800 576) const struct file_operations hfsplus_dir_operations = {
eb29d66d4f2dc (Christoph Hellwig    2010-11-23 14:38:10 +0100 577) 	.fsync		= hfsplus_file_fsync,
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 578) 	.read		= generic_read_dir,
323ee8fc544d4 (Al Viro              2016-05-12 20:02:09 -0400 579) 	.iterate_shared	= hfsplus_readdir,
7cc4bcc6f152d (Arnd Bergmann        2010-04-27 16:24:20 +0200 580) 	.unlocked_ioctl = hfsplus_ioctl,
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 581) 	.llseek		= generic_file_llseek,
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 582) 	.release	= hfsplus_dir_release,
^1da177e4c3f4 (Linus Torvalds       2005-04-16 15:20:36 -0700 583) };