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-only
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    2) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    3)  *  linux/fs/isofs/inode.c
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    4)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    5)  *  (C) 1991  Linus Torvalds - minix filesystem
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    6)  *      1992, 1993, 1994  Eric Youngdale Modified for ISO 9660 filesystem.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    7)  *      1994  Eberhard Mönkeberg - multi session handling.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    8)  *      1995  Mark Dobie - allow mounting of some weird VideoCDs and PhotoCDs.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300    9)  *	1997  Gordon Chaffee - Joliet CDs
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   10)  *	1998  Eric Lammerts - ISO 9660 Level 3
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   11)  *	2004  Paul Serice - Inode Support pushed out from 4GB to 128GB
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   12)  *	2004  Paul Serice - NFS Export Operations
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   13)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   14) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   15) #include <linux/init.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   16) #include <linux/module.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   17) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   18) #include <linux/slab.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   19) #include <linux/cred.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   20) #include <linux/nls.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   21) #include <linux/ctype.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   22) #include <linux/statfs.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   23) #include <linux/cdrom.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   24) #include <linux/parser.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   25) #include <linux/mpage.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   26) #include <linux/user_namespace.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   27) #include <linux/seq_file.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   28) #include <linux/blkdev.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   29) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   30) #include "isofs.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   31) #include "zisofs.h"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   32) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   33) /* max tz offset is 13 hours */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   34) #define MAX_TZ_OFFSET (52*15*60)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   35) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   36) #define BEQUIET
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   37) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   38) static int isofs_hashi(const struct dentry *parent, struct qstr *qstr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   39) static int isofs_dentry_cmpi(const struct dentry *dentry,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   40) 		unsigned int len, const char *str, const struct qstr *name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   41) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   42) #ifdef CONFIG_JOLIET
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   43) static int isofs_hashi_ms(const struct dentry *parent, struct qstr *qstr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   44) static int isofs_hash_ms(const struct dentry *parent, struct qstr *qstr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   45) static int isofs_dentry_cmpi_ms(const struct dentry *dentry,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   46) 		unsigned int len, const char *str, const struct qstr *name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   47) static int isofs_dentry_cmp_ms(const struct dentry *dentry,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   48) 		unsigned int len, const char *str, const struct qstr *name);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   49) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   50) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   51) static void isofs_put_super(struct super_block *sb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   52) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   53) 	struct isofs_sb_info *sbi = ISOFS_SB(sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   54) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   55) #ifdef CONFIG_JOLIET
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   56) 	unload_nls(sbi->s_nls_iocharset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   57) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   58) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   59) 	kfree(sbi);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   60) 	sb->s_fs_info = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   61) 	return;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   62) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   63) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   64) static int isofs_read_inode(struct inode *, int relocated);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   65) static int isofs_statfs (struct dentry *, struct kstatfs *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   66) static int isofs_show_options(struct seq_file *, struct dentry *);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   67) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   68) static struct kmem_cache *isofs_inode_cachep;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   69) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   70) static struct inode *isofs_alloc_inode(struct super_block *sb)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   71) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   72) 	struct iso_inode_info *ei;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   73) 	ei = kmem_cache_alloc(isofs_inode_cachep, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   74) 	if (!ei)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   75) 		return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   76) 	return &ei->vfs_inode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   77) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   78) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   79) static void isofs_free_inode(struct inode *inode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   80) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   81) 	kmem_cache_free(isofs_inode_cachep, ISOFS_I(inode));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   82) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   83) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   84) static void init_once(void *foo)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   85) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   86) 	struct iso_inode_info *ei = foo;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   87) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   88) 	inode_init_once(&ei->vfs_inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   89) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   90) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   91) static int __init init_inodecache(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   92) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   93) 	isofs_inode_cachep = kmem_cache_create("isofs_inode_cache",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   94) 					sizeof(struct iso_inode_info),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   95) 					0, (SLAB_RECLAIM_ACCOUNT|
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   96) 					SLAB_MEM_SPREAD|SLAB_ACCOUNT),
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   97) 					init_once);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   98) 	if (!isofs_inode_cachep)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300   99) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  100) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  101) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  102) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  103) static void destroy_inodecache(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  104) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  105) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  106) 	 * Make sure all delayed rcu free inodes are flushed before we
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  107) 	 * destroy cache.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  108) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  109) 	rcu_barrier();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  110) 	kmem_cache_destroy(isofs_inode_cachep);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  111) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  112) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  113) static int isofs_remount(struct super_block *sb, int *flags, char *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  114) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  115) 	sync_filesystem(sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  116) 	if (!(*flags & SB_RDONLY))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  117) 		return -EROFS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  118) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  119) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  120) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  121) static const struct super_operations isofs_sops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  122) 	.alloc_inode	= isofs_alloc_inode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  123) 	.free_inode	= isofs_free_inode,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  124) 	.put_super	= isofs_put_super,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  125) 	.statfs		= isofs_statfs,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  126) 	.remount_fs	= isofs_remount,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  127) 	.show_options	= isofs_show_options,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  128) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  129) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  130) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  131) static const struct dentry_operations isofs_dentry_ops[] = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  132) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  133) 		.d_hash		= isofs_hashi,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  134) 		.d_compare	= isofs_dentry_cmpi,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  135) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  136) #ifdef CONFIG_JOLIET
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  137) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  138) 		.d_hash		= isofs_hash_ms,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  139) 		.d_compare	= isofs_dentry_cmp_ms,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  140) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  141) 	{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  142) 		.d_hash		= isofs_hashi_ms,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  143) 		.d_compare	= isofs_dentry_cmpi_ms,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  144) 	},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  145) #endif
^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) struct iso9660_options{
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  149) 	unsigned int rock:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  150) 	unsigned int joliet:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  151) 	unsigned int cruft:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  152) 	unsigned int hide:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  153) 	unsigned int showassoc:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  154) 	unsigned int nocompress:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  155) 	unsigned int overriderockperm:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  156) 	unsigned int uid_set:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  157) 	unsigned int gid_set:1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  158) 	unsigned char map;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  159) 	unsigned char check;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  160) 	unsigned int blocksize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  161) 	umode_t fmode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  162) 	umode_t dmode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  163) 	kgid_t gid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  164) 	kuid_t uid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  165) 	char *iocharset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  166) 	/* LVE */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  167) 	s32 session;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  168) 	s32 sbsector;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  169) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  170) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  171) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  172)  * Compute the hash for the isofs name corresponding to the dentry.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  173)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  174) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  175) isofs_hashi_common(const struct dentry *dentry, struct qstr *qstr, int ms)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  176) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  177) 	const char *name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  178) 	int len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  179) 	char c;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  180) 	unsigned long hash;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  181) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  182) 	len = qstr->len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  183) 	name = qstr->name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  184) 	if (ms) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  185) 		while (len && name[len-1] == '.')
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  186) 			len--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  187) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  188) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  189) 	hash = init_name_hash(dentry);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  190) 	while (len--) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  191) 		c = tolower(*name++);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  192) 		hash = partial_name_hash(c, hash);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  193) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  194) 	qstr->hash = end_name_hash(hash);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  195) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  196) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  197) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  198) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  199) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  200)  * Compare of two isofs names.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  201)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  202) static int isofs_dentry_cmp_common(
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  203) 		unsigned int len, const char *str,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  204) 		const struct qstr *name, int ms, int ci)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  205) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  206) 	int alen, blen;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  207) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  208) 	/* A filename cannot end in '.' or we treat it like it has none */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  209) 	alen = name->len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  210) 	blen = len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  211) 	if (ms) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  212) 		while (alen && name->name[alen-1] == '.')
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  213) 			alen--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  214) 		while (blen && str[blen-1] == '.')
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  215) 			blen--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  216) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  217) 	if (alen == blen) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  218) 		if (ci) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  219) 			if (strncasecmp(name->name, str, alen) == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  220) 				return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  221) 		} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  222) 			if (strncmp(name->name, str, alen) == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  223) 				return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  224) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  225) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  226) 	return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  227) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  228) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  229) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  230) isofs_hashi(const struct dentry *dentry, struct qstr *qstr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  231) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  232) 	return isofs_hashi_common(dentry, qstr, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  233) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  234) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  235) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  236) isofs_dentry_cmpi(const struct dentry *dentry,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  237) 		unsigned int len, const char *str, const struct qstr *name)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  238) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  239) 	return isofs_dentry_cmp_common(len, str, name, 0, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  240) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  241) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  242) #ifdef CONFIG_JOLIET
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  243) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  244)  * Compute the hash for the isofs name corresponding to the dentry.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  245)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  246) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  247) isofs_hash_common(const struct dentry *dentry, struct qstr *qstr, int ms)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  248) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  249) 	const char *name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  250) 	int len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  251) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  252) 	len = qstr->len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  253) 	name = qstr->name;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  254) 	if (ms) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  255) 		while (len && name[len-1] == '.')
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  256) 			len--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  257) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  258) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  259) 	qstr->hash = full_name_hash(dentry, name, len);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  260) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  261) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  262) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  263) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  264) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  265) isofs_hash_ms(const struct dentry *dentry, struct qstr *qstr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  266) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  267) 	return isofs_hash_common(dentry, qstr, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  268) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  269) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  270) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  271) isofs_hashi_ms(const struct dentry *dentry, struct qstr *qstr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  272) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  273) 	return isofs_hashi_common(dentry, qstr, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  274) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  275) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  276) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  277) isofs_dentry_cmp_ms(const struct dentry *dentry,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  278) 		unsigned int len, const char *str, const struct qstr *name)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  279) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  280) 	return isofs_dentry_cmp_common(len, str, name, 1, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  281) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  282) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  283) static int
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  284) isofs_dentry_cmpi_ms(const struct dentry *dentry,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  285) 		unsigned int len, const char *str, const struct qstr *name)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  286) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  287) 	return isofs_dentry_cmp_common(len, str, name, 1, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  288) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  289) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  290) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  291) enum {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  292) 	Opt_block, Opt_check_r, Opt_check_s, Opt_cruft, Opt_gid, Opt_ignore,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  293) 	Opt_iocharset, Opt_map_a, Opt_map_n, Opt_map_o, Opt_mode, Opt_nojoliet,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  294) 	Opt_norock, Opt_sb, Opt_session, Opt_uid, Opt_unhide, Opt_utf8, Opt_err,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  295) 	Opt_nocompress, Opt_hide, Opt_showassoc, Opt_dmode, Opt_overriderockperm,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  296) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  297) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  298) static const match_table_t tokens = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  299) 	{Opt_norock, "norock"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  300) 	{Opt_nojoliet, "nojoliet"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  301) 	{Opt_unhide, "unhide"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  302) 	{Opt_hide, "hide"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  303) 	{Opt_showassoc, "showassoc"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  304) 	{Opt_cruft, "cruft"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  305) 	{Opt_utf8, "utf8"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  306) 	{Opt_iocharset, "iocharset=%s"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  307) 	{Opt_map_a, "map=acorn"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  308) 	{Opt_map_a, "map=a"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  309) 	{Opt_map_n, "map=normal"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  310) 	{Opt_map_n, "map=n"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  311) 	{Opt_map_o, "map=off"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  312) 	{Opt_map_o, "map=o"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  313) 	{Opt_session, "session=%u"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  314) 	{Opt_sb, "sbsector=%u"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  315) 	{Opt_check_r, "check=relaxed"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  316) 	{Opt_check_r, "check=r"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  317) 	{Opt_check_s, "check=strict"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  318) 	{Opt_check_s, "check=s"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  319) 	{Opt_uid, "uid=%u"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  320) 	{Opt_gid, "gid=%u"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  321) 	{Opt_mode, "mode=%u"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  322) 	{Opt_dmode, "dmode=%u"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  323) 	{Opt_overriderockperm, "overriderockperm"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  324) 	{Opt_block, "block=%u"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  325) 	{Opt_ignore, "conv=binary"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  326) 	{Opt_ignore, "conv=b"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  327) 	{Opt_ignore, "conv=text"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  328) 	{Opt_ignore, "conv=t"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  329) 	{Opt_ignore, "conv=mtext"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  330) 	{Opt_ignore, "conv=m"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  331) 	{Opt_ignore, "conv=auto"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  332) 	{Opt_ignore, "conv=a"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  333) 	{Opt_nocompress, "nocompress"},
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  334) 	{Opt_err, NULL}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  335) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  336) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  337) static int parse_options(char *options, struct iso9660_options *popt)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  338) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  339) 	char *p;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  340) 	int option;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  341) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  342) 	popt->map = 'n';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  343) 	popt->rock = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  344) 	popt->joliet = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  345) 	popt->cruft = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  346) 	popt->hide = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  347) 	popt->showassoc = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  348) 	popt->check = 'u';		/* unset */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  349) 	popt->nocompress = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  350) 	popt->blocksize = 1024;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  351) 	popt->fmode = popt->dmode = ISOFS_INVALID_MODE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  352) 	popt->uid_set = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  353) 	popt->gid_set = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  354) 	popt->gid = GLOBAL_ROOT_GID;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  355) 	popt->uid = GLOBAL_ROOT_UID;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  356) 	popt->iocharset = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  357) 	popt->overriderockperm = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  358) 	popt->session=-1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  359) 	popt->sbsector=-1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  360) 	if (!options)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  361) 		return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  362) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  363) 	while ((p = strsep(&options, ",")) != NULL) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  364) 		int token;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  365) 		substring_t args[MAX_OPT_ARGS];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  366) 		unsigned n;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  367) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  368) 		if (!*p)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  369) 			continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  370) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  371) 		token = match_token(p, tokens, args);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  372) 		switch (token) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  373) 		case Opt_norock:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  374) 			popt->rock = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  375) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  376) 		case Opt_nojoliet:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  377) 			popt->joliet = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  378) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  379) 		case Opt_hide:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  380) 			popt->hide = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  381) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  382) 		case Opt_unhide:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  383) 		case Opt_showassoc:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  384) 			popt->showassoc = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  385) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  386) 		case Opt_cruft:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  387) 			popt->cruft = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  388) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  389) #ifdef CONFIG_JOLIET
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  390) 		case Opt_utf8:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  391) 			kfree(popt->iocharset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  392) 			popt->iocharset = kstrdup("utf8", GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  393) 			if (!popt->iocharset)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  394) 				return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  395) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  396) 		case Opt_iocharset:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  397) 			kfree(popt->iocharset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  398) 			popt->iocharset = match_strdup(&args[0]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  399) 			if (!popt->iocharset)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  400) 				return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  401) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  402) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  403) 		case Opt_map_a:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  404) 			popt->map = 'a';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  405) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  406) 		case Opt_map_o:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  407) 			popt->map = 'o';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  408) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  409) 		case Opt_map_n:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  410) 			popt->map = 'n';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  411) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  412) 		case Opt_session:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  413) 			if (match_int(&args[0], &option))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  414) 				return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  415) 			n = option;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  416) 			/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  417) 			 * Track numbers are supposed to be in range 1-99, the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  418) 			 * mount option starts indexing at 0.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  419) 			 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  420) 			if (n >= 99)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  421) 				return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  422) 			popt->session = n + 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  423) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  424) 		case Opt_sb:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  425) 			if (match_int(&args[0], &option))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  426) 				return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  427) 			popt->sbsector = option;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  428) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  429) 		case Opt_check_r:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  430) 			popt->check = 'r';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  431) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  432) 		case Opt_check_s:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  433) 			popt->check = 's';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  434) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  435) 		case Opt_ignore:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  436) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  437) 		case Opt_uid:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  438) 			if (match_int(&args[0], &option))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  439) 				return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  440) 			popt->uid = make_kuid(current_user_ns(), option);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  441) 			if (!uid_valid(popt->uid))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  442) 				return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  443) 			popt->uid_set = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  444) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  445) 		case Opt_gid:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  446) 			if (match_int(&args[0], &option))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  447) 				return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  448) 			popt->gid = make_kgid(current_user_ns(), option);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  449) 			if (!gid_valid(popt->gid))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  450) 				return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  451) 			popt->gid_set = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  452) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  453) 		case Opt_mode:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  454) 			if (match_int(&args[0], &option))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  455) 				return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  456) 			popt->fmode = option;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  457) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  458) 		case Opt_dmode:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  459) 			if (match_int(&args[0], &option))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  460) 				return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  461) 			popt->dmode = option;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  462) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  463) 		case Opt_overriderockperm:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  464) 			popt->overriderockperm = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  465) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  466) 		case Opt_block:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  467) 			if (match_int(&args[0], &option))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  468) 				return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  469) 			n = option;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  470) 			if (n != 512 && n != 1024 && n != 2048)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  471) 				return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  472) 			popt->blocksize = n;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  473) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  474) 		case Opt_nocompress:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  475) 			popt->nocompress = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  476) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  477) 		default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  478) 			return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  479) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  480) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  481) 	return 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  482) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  483) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  484) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  485)  * Display the mount options in /proc/mounts.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  486)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  487) static int isofs_show_options(struct seq_file *m, struct dentry *root)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  488) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  489) 	struct isofs_sb_info *sbi = ISOFS_SB(root->d_sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  490) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  491) 	if (!sbi->s_rock)		seq_puts(m, ",norock");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  492) 	else if (!sbi->s_joliet_level)	seq_puts(m, ",nojoliet");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  493) 	if (sbi->s_cruft)		seq_puts(m, ",cruft");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  494) 	if (sbi->s_hide)		seq_puts(m, ",hide");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  495) 	if (sbi->s_nocompress)		seq_puts(m, ",nocompress");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  496) 	if (sbi->s_overriderockperm)	seq_puts(m, ",overriderockperm");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  497) 	if (sbi->s_showassoc)		seq_puts(m, ",showassoc");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  498) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  499) 	if (sbi->s_check)		seq_printf(m, ",check=%c", sbi->s_check);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  500) 	if (sbi->s_mapping)		seq_printf(m, ",map=%c", sbi->s_mapping);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  501) 	if (sbi->s_session != 255)	seq_printf(m, ",session=%u", sbi->s_session - 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  502) 	if (sbi->s_sbsector != -1)	seq_printf(m, ",sbsector=%u", sbi->s_sbsector);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  503) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  504) 	if (root->d_sb->s_blocksize != 1024)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  505) 		seq_printf(m, ",blocksize=%lu", root->d_sb->s_blocksize);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  506) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  507) 	if (sbi->s_uid_set)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  508) 		seq_printf(m, ",uid=%u",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  509) 			   from_kuid_munged(&init_user_ns, sbi->s_uid));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  510) 	if (sbi->s_gid_set)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  511) 		seq_printf(m, ",gid=%u",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  512) 			   from_kgid_munged(&init_user_ns, sbi->s_gid));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  513) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  514) 	if (sbi->s_dmode != ISOFS_INVALID_MODE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  515) 		seq_printf(m, ",dmode=%o", sbi->s_dmode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  516) 	if (sbi->s_fmode != ISOFS_INVALID_MODE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  517) 		seq_printf(m, ",fmode=%o", sbi->s_fmode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  518) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  519) #ifdef CONFIG_JOLIET
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  520) 	if (sbi->s_nls_iocharset)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  521) 		seq_printf(m, ",iocharset=%s", sbi->s_nls_iocharset->charset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  522) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  523) 		seq_puts(m, ",iocharset=utf8");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  524) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  525) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  526) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  527) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  528) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  529)  * look if the driver can tell the multi session redirection value
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  530)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  531)  * don't change this if you don't know what you do, please!
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  532)  * Multisession is legal only with XA disks.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  533)  * A non-XA disk with more than one volume descriptor may do it right, but
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  534)  * usually is written in a nowhere standardized "multi-partition" manner.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  535)  * Multisession uses absolute addressing (solely the first frame of the whole
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  536)  * track is #0), multi-partition uses relative addressing (each first frame of
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  537)  * each track is #0), and a track is not a session.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  538)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  539)  * A broken CDwriter software or drive firmware does not set new standards,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  540)  * at least not if conflicting with the existing ones.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  541)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  542)  * emoenke@gwdg.de
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  543)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  544) #define WE_OBEY_THE_WRITTEN_STANDARDS 1
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  545) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  546) static unsigned int isofs_get_last_session(struct super_block *sb, s32 session)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  547) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  548) 	struct cdrom_device_info *cdi = disk_to_cdi(sb->s_bdev->bd_disk);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  549) 	unsigned int vol_desc_start = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  550) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  551) 	if (session > 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  552) 		struct cdrom_tocentry te;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  553) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  554) 		if (!cdi)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  555) 			return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  556) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  557) 		te.cdte_track = session;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  558) 		te.cdte_format = CDROM_LBA;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  559) 		if (cdrom_read_tocentry(cdi, &te) == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  560) 			printk(KERN_DEBUG "ISOFS: Session %d start %d type %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  561) 				session, te.cdte_addr.lba,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  562) 				te.cdte_ctrl & CDROM_DATA_TRACK);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  563) 			if ((te.cdte_ctrl & CDROM_DATA_TRACK) == 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  564) 				return te.cdte_addr.lba;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  565) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  566) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  567) 		printk(KERN_ERR "ISOFS: Invalid session number or type of track\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  568) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  569) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  570) 	if (cdi) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  571) 		struct cdrom_multisession ms_info;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  572) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  573) 		ms_info.addr_format = CDROM_LBA;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  574) 		if (cdrom_multisession(cdi, &ms_info) == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  575) #if WE_OBEY_THE_WRITTEN_STANDARDS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  576) 			/* necessary for a valid ms_info.addr */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  577) 			if (ms_info.xa_flag)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  578) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  579) 				vol_desc_start = ms_info.addr.lba;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  580) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  581) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  582) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  583) 	return vol_desc_start;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  584) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  585) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  586) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  587)  * Check if root directory is empty (has less than 3 files).
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  588)  *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  589)  * Used to detect broken CDs where ISO root directory is empty but Joliet root
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  590)  * directory is OK. If such CD has Rock Ridge extensions, they will be disabled
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  591)  * (and Joliet used instead) or else no files would be visible.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  592)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  593) static bool rootdir_empty(struct super_block *sb, unsigned long block)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  594) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  595) 	int offset = 0, files = 0, de_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  596) 	struct iso_directory_record *de;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  597) 	struct buffer_head *bh;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  598) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  599) 	bh = sb_bread(sb, block);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  600) 	if (!bh)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  601) 		return true;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  602) 	while (files < 3) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  603) 		de = (struct iso_directory_record *) (bh->b_data + offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  604) 		de_len = *(unsigned char *) de;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  605) 		if (de_len == 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  606) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  607) 		files++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  608) 		offset += de_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  609) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  610) 	brelse(bh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  611) 	return files < 3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  612) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  613) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  614) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  615)  * Initialize the superblock and read the root inode.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  616)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  617) static int isofs_fill_super(struct super_block *s, void *data, int silent)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  618) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  619) 	struct buffer_head *bh = NULL, *pri_bh = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  620) 	struct hs_primary_descriptor *h_pri = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  621) 	struct iso_primary_descriptor *pri = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  622) 	struct iso_supplementary_descriptor *sec = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  623) 	struct iso_directory_record *rootp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  624) 	struct inode *inode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  625) 	struct iso9660_options opt;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  626) 	struct isofs_sb_info *sbi;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  627) 	unsigned long first_data_zone;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  628) 	int joliet_level = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  629) 	int iso_blknum, block;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  630) 	int orig_zonesize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  631) 	int table, error = -EINVAL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  632) 	unsigned int vol_desc_start;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  633) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  634) 	sbi = kzalloc(sizeof(*sbi), GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  635) 	if (!sbi)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  636) 		return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  637) 	s->s_fs_info = sbi;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  638) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  639) 	if (!parse_options((char *)data, &opt))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  640) 		goto out_freesbi;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  641) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  642) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  643) 	 * First of all, get the hardware blocksize for this device.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  644) 	 * If we don't know what it is, or the hardware blocksize is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  645) 	 * larger than the blocksize the user specified, then use
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  646) 	 * that value.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  647) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  648) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  649) 	 * What if bugger tells us to go beyond page size?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  650) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  651) 	if (bdev_logical_block_size(s->s_bdev) > 2048) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  652) 		printk(KERN_WARNING
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  653) 		       "ISOFS: unsupported/invalid hardware sector size %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  654) 			bdev_logical_block_size(s->s_bdev));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  655) 		goto out_freesbi;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  656) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  657) 	opt.blocksize = sb_min_blocksize(s, opt.blocksize);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  658) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  659) 	sbi->s_high_sierra = 0; /* default is iso9660 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  660) 	sbi->s_session = opt.session;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  661) 	sbi->s_sbsector = opt.sbsector;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  662) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  663) 	vol_desc_start = (opt.sbsector != -1) ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  664) 		opt.sbsector : isofs_get_last_session(s,opt.session);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  665) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  666) 	for (iso_blknum = vol_desc_start+16;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  667) 		iso_blknum < vol_desc_start+100; iso_blknum++) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  668) 		struct hs_volume_descriptor *hdp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  669) 		struct iso_volume_descriptor  *vdp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  670) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  671) 		block = iso_blknum << (ISOFS_BLOCK_BITS - s->s_blocksize_bits);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  672) 		if (!(bh = sb_bread(s, block)))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  673) 			goto out_no_read;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  674) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  675) 		vdp = (struct iso_volume_descriptor *)bh->b_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  676) 		hdp = (struct hs_volume_descriptor *)bh->b_data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  677) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  678) 		/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  679) 		 * Due to the overlapping physical location of the descriptors,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  680) 		 * ISO CDs can match hdp->id==HS_STANDARD_ID as well. To ensure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  681) 		 * proper identification in this case, we first check for ISO.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  682) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  683) 		if (strncmp (vdp->id, ISO_STANDARD_ID, sizeof vdp->id) == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  684) 			if (isonum_711(vdp->type) == ISO_VD_END)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  685) 				break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  686) 			if (isonum_711(vdp->type) == ISO_VD_PRIMARY) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  687) 				if (!pri) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  688) 					pri = (struct iso_primary_descriptor *)vdp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  689) 					/* Save the buffer in case we need it ... */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  690) 					pri_bh = bh;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  691) 					bh = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  692) 				}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  693) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  694) #ifdef CONFIG_JOLIET
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  695) 			else if (isonum_711(vdp->type) == ISO_VD_SUPPLEMENTARY) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  696) 				sec = (struct iso_supplementary_descriptor *)vdp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  697) 				if (sec->escape[0] == 0x25 && sec->escape[1] == 0x2f) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  698) 					if (opt.joliet) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  699) 						if (sec->escape[2] == 0x40)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  700) 							joliet_level = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  701) 						else if (sec->escape[2] == 0x43)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  702) 							joliet_level = 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  703) 						else if (sec->escape[2] == 0x45)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  704) 							joliet_level = 3;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  705) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  706) 						printk(KERN_DEBUG "ISO 9660 Extensions: "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  707) 							"Microsoft Joliet Level %d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  708) 							joliet_level);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  709) 					}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  710) 					goto root_found;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  711) 				} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  712) 				/* Unknown supplementary volume descriptor */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  713) 				sec = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  714) 				}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  715) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  716) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  717) 		} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  718) 			if (strncmp (hdp->id, HS_STANDARD_ID, sizeof hdp->id) == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  719) 				if (isonum_711(hdp->type) != ISO_VD_PRIMARY)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  720) 					goto out_freebh;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  721) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  722) 				sbi->s_high_sierra = 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  723) 				opt.rock = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  724) 				h_pri = (struct hs_primary_descriptor *)vdp;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  725) 				goto root_found;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  726) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  727) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  728) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  729) 		/* Just skip any volume descriptors we don't recognize */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  730) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  731) 		brelse(bh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  732) 		bh = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  733) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  734) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  735) 	 * If we fall through, either no volume descriptor was found,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  736) 	 * or else we passed a primary descriptor looking for others.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  737) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  738) 	if (!pri)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  739) 		goto out_unknown_format;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  740) 	brelse(bh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  741) 	bh = pri_bh;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  742) 	pri_bh = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  743) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  744) root_found:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  745) 	/* We don't support read-write mounts */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  746) 	if (!sb_rdonly(s)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  747) 		error = -EACCES;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  748) 		goto out_freebh;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  749) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  750) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  751) 	if (joliet_level && (!pri || !opt.rock)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  752) 		/* This is the case of Joliet with the norock mount flag.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  753) 		 * A disc with both Joliet and Rock Ridge is handled later
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  754) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  755) 		pri = (struct iso_primary_descriptor *) sec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  756) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  757) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  758) 	if(sbi->s_high_sierra){
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  759) 		rootp = (struct iso_directory_record *) h_pri->root_directory_record;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  760) 		sbi->s_nzones = isonum_733(h_pri->volume_space_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  761) 		sbi->s_log_zone_size = isonum_723(h_pri->logical_block_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  762) 		sbi->s_max_size = isonum_733(h_pri->volume_space_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  763) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  764) 		if (!pri)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  765) 			goto out_freebh;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  766) 		rootp = (struct iso_directory_record *) pri->root_directory_record;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  767) 		sbi->s_nzones = isonum_733(pri->volume_space_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  768) 		sbi->s_log_zone_size = isonum_723(pri->logical_block_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  769) 		sbi->s_max_size = isonum_733(pri->volume_space_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  770) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  771) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  772) 	sbi->s_ninodes = 0; /* No way to figure this out easily */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  773) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  774) 	orig_zonesize = sbi->s_log_zone_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  775) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  776) 	 * If the zone size is smaller than the hardware sector size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  777) 	 * this is a fatal error.  This would occur if the disc drive
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  778) 	 * had sectors that were 2048 bytes, but the filesystem had
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  779) 	 * blocks that were 512 bytes (which should only very rarely
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  780) 	 * happen.)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  781) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  782) 	if (orig_zonesize < opt.blocksize)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  783) 		goto out_bad_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  784) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  785) 	/* RDE: convert log zone size to bit shift */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  786) 	switch (sbi->s_log_zone_size) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  787) 	case  512: sbi->s_log_zone_size =  9; break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  788) 	case 1024: sbi->s_log_zone_size = 10; break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  789) 	case 2048: sbi->s_log_zone_size = 11; break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  790) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  791) 	default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  792) 		goto out_bad_zone_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  793) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  794) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  795) 	s->s_magic = ISOFS_SUPER_MAGIC;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  796) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  797) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  798) 	 * With multi-extent files, file size is only limited by the maximum
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  799) 	 * size of a file system, which is 8 TB.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  800) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  801) 	s->s_maxbytes = 0x80000000000LL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  802) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  803) 	/* ECMA-119 timestamp from 1900/1/1 with tz offset */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  804) 	s->s_time_min = mktime64(1900, 1, 1, 0, 0, 0) - MAX_TZ_OFFSET;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  805) 	s->s_time_max = mktime64(U8_MAX+1900, 12, 31, 23, 59, 59) + MAX_TZ_OFFSET;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  806) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  807) 	/* Set this for reference. Its not currently used except on write
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  808) 	   which we don't have .. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  809) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  810) 	first_data_zone = isonum_733(rootp->extent) +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  811) 			  isonum_711(rootp->ext_attr_length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  812) 	sbi->s_firstdatazone = first_data_zone;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  813) #ifndef BEQUIET
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  814) 	printk(KERN_DEBUG "ISOFS: Max size:%ld   Log zone size:%ld\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  815) 		sbi->s_max_size, 1UL << sbi->s_log_zone_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  816) 	printk(KERN_DEBUG "ISOFS: First datazone:%ld\n", sbi->s_firstdatazone);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  817) 	if(sbi->s_high_sierra)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  818) 		printk(KERN_DEBUG "ISOFS: Disc in High Sierra format.\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  819) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  820) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  821) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  822) 	 * If the Joliet level is set, we _may_ decide to use the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  823) 	 * secondary descriptor, but can't be sure until after we
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  824) 	 * read the root inode. But before reading the root inode
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  825) 	 * we may need to change the device blocksize, and would
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  826) 	 * rather release the old buffer first. So, we cache the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  827) 	 * first_data_zone value from the secondary descriptor.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  828) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  829) 	if (joliet_level) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  830) 		pri = (struct iso_primary_descriptor *) sec;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  831) 		rootp = (struct iso_directory_record *)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  832) 			pri->root_directory_record;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  833) 		first_data_zone = isonum_733(rootp->extent) +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  834) 				isonum_711(rootp->ext_attr_length);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  835) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  836) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  837) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  838) 	 * We're all done using the volume descriptor, and may need
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  839) 	 * to change the device blocksize, so release the buffer now.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  840) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  841) 	brelse(pri_bh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  842) 	brelse(bh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  843) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  844) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  845) 	 * Force the blocksize to 512 for 512 byte sectors.  The file
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  846) 	 * read primitives really get it wrong in a bad way if we don't
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  847) 	 * do this.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  848) 	 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  849) 	 * Note - we should never be setting the blocksize to something
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  850) 	 * less than the hardware sector size for the device.  If we
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  851) 	 * do, we would end up having to read larger buffers and split
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  852) 	 * out portions to satisfy requests.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  853) 	 *
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  854) 	 * Note2- the idea here is that we want to deal with the optimal
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  855) 	 * zonesize in the filesystem.  If we have it set to something less,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  856) 	 * then we have horrible problems with trying to piece together
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  857) 	 * bits of adjacent blocks in order to properly read directory
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  858) 	 * entries.  By forcing the blocksize in this way, we ensure
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  859) 	 * that we will never be required to do this.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  860) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  861) 	sb_set_blocksize(s, orig_zonesize);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  862) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  863) 	sbi->s_nls_iocharset = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  864) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  865) #ifdef CONFIG_JOLIET
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  866) 	if (joliet_level) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  867) 		char *p = opt.iocharset ? opt.iocharset : CONFIG_NLS_DEFAULT;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  868) 		if (strcmp(p, "utf8") != 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  869) 			sbi->s_nls_iocharset = opt.iocharset ?
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  870) 				load_nls(opt.iocharset) : load_nls_default();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  871) 			if (!sbi->s_nls_iocharset)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  872) 				goto out_freesbi;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  873) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  874) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  875) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  876) 	s->s_op = &isofs_sops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  877) 	s->s_export_op = &isofs_export_ops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  878) 	sbi->s_mapping = opt.map;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  879) 	sbi->s_rock = (opt.rock ? 2 : 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  880) 	sbi->s_rock_offset = -1; /* initial offset, will guess until SP is found*/
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  881) 	sbi->s_cruft = opt.cruft;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  882) 	sbi->s_hide = opt.hide;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  883) 	sbi->s_showassoc = opt.showassoc;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  884) 	sbi->s_uid = opt.uid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  885) 	sbi->s_gid = opt.gid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  886) 	sbi->s_uid_set = opt.uid_set;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  887) 	sbi->s_gid_set = opt.gid_set;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  888) 	sbi->s_nocompress = opt.nocompress;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  889) 	sbi->s_overriderockperm = opt.overriderockperm;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  890) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  891) 	 * It would be incredibly stupid to allow people to mark every file
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  892) 	 * on the disk as suid, so we merely allow them to set the default
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  893) 	 * permissions.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  894) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  895) 	if (opt.fmode != ISOFS_INVALID_MODE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  896) 		sbi->s_fmode = opt.fmode & 0777;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  897) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  898) 		sbi->s_fmode = ISOFS_INVALID_MODE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  899) 	if (opt.dmode != ISOFS_INVALID_MODE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  900) 		sbi->s_dmode = opt.dmode & 0777;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  901) 	else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  902) 		sbi->s_dmode = ISOFS_INVALID_MODE;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  903) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  904) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  905) 	 * Read the root inode, which _may_ result in changing
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  906) 	 * the s_rock flag. Once we have the final s_rock value,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  907) 	 * we then decide whether to use the Joliet descriptor.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  908) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  909) 	inode = isofs_iget(s, sbi->s_firstdatazone, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  910) 	if (IS_ERR(inode))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  911) 		goto out_no_root;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  912) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  913) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  914) 	 * Fix for broken CDs with Rock Ridge and empty ISO root directory but
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  915) 	 * correct Joliet root directory.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  916) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  917) 	if (sbi->s_rock == 1 && joliet_level &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  918) 				rootdir_empty(s, sbi->s_firstdatazone)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  919) 		printk(KERN_NOTICE
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  920) 			"ISOFS: primary root directory is empty. "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  921) 			"Disabling Rock Ridge and switching to Joliet.");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  922) 		sbi->s_rock = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  923) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  924) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  925) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  926) 	 * If this disk has both Rock Ridge and Joliet on it, then we
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  927) 	 * want to use Rock Ridge by default.  This can be overridden
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  928) 	 * by using the norock mount option.  There is still one other
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  929) 	 * possibility that is not taken into account: a Rock Ridge
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  930) 	 * CD with Unicode names.  Until someone sees such a beast, it
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  931) 	 * will not be supported.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  932) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  933) 	if (sbi->s_rock == 1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  934) 		joliet_level = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  935) 	} else if (joliet_level) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  936) 		sbi->s_rock = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  937) 		if (sbi->s_firstdatazone != first_data_zone) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  938) 			sbi->s_firstdatazone = first_data_zone;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  939) 			printk(KERN_DEBUG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  940) 				"ISOFS: changing to secondary root\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  941) 			iput(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  942) 			inode = isofs_iget(s, sbi->s_firstdatazone, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  943) 			if (IS_ERR(inode))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  944) 				goto out_no_root;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  945) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  946) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  947) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  948) 	if (opt.check == 'u') {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  949) 		/* Only Joliet is case insensitive by default */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  950) 		if (joliet_level)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  951) 			opt.check = 'r';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  952) 		else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  953) 			opt.check = 's';
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  954) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  955) 	sbi->s_joliet_level = joliet_level;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  956) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  957) 	/* Make sure the root inode is a directory */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  958) 	if (!S_ISDIR(inode->i_mode)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  959) 		printk(KERN_WARNING
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  960) 			"isofs_fill_super: root inode is not a directory. "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  961) 			"Corrupted media?\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  962) 		goto out_iput;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  963) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  964) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  965) 	table = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  966) 	if (joliet_level)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  967) 		table += 2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  968) 	if (opt.check == 'r')
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  969) 		table++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  970) 	sbi->s_check = opt.check;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  971) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  972) 	if (table)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  973) 		s->s_d_op = &isofs_dentry_ops[table - 1];
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  974) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  975) 	/* get the root dentry */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  976) 	s->s_root = d_make_root(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  977) 	if (!(s->s_root)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  978) 		error = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  979) 		goto out_no_inode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  980) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  981) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  982) 	kfree(opt.iocharset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  983) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  984) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  985) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  986) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  987) 	 * Display error messages and free resources.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  988) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  989) out_iput:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  990) 	iput(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  991) 	goto out_no_inode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  992) out_no_root:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  993) 	error = PTR_ERR(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  994) 	if (error != -ENOMEM)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  995) 		printk(KERN_WARNING "%s: get root inode failed\n", __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  996) out_no_inode:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  997) #ifdef CONFIG_JOLIET
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  998) 	unload_nls(sbi->s_nls_iocharset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300  999) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1000) 	goto out_freesbi;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1001) out_no_read:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1002) 	printk(KERN_WARNING "%s: bread failed, dev=%s, iso_blknum=%d, block=%d\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1003) 		__func__, s->s_id, iso_blknum, block);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1004) 	goto out_freebh;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1005) out_bad_zone_size:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1006) 	printk(KERN_WARNING "ISOFS: Bad logical zone size %ld\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1007) 		sbi->s_log_zone_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1008) 	goto out_freebh;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1009) out_bad_size:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1010) 	printk(KERN_WARNING "ISOFS: Logical zone size(%d) < hardware blocksize(%u)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1011) 		orig_zonesize, opt.blocksize);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1012) 	goto out_freebh;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1013) out_unknown_format:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1014) 	if (!silent)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1015) 		printk(KERN_WARNING "ISOFS: Unable to identify CD-ROM format.\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1016) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1017) out_freebh:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1018) 	brelse(bh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1019) 	brelse(pri_bh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1020) out_freesbi:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1021) 	kfree(opt.iocharset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1022) 	kfree(sbi);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1023) 	s->s_fs_info = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1024) 	return error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1025) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1026) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1027) static int isofs_statfs (struct dentry *dentry, struct kstatfs *buf)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1028) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1029) 	struct super_block *sb = dentry->d_sb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1030) 	u64 id = huge_encode_dev(sb->s_bdev->bd_dev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1031) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1032) 	buf->f_type = ISOFS_SUPER_MAGIC;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1033) 	buf->f_bsize = sb->s_blocksize;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1034) 	buf->f_blocks = (ISOFS_SB(sb)->s_nzones
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1035) 		<< (ISOFS_SB(sb)->s_log_zone_size - sb->s_blocksize_bits));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1036) 	buf->f_bfree = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1037) 	buf->f_bavail = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1038) 	buf->f_files = ISOFS_SB(sb)->s_ninodes;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1039) 	buf->f_ffree = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1040) 	buf->f_fsid = u64_to_fsid(id);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1041) 	buf->f_namelen = NAME_MAX;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1042) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1043) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1044) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1045) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1046)  * Get a set of blocks; filling in buffer_heads if already allocated
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1047)  * or getblk() if they are not.  Returns the number of blocks inserted
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1048)  * (-ve == error.)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1049)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1050) int isofs_get_blocks(struct inode *inode, sector_t iblock,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1051) 		     struct buffer_head **bh, unsigned long nblocks)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1052) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1053) 	unsigned long b_off = iblock;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1054) 	unsigned offset, sect_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1055) 	unsigned int firstext;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1056) 	unsigned long nextblk, nextoff;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1057) 	int section, rv, error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1058) 	struct iso_inode_info *ei = ISOFS_I(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1059) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1060) 	error = -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1061) 	rv = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1062) 	if (iblock != b_off) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1063) 		printk(KERN_DEBUG "%s: block number too large\n", __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1064) 		goto abort;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1065) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1066) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1067) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1068) 	offset = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1069) 	firstext = ei->i_first_extent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1070) 	sect_size = ei->i_section_size >> ISOFS_BUFFER_BITS(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1071) 	nextblk = ei->i_next_section_block;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1072) 	nextoff = ei->i_next_section_offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1073) 	section = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1074) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1075) 	while (nblocks) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1076) 		/* If we are *way* beyond the end of the file, print a message.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1077) 		 * Access beyond the end of the file up to the next page boundary
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1078) 		 * is normal, however because of the way the page cache works.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1079) 		 * In this case, we just return 0 so that we can properly fill
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1080) 		 * the page with useless information without generating any
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1081) 		 * I/O errors.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1082) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1083) 		if (b_off > ((inode->i_size + PAGE_SIZE - 1) >> ISOFS_BUFFER_BITS(inode))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1084) 			printk(KERN_DEBUG "%s: block >= EOF (%lu, %llu)\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1085) 				__func__, b_off,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1086) 				(unsigned long long)inode->i_size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1087) 			goto abort;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1088) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1089) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1090) 		/* On the last section, nextblk == 0, section size is likely to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1091) 		 * exceed sect_size by a partial block, and access beyond the
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1092) 		 * end of the file will reach beyond the section size, too.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1093) 		 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1094) 		while (nextblk && (b_off >= (offset + sect_size))) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1095) 			struct inode *ninode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1096) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1097) 			offset += sect_size;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1098) 			ninode = isofs_iget(inode->i_sb, nextblk, nextoff);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1099) 			if (IS_ERR(ninode)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1100) 				error = PTR_ERR(ninode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1101) 				goto abort;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1102) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1103) 			firstext  = ISOFS_I(ninode)->i_first_extent;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1104) 			sect_size = ISOFS_I(ninode)->i_section_size >> ISOFS_BUFFER_BITS(ninode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1105) 			nextblk   = ISOFS_I(ninode)->i_next_section_block;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1106) 			nextoff   = ISOFS_I(ninode)->i_next_section_offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1107) 			iput(ninode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1108) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1109) 			if (++section > 100) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1110) 				printk(KERN_DEBUG "%s: More than 100 file sections ?!?"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1111) 					" aborting...\n", __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1112) 				printk(KERN_DEBUG "%s: block=%lu firstext=%u sect_size=%u "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1113) 					"nextblk=%lu nextoff=%lu\n", __func__,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1114) 					b_off, firstext, (unsigned) sect_size,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1115) 					nextblk, nextoff);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1116) 				goto abort;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1117) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1118) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1119) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1120) 		if (*bh) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1121) 			map_bh(*bh, inode->i_sb, firstext + b_off - offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1122) 		} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1123) 			*bh = sb_getblk(inode->i_sb, firstext+b_off-offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1124) 			if (!*bh)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1125) 				goto abort;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1126) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1127) 		bh++;	/* Next buffer head */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1128) 		b_off++;	/* Next buffer offset */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1129) 		nblocks--;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1130) 		rv++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1131) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1132) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1133) 	error = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1134) abort:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1135) 	return rv != 0 ? rv : error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1136) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1137) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1138) /*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1139)  * Used by the standard interfaces.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1140)  */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1141) static int isofs_get_block(struct inode *inode, sector_t iblock,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1142) 		    struct buffer_head *bh_result, int create)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1143) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1144) 	int ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1145) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1146) 	if (create) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1147) 		printk(KERN_DEBUG "%s: Kernel tries to allocate a block\n", __func__);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1148) 		return -EROFS;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1149) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1150) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1151) 	ret = isofs_get_blocks(inode, iblock, &bh_result, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1152) 	return ret < 0 ? ret : 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1153) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1154) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1155) static int isofs_bmap(struct inode *inode, sector_t block)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1156) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1157) 	struct buffer_head dummy;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1158) 	int error;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1159) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1160) 	dummy.b_state = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1161) 	dummy.b_blocknr = -1000;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1162) 	error = isofs_get_block(inode, block, &dummy, 0);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1163) 	if (!error)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1164) 		return dummy.b_blocknr;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1165) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1166) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1167) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1168) struct buffer_head *isofs_bread(struct inode *inode, sector_t block)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1169) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1170) 	sector_t blknr = isofs_bmap(inode, block);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1171) 	if (!blknr)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1172) 		return NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1173) 	return sb_bread(inode->i_sb, blknr);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1174) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1175) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1176) static int isofs_readpage(struct file *file, struct page *page)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1177) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1178) 	return mpage_readpage(page, isofs_get_block);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1179) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1180) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1181) static void isofs_readahead(struct readahead_control *rac)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1182) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1183) 	mpage_readahead(rac, isofs_get_block);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1184) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1185) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1186) static sector_t _isofs_bmap(struct address_space *mapping, sector_t block)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1187) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1188) 	return generic_block_bmap(mapping,block,isofs_get_block);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1189) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1190) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1191) static const struct address_space_operations isofs_aops = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1192) 	.readpage = isofs_readpage,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1193) 	.readahead = isofs_readahead,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1194) 	.bmap = _isofs_bmap
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1195) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1196) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1197) static int isofs_read_level3_size(struct inode *inode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1198) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1199) 	unsigned long bufsize = ISOFS_BUFFER_SIZE(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1200) 	int high_sierra = ISOFS_SB(inode->i_sb)->s_high_sierra;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1201) 	struct buffer_head *bh = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1202) 	unsigned long block, offset, block_saved, offset_saved;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1203) 	int i = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1204) 	int more_entries = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1205) 	struct iso_directory_record *tmpde = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1206) 	struct iso_inode_info *ei = ISOFS_I(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1207) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1208) 	inode->i_size = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1209) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1210) 	/* The first 16 blocks are reserved as the System Area.  Thus,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1211) 	 * no inodes can appear in block 0.  We use this to flag that
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1212) 	 * this is the last section. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1213) 	ei->i_next_section_block = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1214) 	ei->i_next_section_offset = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1215) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1216) 	block = ei->i_iget5_block;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1217) 	offset = ei->i_iget5_offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1218) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1219) 	do {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1220) 		struct iso_directory_record *de;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1221) 		unsigned int de_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1222) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1223) 		if (!bh) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1224) 			bh = sb_bread(inode->i_sb, block);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1225) 			if (!bh)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1226) 				goto out_noread;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1227) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1228) 		de = (struct iso_directory_record *) (bh->b_data + offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1229) 		de_len = *(unsigned char *) de;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1230) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1231) 		if (de_len == 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1232) 			brelse(bh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1233) 			bh = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1234) 			++block;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1235) 			offset = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1236) 			continue;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1237) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1238) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1239) 		block_saved = block;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1240) 		offset_saved = offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1241) 		offset += de_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1242) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1243) 		/* Make sure we have a full directory entry */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1244) 		if (offset >= bufsize) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1245) 			int slop = bufsize - offset + de_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1246) 			if (!tmpde) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1247) 				tmpde = kmalloc(256, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1248) 				if (!tmpde)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1249) 					goto out_nomem;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1250) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1251) 			memcpy(tmpde, de, slop);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1252) 			offset &= bufsize - 1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1253) 			block++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1254) 			brelse(bh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1255) 			bh = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1256) 			if (offset) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1257) 				bh = sb_bread(inode->i_sb, block);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1258) 				if (!bh)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1259) 					goto out_noread;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1260) 				memcpy((void *)tmpde+slop, bh->b_data, offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1261) 			}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1262) 			de = tmpde;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1263) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1264) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1265) 		inode->i_size += isonum_733(de->size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1266) 		if (i == 1) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1267) 			ei->i_next_section_block = block_saved;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1268) 			ei->i_next_section_offset = offset_saved;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1269) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1270) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1271) 		more_entries = de->flags[-high_sierra] & 0x80;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1272) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1273) 		i++;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1274) 		if (i > 100)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1275) 			goto out_toomany;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1276) 	} while (more_entries);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1277) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1278) 	kfree(tmpde);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1279) 	if (bh)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1280) 		brelse(bh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1281) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1282) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1283) out_nomem:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1284) 	if (bh)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1285) 		brelse(bh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1286) 	return -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1287) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1288) out_noread:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1289) 	printk(KERN_INFO "ISOFS: unable to read i-node block %lu\n", block);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1290) 	kfree(tmpde);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1291) 	return -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1292) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1293) out_toomany:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1294) 	printk(KERN_INFO "%s: More than 100 file sections ?!?, aborting...\n"
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1295) 		"isofs_read_level3_size: inode=%lu\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1296) 		__func__, inode->i_ino);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1297) 	goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1298) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1299) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1300) static int isofs_read_inode(struct inode *inode, int relocated)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1301) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1302) 	struct super_block *sb = inode->i_sb;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1303) 	struct isofs_sb_info *sbi = ISOFS_SB(sb);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1304) 	unsigned long bufsize = ISOFS_BUFFER_SIZE(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1305) 	unsigned long block;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1306) 	int high_sierra = sbi->s_high_sierra;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1307) 	struct buffer_head *bh;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1308) 	struct iso_directory_record *de;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1309) 	struct iso_directory_record *tmpde = NULL;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1310) 	unsigned int de_len;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1311) 	unsigned long offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1312) 	struct iso_inode_info *ei = ISOFS_I(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1313) 	int ret = -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1314) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1315) 	block = ei->i_iget5_block;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1316) 	bh = sb_bread(inode->i_sb, block);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1317) 	if (!bh)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1318) 		goto out_badread;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1319) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1320) 	offset = ei->i_iget5_offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1321) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1322) 	de = (struct iso_directory_record *) (bh->b_data + offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1323) 	de_len = *(unsigned char *) de;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1324) 	if (de_len < sizeof(struct iso_directory_record))
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1325) 		goto fail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1326) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1327) 	if (offset + de_len > bufsize) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1328) 		int frag1 = bufsize - offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1329) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1330) 		tmpde = kmalloc(de_len, GFP_KERNEL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1331) 		if (!tmpde) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1332) 			ret = -ENOMEM;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1333) 			goto fail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1334) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1335) 		memcpy(tmpde, bh->b_data + offset, frag1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1336) 		brelse(bh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1337) 		bh = sb_bread(inode->i_sb, ++block);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1338) 		if (!bh)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1339) 			goto out_badread;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1340) 		memcpy((char *)tmpde+frag1, bh->b_data, de_len - frag1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1341) 		de = tmpde;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1342) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1343) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1344) 	inode->i_ino = isofs_get_ino(ei->i_iget5_block,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1345) 					ei->i_iget5_offset,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1346) 					ISOFS_BUFFER_BITS(inode));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1347) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1348) 	/* Assume it is a normal-format file unless told otherwise */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1349) 	ei->i_file_format = isofs_file_normal;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1350) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1351) 	if (de->flags[-high_sierra] & 2) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1352) 		if (sbi->s_dmode != ISOFS_INVALID_MODE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1353) 			inode->i_mode = S_IFDIR | sbi->s_dmode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1354) 		else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1355) 			inode->i_mode = S_IFDIR | S_IRUGO | S_IXUGO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1356) 		set_nlink(inode, 1);	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1357) 					 * Set to 1.  We know there are 2, but
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1358) 					 * the find utility tries to optimize
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1359) 					 * if it is 2, and it screws up.  It is
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1360) 					 * easier to give 1 which tells find to
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1361) 					 * do it the hard way.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1362) 					 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1363) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1364) 		if (sbi->s_fmode != ISOFS_INVALID_MODE) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1365) 			inode->i_mode = S_IFREG | sbi->s_fmode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1366) 		} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1367) 			/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1368) 			 * Set default permissions: r-x for all.  The disc
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1369) 			 * could be shared with DOS machines so virtually
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1370) 			 * anything could be a valid executable.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1371) 			 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1372) 			inode->i_mode = S_IFREG | S_IRUGO | S_IXUGO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1373) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1374) 		set_nlink(inode, 1);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1375) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1376) 	inode->i_uid = sbi->s_uid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1377) 	inode->i_gid = sbi->s_gid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1378) 	inode->i_blocks = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1379) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1380) 	ei->i_format_parm[0] = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1381) 	ei->i_format_parm[1] = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1382) 	ei->i_format_parm[2] = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1383) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1384) 	ei->i_section_size = isonum_733(de->size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1385) 	if (de->flags[-high_sierra] & 0x80) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1386) 		ret = isofs_read_level3_size(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1387) 		if (ret < 0)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1388) 			goto fail;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1389) 		ret = -EIO;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1390) 	} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1391) 		ei->i_next_section_block = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1392) 		ei->i_next_section_offset = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1393) 		inode->i_size = isonum_733(de->size);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1394) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1395) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1396) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1397) 	 * Some dipshit decided to store some other bit of information
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1398) 	 * in the high byte of the file length.  Truncate size in case
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1399) 	 * this CDROM was mounted with the cruft option.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1400) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1401) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1402) 	if (sbi->s_cruft)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1403) 		inode->i_size &= 0x00ffffff;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1404) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1405) 	if (de->interleave[0]) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1406) 		printk(KERN_DEBUG "ISOFS: Interleaved files not (yet) supported.\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1407) 		inode->i_size = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1408) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1409) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1410) 	/* I have no idea what file_unit_size is used for, so
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1411) 	   we will flag it for now */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1412) 	if (de->file_unit_size[0] != 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1413) 		printk(KERN_DEBUG "ISOFS: File unit size != 0 for ISO file (%ld).\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1414) 			inode->i_ino);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1415) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1416) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1417) 	/* I have no idea what other flag bits are used for, so
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1418) 	   we will flag it for now */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1419) #ifdef DEBUG
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1420) 	if((de->flags[-high_sierra] & ~2)!= 0){
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1421) 		printk(KERN_DEBUG "ISOFS: Unusual flag settings for ISO file "
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1422) 				"(%ld %x).\n",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1423) 			inode->i_ino, de->flags[-high_sierra]);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1424) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1425) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1426) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1427) 	inode->i_mtime.tv_sec =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1428) 	inode->i_atime.tv_sec =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1429) 	inode->i_ctime.tv_sec = iso_date(de->date, high_sierra);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1430) 	inode->i_mtime.tv_nsec =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1431) 	inode->i_atime.tv_nsec =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1432) 	inode->i_ctime.tv_nsec = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1433) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1434) 	ei->i_first_extent = (isonum_733(de->extent) +
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1435) 			isonum_711(de->ext_attr_length));
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1436) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1437) 	/* Set the number of blocks for stat() - should be done before RR */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1438) 	inode->i_blocks = (inode->i_size + 511) >> 9;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1439) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1440) 	/*
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1441) 	 * Now test for possible Rock Ridge extensions which will override
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1442) 	 * some of these numbers in the inode structure.
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1443) 	 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1444) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1445) 	if (!high_sierra) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1446) 		parse_rock_ridge_inode(de, inode, relocated);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1447) 		/* if we want uid/gid set, override the rock ridge setting */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1448) 		if (sbi->s_uid_set)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1449) 			inode->i_uid = sbi->s_uid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1450) 		if (sbi->s_gid_set)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1451) 			inode->i_gid = sbi->s_gid;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1452) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1453) 	/* Now set final access rights if overriding rock ridge setting */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1454) 	if (S_ISDIR(inode->i_mode) && sbi->s_overriderockperm &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1455) 	    sbi->s_dmode != ISOFS_INVALID_MODE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1456) 		inode->i_mode = S_IFDIR | sbi->s_dmode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1457) 	if (S_ISREG(inode->i_mode) && sbi->s_overriderockperm &&
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1458) 	    sbi->s_fmode != ISOFS_INVALID_MODE)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1459) 		inode->i_mode = S_IFREG | sbi->s_fmode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1460) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1461) 	/* Install the inode operations vector */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1462) 	if (S_ISREG(inode->i_mode)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1463) 		inode->i_fop = &generic_ro_fops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1464) 		switch (ei->i_file_format) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1465) #ifdef CONFIG_ZISOFS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1466) 		case isofs_file_compressed:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1467) 			inode->i_data.a_ops = &zisofs_aops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1468) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1469) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1470) 		default:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1471) 			inode->i_data.a_ops = &isofs_aops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1472) 			break;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1473) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1474) 	} else if (S_ISDIR(inode->i_mode)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1475) 		inode->i_op = &isofs_dir_inode_operations;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1476) 		inode->i_fop = &isofs_dir_operations;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1477) 	} else if (S_ISLNK(inode->i_mode)) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1478) 		inode->i_op = &page_symlink_inode_operations;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1479) 		inode_nohighmem(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1480) 		inode->i_data.a_ops = &isofs_symlink_aops;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1481) 	} else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1482) 		/* XXX - parse_rock_ridge_inode() had already set i_rdev. */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1483) 		init_special_inode(inode, inode->i_mode, inode->i_rdev);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1484) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1485) 	ret = 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1486) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1487) 	kfree(tmpde);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1488) 	if (bh)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1489) 		brelse(bh);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1490) 	return ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1491) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1492) out_badread:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1493) 	printk(KERN_WARNING "ISOFS: unable to read i-node block\n");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1494) fail:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1495) 	goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1496) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1497) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1498) struct isofs_iget5_callback_data {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1499) 	unsigned long block;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1500) 	unsigned long offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1501) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1502) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1503) static int isofs_iget5_test(struct inode *ino, void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1504) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1505) 	struct iso_inode_info *i = ISOFS_I(ino);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1506) 	struct isofs_iget5_callback_data *d =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1507) 		(struct isofs_iget5_callback_data*)data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1508) 	return (i->i_iget5_block == d->block)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1509) 		&& (i->i_iget5_offset == d->offset);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1510) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1511) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1512) static int isofs_iget5_set(struct inode *ino, void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1513) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1514) 	struct iso_inode_info *i = ISOFS_I(ino);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1515) 	struct isofs_iget5_callback_data *d =
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1516) 		(struct isofs_iget5_callback_data*)data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1517) 	i->i_iget5_block = d->block;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1518) 	i->i_iget5_offset = d->offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1519) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1520) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1521) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1522) /* Store, in the inode's containing structure, the block and block
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1523)  * offset that point to the underlying meta-data for the inode.  The
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1524)  * code below is otherwise similar to the iget() code in
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1525)  * include/linux/fs.h */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1526) struct inode *__isofs_iget(struct super_block *sb,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1527) 			   unsigned long block,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1528) 			   unsigned long offset,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1529) 			   int relocated)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1530) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1531) 	unsigned long hashval;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1532) 	struct inode *inode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1533) 	struct isofs_iget5_callback_data data;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1534) 	long ret;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1535) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1536) 	if (offset >= 1ul << sb->s_blocksize_bits)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1537) 		return ERR_PTR(-EINVAL);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1538) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1539) 	data.block = block;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1540) 	data.offset = offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1541) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1542) 	hashval = (block << sb->s_blocksize_bits) | offset;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1543) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1544) 	inode = iget5_locked(sb, hashval, &isofs_iget5_test,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1545) 				&isofs_iget5_set, &data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1546) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1547) 	if (!inode)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1548) 		return ERR_PTR(-ENOMEM);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1549) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1550) 	if (inode->i_state & I_NEW) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1551) 		ret = isofs_read_inode(inode, relocated);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1552) 		if (ret < 0) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1553) 			iget_failed(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1554) 			inode = ERR_PTR(ret);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1555) 		} else {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1556) 			unlock_new_inode(inode);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1557) 		}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1558) 	}
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1559) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1560) 	return inode;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1561) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1562) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1563) static struct dentry *isofs_mount(struct file_system_type *fs_type,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1564) 	int flags, const char *dev_name, void *data)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1565) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1566) 	return mount_bdev(fs_type, flags, dev_name, data, isofs_fill_super);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1567) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1568) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1569) static struct file_system_type iso9660_fs_type = {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1570) 	.owner		= THIS_MODULE,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1571) 	.name		= "iso9660",
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1572) 	.mount		= isofs_mount,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1573) 	.kill_sb	= kill_block_super,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1574) 	.fs_flags	= FS_REQUIRES_DEV,
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1575) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1576) MODULE_ALIAS_FS("iso9660");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1577) MODULE_ALIAS("iso9660");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1578) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1579) static int __init init_iso9660_fs(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1580) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1581) 	int err = init_inodecache();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1582) 	if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1583) 		goto out;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1584) #ifdef CONFIG_ZISOFS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1585) 	err = zisofs_init();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1586) 	if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1587) 		goto out1;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1588) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1589) 	err = register_filesystem(&iso9660_fs_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1590) 	if (err)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1591) 		goto out2;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1592) 	return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1593) out2:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1594) #ifdef CONFIG_ZISOFS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1595) 	zisofs_cleanup();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1596) out1:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1597) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1598) 	destroy_inodecache();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1599) out:
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1600) 	return err;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1601) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1602) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1603) static void __exit exit_iso9660_fs(void)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1604) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1605)         unregister_filesystem(&iso9660_fs_type);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1606) #ifdef CONFIG_ZISOFS
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1607) 	zisofs_cleanup();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1608) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1609) 	destroy_inodecache();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1610) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1611) 
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1612) module_init(init_iso9660_fs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1613) module_exit(exit_iso9660_fs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1614) MODULE_LICENSE("GPL");
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1615) MODULE_IMPORT_NS(ANDROID_GKI_VFS_EXPORT_ONLY);