static int f2fs_ioc_get_encryption_pwsalt(struct file *filp, unsigned long arg) { struct inode *inode = file_inode(filp); struct f2fs_sb_info *sbi = F2FS_I_SB(inode); int err; if (!f2fs_sb_has_crypto(inode->i_sb)) return -EOPNOTSUPP; if (uuid_is_nonzero(sbi->raw_super->encrypt_pw_salt)) goto got_it; err = mnt_want_write_file(filp); if (err) return err; /* update superblock with uuid */ generate_random_uuid(sbi->raw_super->encrypt_pw_salt); err = f2fs_commit_super(sbi, false); mnt_drop_write_file(filp); if (err) { /* undo new data */ memset(sbi->raw_super->encrypt_pw_salt, 0, 16); return err; } got_it: if (copy_to_user((__u8 __user *)arg, sbi->raw_super->encrypt_pw_salt, 16)) return -EFAULT; return 0; }
static ssize_t features_show(struct f2fs_attr *a, struct f2fs_sb_info *sbi, char *buf) { struct super_block *sb = sbi->sb; int len = 0; if (!sb->s_bdev->bd_part) return snprintf(buf, PAGE_SIZE, "0\n"); if (f2fs_sb_has_crypto(sb)) len += snprintf(buf, PAGE_SIZE - len, "%s", "encryption"); if (f2fs_sb_mounted_blkzoned(sb)) len += snprintf(buf + len, PAGE_SIZE - len, "%s%s", len ? ", " : "", "blkzoned"); if (f2fs_sb_has_extra_attr(sb)) len += snprintf(buf + len, PAGE_SIZE - len, "%s%s", len ? ", " : "", "extra_attr"); if (f2fs_sb_has_project_quota(sb)) len += snprintf(buf + len, PAGE_SIZE - len, "%s%s", len ? ", " : "", "projquota"); if (f2fs_sb_has_inode_chksum(sb)) len += snprintf(buf + len, PAGE_SIZE - len, "%s%s", len ? ", " : "", "inode_checksum"); len += snprintf(buf + len, PAGE_SIZE - len, "\n"); return len; }