ecryptfs: make show_options reflect actual mount options

Change ecryptfs_show_options to reflect the actual mount options in use.
Note that this does away with the "dir=" output, which is not a valid mount
option and appears to be unused.

Mount options such as "ecryptfs_verbose" and "ecryptfs_xattr_metadata" are
somewhat indeterminate for a given fs, but in any case the reported mount
options can be used in a new mount command to get the same behavior.

[akpm@linux-foundation.org: fix printk warning]
Signed-off-by: Eric Sandeen <sandeen@redhat.com>
Acked-by: Michael Halcrow <mhalcrow@us.ibm.com>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
Eric Sandeen 2008-02-06 01:38:34 -08:00 committed by Linus Torvalds
parent 8e3a6f16ba
commit 99db6e4a97

View File

@ -156,32 +156,42 @@ static void ecryptfs_clear_inode(struct inode *inode)
/** /**
* ecryptfs_show_options * ecryptfs_show_options
* *
* Prints the directory we are currently mounted over. * Prints the mount options for a given superblock.
* Returns zero on success; non-zero otherwise * Returns zero; does not fail.
*/ */
static int ecryptfs_show_options(struct seq_file *m, struct vfsmount *mnt) static int ecryptfs_show_options(struct seq_file *m, struct vfsmount *mnt)
{ {
struct super_block *sb = mnt->mnt_sb; struct super_block *sb = mnt->mnt_sb;
struct dentry *lower_root_dentry = ecryptfs_dentry_to_lower(sb->s_root); struct ecryptfs_mount_crypt_stat *mount_crypt_stat =
struct vfsmount *lower_mnt = ecryptfs_dentry_to_lower_mnt(sb->s_root); &ecryptfs_superblock_to_private(sb)->mount_crypt_stat;
char *tmp_page; struct ecryptfs_global_auth_tok *walker;
char *path;
int rc = 0;
tmp_page = (char *)__get_free_page(GFP_KERNEL); mutex_lock(&mount_crypt_stat->global_auth_tok_list_mutex);
if (!tmp_page) { list_for_each_entry(walker,
rc = -ENOMEM; &mount_crypt_stat->global_auth_tok_list,
goto out; mount_crypt_stat_list) {
seq_printf(m, ",ecryptfs_sig=%s", walker->sig);
} }
path = d_path(lower_root_dentry, lower_mnt, tmp_page, PAGE_SIZE); mutex_unlock(&mount_crypt_stat->global_auth_tok_list_mutex);
if (IS_ERR(path)) {
rc = PTR_ERR(path); /* Note this is global and probably shouldn't be a mount option */
goto out; if (ecryptfs_verbosity)
} seq_printf(m, ",ecryptfs_debug=%d\n", ecryptfs_verbosity);
seq_printf(m, ",dir=%s", path);
free_page((unsigned long)tmp_page); seq_printf(m, ",ecryptfs_cipher=%s",
out: mount_crypt_stat->global_default_cipher_name);
return rc;
if (mount_crypt_stat->global_default_cipher_key_size)
seq_printf(m, ",ecryptfs_key_bytes=%zd",
mount_crypt_stat->global_default_cipher_key_size);
if (mount_crypt_stat->flags & ECRYPTFS_PLAINTEXT_PASSTHROUGH_ENABLED)
seq_printf(m, ",ecryptfs_passthrough");
if (mount_crypt_stat->flags & ECRYPTFS_XATTR_METADATA_ENABLED)
seq_printf(m, ",ecryptfs_xattr_metadata");
if (mount_crypt_stat->flags & ECRYPTFS_ENCRYPTED_VIEW_ENABLED)
seq_printf(m, ",ecryptfs_encrypted_view");
return 0;
} }
const struct super_operations ecryptfs_sops = { const struct super_operations ecryptfs_sops = {