Orange Pi5 kernel

Deprecated Linux kernel 5.10.110 for OrangePi 5/5B/5+ boards

3 Commits   0 Branches   0 Tags
^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/hfsplus/inode.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   5)  * Copyright (C) 2001
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   6)  * Brad Boyer (flar@allandria.com)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   7)  * (C) 2003 Ardis Technologies <roman@ardistech.com>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   8)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   9)  * Inode handling routines
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  10)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  11) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  12) #include <linux/blkdev.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  13) #include <linux/mm.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  14) #include <linux/fs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  15) #include <linux/pagemap.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  16) #include <linux/mpage.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  17) #include <linux/sched.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  18) #include <linux/cred.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  19) #include <linux/uio.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  20) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  21) #include "hfsplus_fs.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  22) #include "hfsplus_raw.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  23) #include "xattr.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  24) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  25) static int hfsplus_readpage(struct file *file, struct page *page)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  26) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  27) 	return block_read_full_page(page, hfsplus_get_block);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  28) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  29) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  30) static int hfsplus_writepage(struct page *page, struct writeback_control *wbc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  31) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  32) 	return block_write_full_page(page, hfsplus_get_block, wbc);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  33) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  34) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  35) static void hfsplus_write_failed(struct address_space *mapping, loff_t to)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  36) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  37) 	struct inode *inode = mapping->host;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  38) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  39) 	if (to > inode->i_size) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  40) 		truncate_pagecache(inode, inode->i_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  41) 		hfsplus_file_truncate(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  42) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  43) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  44) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  45) static int hfsplus_write_begin(struct file *file, struct address_space *mapping,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  46) 			loff_t pos, unsigned len, unsigned flags,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  47) 			struct page **pagep, void **fsdata)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  48) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  49) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  50) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  51) 	*pagep = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  52) 	ret = cont_write_begin(file, mapping, pos, len, flags, pagep, fsdata,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  53) 				hfsplus_get_block,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  54) 				&HFSPLUS_I(mapping->host)->phys_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  55) 	if (unlikely(ret))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  56) 		hfsplus_write_failed(mapping, pos + len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  57) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  58) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  59) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  60) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  61) static sector_t hfsplus_bmap(struct address_space *mapping, sector_t block)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  62) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  63) 	return generic_block_bmap(mapping, block, hfsplus_get_block);
^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 hfsplus_releasepage(struct page *page, gfp_t mask)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  67) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  68) 	struct inode *inode = page->mapping->host;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  69) 	struct super_block *sb = inode->i_sb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  70) 	struct hfs_btree *tree;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  71) 	struct hfs_bnode *node;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  72) 	u32 nidx;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  73) 	int i, res = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  74) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  75) 	switch (inode->i_ino) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  76) 	case HFSPLUS_EXT_CNID:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  77) 		tree = HFSPLUS_SB(sb)->ext_tree;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  78) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  79) 	case HFSPLUS_CAT_CNID:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  80) 		tree = HFSPLUS_SB(sb)->cat_tree;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  81) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  82) 	case HFSPLUS_ATTR_CNID:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  83) 		tree = HFSPLUS_SB(sb)->attr_tree;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  84) 		break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  85) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  86) 		BUG();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  87) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  88) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  89) 	if (!tree)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  90) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  91) 	if (tree->node_size >= PAGE_SIZE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  92) 		nidx = page->index >>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  93) 			(tree->node_size_shift - PAGE_SHIFT);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  94) 		spin_lock(&tree->hash_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  95) 		node = hfs_bnode_findhash(tree, nidx);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  96) 		if (!node)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  97) 			;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  98) 		else if (atomic_read(&node->refcnt))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  99) 			res = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 100) 		if (res && node) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 101) 			hfs_bnode_unhash(node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 102) 			hfs_bnode_free(node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 103) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 104) 		spin_unlock(&tree->hash_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 105) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 106) 		nidx = page->index <<
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 107) 			(PAGE_SHIFT - tree->node_size_shift);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 108) 		i = 1 << (PAGE_SHIFT - tree->node_size_shift);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 109) 		spin_lock(&tree->hash_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 110) 		do {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 111) 			node = hfs_bnode_findhash(tree, nidx++);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 112) 			if (!node)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 113) 				continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 114) 			if (atomic_read(&node->refcnt)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 115) 				res = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 116) 				break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 117) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 118) 			hfs_bnode_unhash(node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 119) 			hfs_bnode_free(node);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 120) 		} while (--i && nidx < tree->node_count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 121) 		spin_unlock(&tree->hash_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 122) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 123) 	return res ? try_to_free_buffers(page) : 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 124) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 125) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 126) static ssize_t hfsplus_direct_IO(struct kiocb *iocb, struct iov_iter *iter)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 127) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 128) 	struct file *file = iocb->ki_filp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 129) 	struct address_space *mapping = file->f_mapping;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 130) 	struct inode *inode = mapping->host;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 131) 	size_t count = iov_iter_count(iter);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 132) 	ssize_t ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 133) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 134) 	ret = blockdev_direct_IO(iocb, inode, iter, hfsplus_get_block);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 135) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 136) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 137) 	 * In case of error extending write may have instantiated a few
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 138) 	 * blocks outside i_size. Trim these off again.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 139) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 140) 	if (unlikely(iov_iter_rw(iter) == WRITE && ret < 0)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 141) 		loff_t isize = i_size_read(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 142) 		loff_t end = iocb->ki_pos + count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 143) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 144) 		if (end > isize)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 145) 			hfsplus_write_failed(mapping, end);
^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) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 149) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 150) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 151) static int hfsplus_writepages(struct address_space *mapping,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 152) 			      struct writeback_control *wbc)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 153) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 154) 	return mpage_writepages(mapping, wbc, hfsplus_get_block);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 155) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 156) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 157) const struct address_space_operations hfsplus_btree_aops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 158) 	.readpage	= hfsplus_readpage,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 159) 	.writepage	= hfsplus_writepage,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 160) 	.write_begin	= hfsplus_write_begin,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 161) 	.write_end	= generic_write_end,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 162) 	.bmap		= hfsplus_bmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 163) 	.releasepage	= hfsplus_releasepage,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 164) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 165) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 166) const struct address_space_operations hfsplus_aops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 167) 	.readpage	= hfsplus_readpage,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 168) 	.writepage	= hfsplus_writepage,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 169) 	.write_begin	= hfsplus_write_begin,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 170) 	.write_end	= generic_write_end,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 171) 	.bmap		= hfsplus_bmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 172) 	.direct_IO	= hfsplus_direct_IO,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 173) 	.writepages	= hfsplus_writepages,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 174) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 175) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 176) const struct dentry_operations hfsplus_dentry_operations = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 177) 	.d_hash       = hfsplus_hash_dentry,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 178) 	.d_compare    = hfsplus_compare_dentry,
^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) static void hfsplus_get_perms(struct inode *inode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 182) 		struct hfsplus_perm *perms, int dir)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 183) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 184) 	struct hfsplus_sb_info *sbi = HFSPLUS_SB(inode->i_sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 185) 	u16 mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 186) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 187) 	mode = be16_to_cpu(perms->mode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 188) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 189) 	i_uid_write(inode, be32_to_cpu(perms->owner));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 190) 	if (!i_uid_read(inode) && !mode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 191) 		inode->i_uid = sbi->uid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 192) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 193) 	i_gid_write(inode, be32_to_cpu(perms->group));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 194) 	if (!i_gid_read(inode) && !mode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 195) 		inode->i_gid = sbi->gid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 196) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 197) 	if (dir) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 198) 		mode = mode ? (mode & S_IALLUGO) : (S_IRWXUGO & ~(sbi->umask));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 199) 		mode |= S_IFDIR;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 200) 	} else if (!mode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 201) 		mode = S_IFREG | ((S_IRUGO|S_IWUGO) & ~(sbi->umask));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 202) 	inode->i_mode = mode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 203) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 204) 	HFSPLUS_I(inode)->userflags = perms->userflags;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 205) 	if (perms->rootflags & HFSPLUS_FLG_IMMUTABLE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 206) 		inode->i_flags |= S_IMMUTABLE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 207) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 208) 		inode->i_flags &= ~S_IMMUTABLE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 209) 	if (perms->rootflags & HFSPLUS_FLG_APPEND)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 210) 		inode->i_flags |= S_APPEND;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 211) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 212) 		inode->i_flags &= ~S_APPEND;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 213) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 214) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 215) static int hfsplus_file_open(struct inode *inode, struct file *file)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 216) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 217) 	if (HFSPLUS_IS_RSRC(inode))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 218) 		inode = HFSPLUS_I(inode)->rsrc_inode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 219) 	if (!(file->f_flags & O_LARGEFILE) && i_size_read(inode) > MAX_NON_LFS)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 220) 		return -EOVERFLOW;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 221) 	atomic_inc(&HFSPLUS_I(inode)->opencnt);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 222) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 223) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 224) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 225) static int hfsplus_file_release(struct inode *inode, struct file *file)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 226) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 227) 	struct super_block *sb = inode->i_sb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 228) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 229) 	if (HFSPLUS_IS_RSRC(inode))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 230) 		inode = HFSPLUS_I(inode)->rsrc_inode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 231) 	if (atomic_dec_and_test(&HFSPLUS_I(inode)->opencnt)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 232) 		inode_lock(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 233) 		hfsplus_file_truncate(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 234) 		if (inode->i_flags & S_DEAD) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 235) 			hfsplus_delete_cat(inode->i_ino,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 236) 					   HFSPLUS_SB(sb)->hidden_dir, NULL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 237) 			hfsplus_delete_inode(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 238) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 239) 		inode_unlock(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 240) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 241) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 242) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 243) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 244) static int hfsplus_setattr(struct dentry *dentry, struct iattr *attr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 245) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 246) 	struct inode *inode = d_inode(dentry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 247) 	int error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 248) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 249) 	error = setattr_prepare(dentry, attr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 250) 	if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 251) 		return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 252) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 253) 	if ((attr->ia_valid & ATTR_SIZE) &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 254) 	    attr->ia_size != i_size_read(inode)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 255) 		inode_dio_wait(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 256) 		if (attr->ia_size > inode->i_size) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 257) 			error = generic_cont_expand_simple(inode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 258) 							   attr->ia_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 259) 			if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 260) 				return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 261) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 262) 		truncate_setsize(inode, attr->ia_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 263) 		hfsplus_file_truncate(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 264) 		inode->i_mtime = inode->i_ctime = current_time(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 265) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 266) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 267) 	setattr_copy(inode, attr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 268) 	mark_inode_dirty(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 269) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 270) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 271) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 272) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 273) int hfsplus_getattr(const struct path *path, struct kstat *stat,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 274) 		    u32 request_mask, unsigned int query_flags)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 275) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 276) 	struct inode *inode = d_inode(path->dentry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 277) 	struct hfsplus_inode_info *hip = HFSPLUS_I(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 278) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 279) 	if (inode->i_flags & S_APPEND)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 280) 		stat->attributes |= STATX_ATTR_APPEND;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 281) 	if (inode->i_flags & S_IMMUTABLE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 282) 		stat->attributes |= STATX_ATTR_IMMUTABLE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 283) 	if (hip->userflags & HFSPLUS_FLG_NODUMP)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 284) 		stat->attributes |= STATX_ATTR_NODUMP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 285) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 286) 	stat->attributes_mask |= STATX_ATTR_APPEND | STATX_ATTR_IMMUTABLE |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 287) 				 STATX_ATTR_NODUMP;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 288) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 289) 	generic_fillattr(inode, stat);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 290) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 291) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 292) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 293) int hfsplus_file_fsync(struct file *file, loff_t start, loff_t end,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 294) 		       int datasync)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 295) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 296) 	struct inode *inode = file->f_mapping->host;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 297) 	struct hfsplus_inode_info *hip = HFSPLUS_I(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 298) 	struct hfsplus_sb_info *sbi = HFSPLUS_SB(inode->i_sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 299) 	int error = 0, error2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 300) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 301) 	error = file_write_and_wait_range(file, start, end);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 302) 	if (error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 303) 		return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 304) 	inode_lock(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 305) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 306) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 307) 	 * Sync inode metadata into the catalog and extent trees.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 308) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 309) 	sync_inode_metadata(inode, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 310) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 311) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 312) 	 * And explicitly write out the btrees.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 313) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 314) 	if (test_and_clear_bit(HFSPLUS_I_CAT_DIRTY, &hip->flags))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 315) 		error = filemap_write_and_wait(sbi->cat_tree->inode->i_mapping);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 316) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 317) 	if (test_and_clear_bit(HFSPLUS_I_EXT_DIRTY, &hip->flags)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 318) 		error2 =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 319) 			filemap_write_and_wait(sbi->ext_tree->inode->i_mapping);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 320) 		if (!error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 321) 			error = error2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 322) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 323) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 324) 	if (test_and_clear_bit(HFSPLUS_I_ATTR_DIRTY, &hip->flags)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 325) 		if (sbi->attr_tree) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 326) 			error2 =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 327) 				filemap_write_and_wait(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 328) 					    sbi->attr_tree->inode->i_mapping);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 329) 			if (!error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 330) 				error = error2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 331) 		} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 332) 			pr_err("sync non-existent attributes tree\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 333) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 334) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 335) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 336) 	if (test_and_clear_bit(HFSPLUS_I_ALLOC_DIRTY, &hip->flags)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 337) 		error2 = filemap_write_and_wait(sbi->alloc_file->i_mapping);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 338) 		if (!error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 339) 			error = error2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 340) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 341) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 342) 	if (!test_bit(HFSPLUS_SB_NOBARRIER, &sbi->flags))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 343) 		blkdev_issue_flush(inode->i_sb->s_bdev, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 344) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 345) 	inode_unlock(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 346) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 347) 	return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 348) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 349) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 350) static const struct inode_operations hfsplus_file_inode_operations = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 351) 	.setattr	= hfsplus_setattr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 352) 	.getattr	= hfsplus_getattr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 353) 	.listxattr	= hfsplus_listxattr,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 354) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 355) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 356) static const struct file_operations hfsplus_file_operations = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 357) 	.llseek		= generic_file_llseek,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 358) 	.read_iter	= generic_file_read_iter,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 359) 	.write_iter	= generic_file_write_iter,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 360) 	.mmap		= generic_file_mmap,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 361) 	.splice_read	= generic_file_splice_read,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 362) 	.fsync		= hfsplus_file_fsync,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 363) 	.open		= hfsplus_file_open,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 364) 	.release	= hfsplus_file_release,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 365) 	.unlocked_ioctl = hfsplus_ioctl,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 366) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 367) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 368) struct inode *hfsplus_new_inode(struct super_block *sb, struct inode *dir,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 369) 				umode_t mode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 370) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 371) 	struct hfsplus_sb_info *sbi = HFSPLUS_SB(sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 372) 	struct inode *inode = new_inode(sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 373) 	struct hfsplus_inode_info *hip;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 374) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 375) 	if (!inode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 376) 		return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 377) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 378) 	inode->i_ino = sbi->next_cnid++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 379) 	inode_init_owner(inode, dir, mode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 380) 	set_nlink(inode, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 381) 	inode->i_mtime = inode->i_atime = inode->i_ctime = current_time(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 382) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 383) 	hip = HFSPLUS_I(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 384) 	INIT_LIST_HEAD(&hip->open_dir_list);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 385) 	spin_lock_init(&hip->open_dir_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 386) 	mutex_init(&hip->extents_lock);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 387) 	atomic_set(&hip->opencnt, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 388) 	hip->extent_state = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 389) 	hip->flags = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 390) 	hip->userflags = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 391) 	hip->subfolders = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 392) 	memset(hip->first_extents, 0, sizeof(hfsplus_extent_rec));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 393) 	memset(hip->cached_extents, 0, sizeof(hfsplus_extent_rec));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 394) 	hip->alloc_blocks = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 395) 	hip->first_blocks = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 396) 	hip->cached_start = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 397) 	hip->cached_blocks = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 398) 	hip->phys_size = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 399) 	hip->fs_blocks = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 400) 	hip->rsrc_inode = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 401) 	if (S_ISDIR(inode->i_mode)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 402) 		inode->i_size = 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 403) 		sbi->folder_count++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 404) 		inode->i_op = &hfsplus_dir_inode_operations;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 405) 		inode->i_fop = &hfsplus_dir_operations;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 406) 	} else if (S_ISREG(inode->i_mode)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 407) 		sbi->file_count++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 408) 		inode->i_op = &hfsplus_file_inode_operations;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 409) 		inode->i_fop = &hfsplus_file_operations;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 410) 		inode->i_mapping->a_ops = &hfsplus_aops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 411) 		hip->clump_blocks = sbi->data_clump_blocks;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 412) 	} else if (S_ISLNK(inode->i_mode)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 413) 		sbi->file_count++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 414) 		inode->i_op = &page_symlink_inode_operations;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 415) 		inode_nohighmem(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 416) 		inode->i_mapping->a_ops = &hfsplus_aops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 417) 		hip->clump_blocks = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 418) 	} else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 419) 		sbi->file_count++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 420) 	insert_inode_hash(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 421) 	mark_inode_dirty(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 422) 	hfsplus_mark_mdb_dirty(sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 423) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 424) 	return inode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 425) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 426) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 427) void hfsplus_delete_inode(struct inode *inode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 428) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 429) 	struct super_block *sb = inode->i_sb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 430) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 431) 	if (S_ISDIR(inode->i_mode)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 432) 		HFSPLUS_SB(sb)->folder_count--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 433) 		hfsplus_mark_mdb_dirty(sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 434) 		return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 435) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 436) 	HFSPLUS_SB(sb)->file_count--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 437) 	if (S_ISREG(inode->i_mode)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 438) 		if (!inode->i_nlink) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 439) 			inode->i_size = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 440) 			hfsplus_file_truncate(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 441) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 442) 	} else if (S_ISLNK(inode->i_mode)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 443) 		inode->i_size = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 444) 		hfsplus_file_truncate(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 445) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 446) 	hfsplus_mark_mdb_dirty(sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 447) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 448) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 449) void hfsplus_inode_read_fork(struct inode *inode, struct hfsplus_fork_raw *fork)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 450) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 451) 	struct super_block *sb = inode->i_sb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 452) 	struct hfsplus_sb_info *sbi = HFSPLUS_SB(sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 453) 	struct hfsplus_inode_info *hip = HFSPLUS_I(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 454) 	u32 count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 455) 	int i;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 456) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 457) 	memcpy(&hip->first_extents, &fork->extents, sizeof(hfsplus_extent_rec));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 458) 	for (count = 0, i = 0; i < 8; i++)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 459) 		count += be32_to_cpu(fork->extents[i].block_count);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 460) 	hip->first_blocks = count;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 461) 	memset(hip->cached_extents, 0, sizeof(hfsplus_extent_rec));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 462) 	hip->cached_start = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 463) 	hip->cached_blocks = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 464) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 465) 	hip->alloc_blocks = be32_to_cpu(fork->total_blocks);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 466) 	hip->phys_size = inode->i_size = be64_to_cpu(fork->total_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 467) 	hip->fs_blocks =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 468) 		(inode->i_size + sb->s_blocksize - 1) >> sb->s_blocksize_bits;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 469) 	inode_set_bytes(inode, hip->fs_blocks << sb->s_blocksize_bits);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 470) 	hip->clump_blocks =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 471) 		be32_to_cpu(fork->clump_size) >> sbi->alloc_blksz_shift;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 472) 	if (!hip->clump_blocks) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 473) 		hip->clump_blocks = HFSPLUS_IS_RSRC(inode) ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 474) 			sbi->rsrc_clump_blocks :
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 475) 			sbi->data_clump_blocks;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 476) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 477) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 478) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 479) void hfsplus_inode_write_fork(struct inode *inode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 480) 		struct hfsplus_fork_raw *fork)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 481) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 482) 	memcpy(&fork->extents, &HFSPLUS_I(inode)->first_extents,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 483) 	       sizeof(hfsplus_extent_rec));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 484) 	fork->total_size = cpu_to_be64(inode->i_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 485) 	fork->total_blocks = cpu_to_be32(HFSPLUS_I(inode)->alloc_blocks);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 486) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 487) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 488) int hfsplus_cat_read_inode(struct inode *inode, struct hfs_find_data *fd)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 489) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 490) 	hfsplus_cat_entry entry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 491) 	int res = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 492) 	u16 type;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 493) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 494) 	type = hfs_bnode_read_u16(fd->bnode, fd->entryoffset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 495) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 496) 	HFSPLUS_I(inode)->linkid = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 497) 	if (type == HFSPLUS_FOLDER) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 498) 		struct hfsplus_cat_folder *folder = &entry.folder;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 499) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 500) 		if (fd->entrylength < sizeof(struct hfsplus_cat_folder))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 501) 			/* panic? */;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 502) 		hfs_bnode_read(fd->bnode, &entry, fd->entryoffset,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 503) 					sizeof(struct hfsplus_cat_folder));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 504) 		hfsplus_get_perms(inode, &folder->permissions, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 505) 		set_nlink(inode, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 506) 		inode->i_size = 2 + be32_to_cpu(folder->valence);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 507) 		inode->i_atime = hfsp_mt2ut(folder->access_date);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 508) 		inode->i_mtime = hfsp_mt2ut(folder->content_mod_date);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 509) 		inode->i_ctime = hfsp_mt2ut(folder->attribute_mod_date);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 510) 		HFSPLUS_I(inode)->create_date = folder->create_date;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 511) 		HFSPLUS_I(inode)->fs_blocks = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 512) 		if (folder->flags & cpu_to_be16(HFSPLUS_HAS_FOLDER_COUNT)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 513) 			HFSPLUS_I(inode)->subfolders =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 514) 				be32_to_cpu(folder->subfolders);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 515) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 516) 		inode->i_op = &hfsplus_dir_inode_operations;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 517) 		inode->i_fop = &hfsplus_dir_operations;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 518) 	} else if (type == HFSPLUS_FILE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 519) 		struct hfsplus_cat_file *file = &entry.file;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 520) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 521) 		if (fd->entrylength < sizeof(struct hfsplus_cat_file))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 522) 			/* panic? */;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 523) 		hfs_bnode_read(fd->bnode, &entry, fd->entryoffset,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 524) 					sizeof(struct hfsplus_cat_file));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 525) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 526) 		hfsplus_inode_read_fork(inode, HFSPLUS_IS_RSRC(inode) ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 527) 					&file->rsrc_fork : &file->data_fork);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 528) 		hfsplus_get_perms(inode, &file->permissions, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 529) 		set_nlink(inode, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 530) 		if (S_ISREG(inode->i_mode)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 531) 			if (file->permissions.dev)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 532) 				set_nlink(inode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 533) 					  be32_to_cpu(file->permissions.dev));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 534) 			inode->i_op = &hfsplus_file_inode_operations;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 535) 			inode->i_fop = &hfsplus_file_operations;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 536) 			inode->i_mapping->a_ops = &hfsplus_aops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 537) 		} else if (S_ISLNK(inode->i_mode)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 538) 			inode->i_op = &page_symlink_inode_operations;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 539) 			inode_nohighmem(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 540) 			inode->i_mapping->a_ops = &hfsplus_aops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 541) 		} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 542) 			init_special_inode(inode, inode->i_mode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 543) 					   be32_to_cpu(file->permissions.dev));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 544) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 545) 		inode->i_atime = hfsp_mt2ut(file->access_date);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 546) 		inode->i_mtime = hfsp_mt2ut(file->content_mod_date);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 547) 		inode->i_ctime = hfsp_mt2ut(file->attribute_mod_date);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 548) 		HFSPLUS_I(inode)->create_date = file->create_date;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 549) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 550) 		pr_err("bad catalog entry used to create inode\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 551) 		res = -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 552) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 553) 	return res;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 554) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 555) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 556) int hfsplus_cat_write_inode(struct inode *inode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 557) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 558) 	struct inode *main_inode = inode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 559) 	struct hfs_find_data fd;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 560) 	hfsplus_cat_entry entry;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 561) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 562) 	if (HFSPLUS_IS_RSRC(inode))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 563) 		main_inode = HFSPLUS_I(inode)->rsrc_inode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 564) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 565) 	if (!main_inode->i_nlink)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 566) 		return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 567) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 568) 	if (hfs_find_init(HFSPLUS_SB(main_inode->i_sb)->cat_tree, &fd))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 569) 		/* panic? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 570) 		return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 571) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 572) 	if (hfsplus_find_cat(main_inode->i_sb, main_inode->i_ino, &fd))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 573) 		/* panic? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 574) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 575) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 576) 	if (S_ISDIR(main_inode->i_mode)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 577) 		struct hfsplus_cat_folder *folder = &entry.folder;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 578) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 579) 		if (fd.entrylength < sizeof(struct hfsplus_cat_folder))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 580) 			/* panic? */;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 581) 		hfs_bnode_read(fd.bnode, &entry, fd.entryoffset,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 582) 					sizeof(struct hfsplus_cat_folder));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 583) 		/* simple node checks? */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 584) 		hfsplus_cat_set_perms(inode, &folder->permissions);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 585) 		folder->access_date = hfsp_ut2mt(inode->i_atime);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 586) 		folder->content_mod_date = hfsp_ut2mt(inode->i_mtime);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 587) 		folder->attribute_mod_date = hfsp_ut2mt(inode->i_ctime);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 588) 		folder->valence = cpu_to_be32(inode->i_size - 2);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 589) 		if (folder->flags & cpu_to_be16(HFSPLUS_HAS_FOLDER_COUNT)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 590) 			folder->subfolders =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 591) 				cpu_to_be32(HFSPLUS_I(inode)->subfolders);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 592) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 593) 		hfs_bnode_write(fd.bnode, &entry, fd.entryoffset,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 594) 					 sizeof(struct hfsplus_cat_folder));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 595) 	} else if (HFSPLUS_IS_RSRC(inode)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 596) 		struct hfsplus_cat_file *file = &entry.file;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 597) 		hfs_bnode_read(fd.bnode, &entry, fd.entryoffset,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 598) 			       sizeof(struct hfsplus_cat_file));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 599) 		hfsplus_inode_write_fork(inode, &file->rsrc_fork);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 600) 		hfs_bnode_write(fd.bnode, &entry, fd.entryoffset,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 601) 				sizeof(struct hfsplus_cat_file));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 602) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 603) 		struct hfsplus_cat_file *file = &entry.file;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 604) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 605) 		if (fd.entrylength < sizeof(struct hfsplus_cat_file))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 606) 			/* panic? */;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 607) 		hfs_bnode_read(fd.bnode, &entry, fd.entryoffset,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 608) 					sizeof(struct hfsplus_cat_file));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 609) 		hfsplus_inode_write_fork(inode, &file->data_fork);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 610) 		hfsplus_cat_set_perms(inode, &file->permissions);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 611) 		if (HFSPLUS_FLG_IMMUTABLE &
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 612) 				(file->permissions.rootflags |
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 613) 					file->permissions.userflags))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 614) 			file->flags |= cpu_to_be16(HFSPLUS_FILE_LOCKED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 615) 		else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 616) 			file->flags &= cpu_to_be16(~HFSPLUS_FILE_LOCKED);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 617) 		file->access_date = hfsp_ut2mt(inode->i_atime);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 618) 		file->content_mod_date = hfsp_ut2mt(inode->i_mtime);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 619) 		file->attribute_mod_date = hfsp_ut2mt(inode->i_ctime);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 620) 		hfs_bnode_write(fd.bnode, &entry, fd.entryoffset,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 621) 					 sizeof(struct hfsplus_cat_file));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 622) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 623) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 624) 	set_bit(HFSPLUS_I_CAT_DIRTY, &HFSPLUS_I(inode)->flags);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 625) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 626) 	hfs_find_exit(&fd);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 627) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 628) }