2 * linux/fs/ext4/symlink.c
4 * Only fast symlinks left here - the rest is done by generic code. AV, 1999
6 * Copyright (C) 1992, 1993, 1994, 1995
7 * Remy Card (card@masi.ibp.fr)
8 * Laboratoire MASI - Institut Blaise Pascal
9 * Universite Pierre et Marie Curie (Paris VI)
13 * linux/fs/minix/symlink.c
15 * Copyright (C) 1991, 1992 Linus Torvalds
17 * ext4 symlink handling code
21 #include <linux/namei.h>
25 #ifdef CONFIG_EXT4_FS_ENCRYPTION
26 static const char *ext4_encrypted_get_link(struct dentry
*dentry
,
28 struct delayed_call
*done
)
30 struct page
*cpage
= NULL
;
31 char *caddr
, *paddr
= NULL
;
32 struct ext4_str cstr
, pstr
;
33 struct ext4_encrypted_symlink_data
*sd
;
34 loff_t size
= min_t(loff_t
, i_size_read(inode
), PAGE_SIZE
- 1);
36 u32 plen
, max_size
= inode
->i_sb
->s_blocksize
;
39 return ERR_PTR(-ECHILD
);
41 res
= ext4_get_encryption_info(inode
);
45 if (ext4_inode_is_fast_symlink(inode
)) {
46 caddr
= (char *) EXT4_I(inode
)->i_data
;
47 max_size
= sizeof(EXT4_I(inode
)->i_data
);
49 cpage
= read_mapping_page(inode
->i_mapping
, 0, NULL
);
51 return ERR_CAST(cpage
);
52 caddr
= page_address(cpage
);
56 /* Symlink is encrypted */
57 sd
= (struct ext4_encrypted_symlink_data
*)caddr
;
58 cstr
.name
= sd
->encrypted_path
;
59 cstr
.len
= le16_to_cpu(sd
->len
);
61 sizeof(struct ext4_encrypted_symlink_data
) - 1) >
63 /* Symlink data on the disk is corrupted */
67 plen
= (cstr
.len
< EXT4_FNAME_CRYPTO_DIGEST_SIZE
*2) ?
68 EXT4_FNAME_CRYPTO_DIGEST_SIZE
*2 : cstr
.len
;
69 paddr
= kmalloc(plen
+ 1, GFP_NOFS
);
76 res
= _ext4_fname_disk_to_usr(inode
, NULL
, &cstr
, &pstr
);
79 /* Null-terminate the name */
83 page_cache_release(cpage
);
84 set_delayed_call(done
, kfree_link
, paddr
);
88 page_cache_release(cpage
);
93 const struct inode_operations ext4_encrypted_symlink_inode_operations
= {
94 .readlink
= generic_readlink
,
95 .get_link
= ext4_encrypted_get_link
,
96 .setattr
= ext4_setattr
,
97 .setxattr
= generic_setxattr
,
98 .getxattr
= generic_getxattr
,
99 .listxattr
= ext4_listxattr
,
100 .removexattr
= generic_removexattr
,
104 const struct inode_operations ext4_symlink_inode_operations
= {
105 .readlink
= generic_readlink
,
106 .get_link
= page_get_link
,
107 .setattr
= ext4_setattr
,
108 .setxattr
= generic_setxattr
,
109 .getxattr
= generic_getxattr
,
110 .listxattr
= ext4_listxattr
,
111 .removexattr
= generic_removexattr
,
114 const struct inode_operations ext4_fast_symlink_inode_operations
= {
115 .readlink
= generic_readlink
,
116 .get_link
= simple_get_link
,
117 .setattr
= ext4_setattr
,
118 .setxattr
= generic_setxattr
,
119 .getxattr
= generic_getxattr
,
120 .listxattr
= ext4_listxattr
,
121 .removexattr
= generic_removexattr
,