Commit | Line | Data |
---|---|---|
b2441318 | 1 | // SPDX-License-Identifier: GPL-2.0 |
ac27a0ec | 2 | /* |
617ba13b | 3 | * linux/fs/ext4/symlink.c |
ac27a0ec DK |
4 | * |
5 | * Only fast symlinks left here - the rest is done by generic code. AV, 1999 | |
6 | * | |
7 | * Copyright (C) 1992, 1993, 1994, 1995 | |
8 | * Remy Card (card@masi.ibp.fr) | |
9 | * Laboratoire MASI - Institut Blaise Pascal | |
10 | * Universite Pierre et Marie Curie (Paris VI) | |
11 | * | |
12 | * from | |
13 | * | |
14 | * linux/fs/minix/symlink.c | |
15 | * | |
16 | * Copyright (C) 1991, 1992 Linus Torvalds | |
17 | * | |
617ba13b | 18 | * ext4 symlink handling code |
ac27a0ec DK |
19 | */ |
20 | ||
21 | #include <linux/fs.h> | |
ac27a0ec | 22 | #include <linux/namei.h> |
3dcf5451 | 23 | #include "ext4.h" |
ac27a0ec DK |
24 | #include "xattr.h" |
25 | ||
6b255391 | 26 | static const char *ext4_encrypted_get_link(struct dentry *dentry, |
fceef393 AV |
27 | struct inode *inode, |
28 | struct delayed_call *done) | |
f348c252 TT |
29 | { |
30 | struct page *cpage = NULL; | |
6a9269c8 EB |
31 | const void *caddr; |
32 | unsigned int max_size; | |
33 | const char *paddr; | |
f348c252 | 34 | |
6b255391 AV |
35 | if (!dentry) |
36 | return ERR_PTR(-ECHILD); | |
37 | ||
f348c252 | 38 | if (ext4_inode_is_fast_symlink(inode)) { |
6a9269c8 | 39 | caddr = EXT4_I(inode)->i_data; |
9ec3a646 | 40 | max_size = sizeof(EXT4_I(inode)->i_data); |
f348c252 TT |
41 | } else { |
42 | cpage = read_mapping_page(inode->i_mapping, 0, NULL); | |
b7236e21 | 43 | if (IS_ERR(cpage)) |
680baacb | 44 | return ERR_CAST(cpage); |
21fc61c7 | 45 | caddr = page_address(cpage); |
6a9269c8 | 46 | max_size = inode->i_sb->s_blocksize; |
f348c252 TT |
47 | } |
48 | ||
6a9269c8 | 49 | paddr = fscrypt_get_symlink(inode, caddr, max_size, done); |
21fc61c7 | 50 | if (cpage) |
09cbfeaf | 51 | put_page(cpage); |
fceef393 | 52 | return paddr; |
f348c252 TT |
53 | } |
54 | ||
a7a67e8a | 55 | const struct inode_operations ext4_encrypted_symlink_inode_operations = { |
6b255391 | 56 | .get_link = ext4_encrypted_get_link, |
a7a67e8a | 57 | .setattr = ext4_setattr, |
99652ea5 | 58 | .getattr = ext4_getattr, |
a7a67e8a | 59 | .listxattr = ext4_listxattr, |
a7a67e8a | 60 | }; |
f348c252 | 61 | |
754661f1 | 62 | const struct inode_operations ext4_symlink_inode_operations = { |
6b255391 | 63 | .get_link = page_get_link, |
256a4535 | 64 | .setattr = ext4_setattr, |
99652ea5 | 65 | .getattr = ext4_getattr, |
617ba13b | 66 | .listxattr = ext4_listxattr, |
ac27a0ec DK |
67 | }; |
68 | ||
754661f1 | 69 | const struct inode_operations ext4_fast_symlink_inode_operations = { |
6b255391 | 70 | .get_link = simple_get_link, |
256a4535 | 71 | .setattr = ext4_setattr, |
99652ea5 | 72 | .getattr = ext4_getattr, |
617ba13b | 73 | .listxattr = ext4_listxattr, |
ac27a0ec | 74 | }; |