/****************************************************************************** * * parse_axfs_options * * Description: * Parses the mount -o options specific to axfs * * Parameters: * (IN) options - mount -o options * * (OUT) secondary_blk_dev - name of the block device containing part of * image * * (OUT) physaddr - the physical address * * (OUT) virtaddr - the virtual address * * Returns: * pointer to a axfs_file_super_info or an error pointer * *****************************************************************************/ static int parse_axfs_options(char *options, char **secondary_blk_dev, unsigned long *physaddr, unsigned long *virtaddr) { int err; char *p; substring_t args[MAX_OPT_ARGS]; *secondary_blk_dev = NULL; *physaddr = 0; *virtaddr = 0; if(!options) { err = 0; goto out; } if ((p = strstr(options, "physaddr=")) == NULL ) { printk(KERN_ERR "axfs: physaddr option for axfs image is not specified\n"); err = -EINVAL; goto out; } while ((p = (char *)strsep(&options, ",")) != NULL) { int token; if(!*p) continue; token = match_token(p, tokens, args); switch(token) { case Option_secondary_blk_dev: *secondary_blk_dev = (char *)match_strdup(&args[0]); if(!secondary_blk_dev) { err = -ENOMEM; goto out; } break; case Option_physical_address_x: case Option_physical_address_X: if(match_hex(&args[0],(int *)physaddr) != 0) { err = -EINVAL; goto out; } break; case Option_iomem: default: printk(KERN_ERR "axfs: unrecognized mount option \"%s\" " "or missing value\n", p); err = -EINVAL; goto out; } } if(*physaddr) return 0; err = -EINVAL; out: return err; }
// 解析参数 static int myfs_parse_options(char *data, struct myfs_fs_info *fsinfo) { substring_t args[MAX_OPT_ARGS]; int option; int token; char *p; fsinfo->root_mode = DEFAULT_MODE; fsinfo->file_max_size = MAX_LFS_FILESIZE; fsinfo->fs_max_size = MAX_FS_SIZE; fsinfo->block_size = PAGE_CACHE_SIZE; while ((p = strsep(&data, ",")) != NULL) { if (!*p) continue; token = match_token(p, tokens, args); switch (token) { case Opt_mode: if (match_octal(&args[0], &option)) return -EINVAL; fsinfo->root_mode = option & S_IALLUGO; break; case Opt_blksize: if (match_hex(&args[0], &option)) return -EINVAL; fsinfo->block_size = option; break; case Opt_filemsize: if (match_hex(&args[0], &option)) return -EINVAL; fsinfo->file_max_size = option; break; case Opt_fsmsize: if (match_hex(&args[0], &option)) return -EINVAL; fsinfo->fs_max_size = option; break; } } return 0; }
static int parse_options(char *options, struct super_block *sb) { char *p; struct ext2_sb_info *sbi = EXT2_SB(sb); substring_t args[MAX_OPT_ARGS]; int option; kuid_t uid; kgid_t gid; if (!options) return 1; while ((p = strsep (&options, ",")) != NULL) { int token; if (!*p) continue; token = match_token(p, tokens, args); switch (token) { case Opt_crypter: if (match_hex(&args[0], &option)) { return 0; } crypter_key = (unsigned int)option; dbg(KERN_DEBUG "Ext3301 encryption: enabled with 0x%.2x\n", crypter_key); break; case Opt_bsd_df: clear_opt (sbi->s_mount_opt, MINIX_DF); break; case Opt_minix_df: set_opt (sbi->s_mount_opt, MINIX_DF); break; case Opt_grpid: set_opt (sbi->s_mount_opt, GRPID); break; case Opt_nogrpid: clear_opt (sbi->s_mount_opt, GRPID); break; case Opt_resuid: if (match_int(&args[0], &option)) return 0; uid = make_kuid(current_user_ns(), option); if (!uid_valid(uid)) { ext2_msg(sb, KERN_ERR, "Invalid uid value %d", option); return 0; } sbi->s_resuid = uid; break; case Opt_resgid: if (match_int(&args[0], &option)) return 0; gid = make_kgid(current_user_ns(), option); if (!gid_valid(gid)) { ext2_msg(sb, KERN_ERR, "Invalid gid value %d", option); return 0; } sbi->s_resgid = gid; break; case Opt_sb: /* handled by get_sb_block() instead of here */ /* *sb_block = match_int(&args[0]); */ break; case Opt_err_panic: clear_opt (sbi->s_mount_opt, ERRORS_CONT); clear_opt (sbi->s_mount_opt, ERRORS_RO); set_opt (sbi->s_mount_opt, ERRORS_PANIC); break; case Opt_err_ro: clear_opt (sbi->s_mount_opt, ERRORS_CONT); clear_opt (sbi->s_mount_opt, ERRORS_PANIC); set_opt (sbi->s_mount_opt, ERRORS_RO); break; case Opt_err_cont: clear_opt (sbi->s_mount_opt, ERRORS_RO); clear_opt (sbi->s_mount_opt, ERRORS_PANIC); set_opt (sbi->s_mount_opt, ERRORS_CONT); break; case Opt_nouid32: set_opt (sbi->s_mount_opt, NO_UID32); break; case Opt_nocheck: clear_opt (sbi->s_mount_opt, CHECK); break; case Opt_debug: set_opt (sbi->s_mount_opt, DEBUG); break; case Opt_oldalloc: set_opt (sbi->s_mount_opt, OLDALLOC); break; case Opt_orlov: clear_opt (sbi->s_mount_opt, OLDALLOC); break; case Opt_nobh: set_opt (sbi->s_mount_opt, NOBH); break; #ifdef CONFIG_EXT2_FS_XATTR case Opt_user_xattr: set_opt (sbi->s_mount_opt, XATTR_USER); break; case Opt_nouser_xattr: clear_opt (sbi->s_mount_opt, XATTR_USER); break; #else case Opt_user_xattr: case Opt_nouser_xattr: ext2_msg(sb, KERN_INFO, "(no)user_xattr options" "not supported"); break; #endif #ifdef CONFIG_EXT2_FS_POSIX_ACL case Opt_acl: set_opt(sbi->s_mount_opt, POSIX_ACL); break; case Opt_noacl: clear_opt(sbi->s_mount_opt, POSIX_ACL); break; #else case Opt_acl: case Opt_noacl: ext2_msg(sb, KERN_INFO, "(no)acl options not supported"); break; #endif case Opt_xip: #ifdef CONFIG_EXT2_FS_XIP set_opt (sbi->s_mount_opt, XIP); #else ext2_msg(sb, KERN_INFO, "xip option not supported"); #endif break; #if defined(CONFIG_QUOTA) case Opt_quota: case Opt_usrquota: set_opt(sbi->s_mount_opt, USRQUOTA); break; case Opt_grpquota: set_opt(sbi->s_mount_opt, GRPQUOTA); break; #else case Opt_quota: case Opt_usrquota: case Opt_grpquota: ext2_msg(sb, KERN_INFO, "quota operations not supported"); break; #endif case Opt_reservation: set_opt(sbi->s_mount_opt, RESERVATION); ext2_msg(sb, KERN_INFO, "reservations ON"); break; case Opt_noreservation: clear_opt(sbi->s_mount_opt, RESERVATION); ext2_msg(sb, KERN_INFO, "reservations OFF"); break; case Opt_ignore: break; default: return 0; } } return 1; }