Blame view
fs/ext4/symlink.c
2.45 KB
b24413180 License cleanup: ... |
1 |
// SPDX-License-Identifier: GPL-2.0 |
ac27a0ec1 [PATCH] ext4: ini... |
2 |
/* |
617ba13b3 [PATCH] ext4: ren... |
3 |
* linux/fs/ext4/symlink.c |
ac27a0ec1 [PATCH] ext4: ini... |
4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
* * Only fast symlinks left here - the rest is done by generic code. AV, 1999 * * Copyright (C) 1992, 1993, 1994, 1995 * Remy Card (card@masi.ibp.fr) * Laboratoire MASI - Institut Blaise Pascal * Universite Pierre et Marie Curie (Paris VI) * * from * * linux/fs/minix/symlink.c * * Copyright (C) 1991, 1992 Linus Torvalds * |
617ba13b3 [PATCH] ext4: ren... |
18 |
* ext4 symlink handling code |
ac27a0ec1 [PATCH] ext4: ini... |
19 20 21 |
*/ #include <linux/fs.h> |
ac27a0ec1 [PATCH] ext4: ini... |
22 |
#include <linux/namei.h> |
3dcf54515 ext4: move header... |
23 |
#include "ext4.h" |
ac27a0ec1 [PATCH] ext4: ini... |
24 |
#include "xattr.h" |
6b2553918 replace ->follow_... |
25 |
static const char *ext4_encrypted_get_link(struct dentry *dentry, |
fceef393a switch ->get_link... |
26 27 |
struct inode *inode, struct delayed_call *done) |
ac27a0ec1 [PATCH] ext4: ini... |
28 |
{ |
f348c2523 ext4 crypto: add ... |
29 30 |
struct page *cpage = NULL; char *caddr, *paddr = NULL; |
a7550b30a ext4 crypto: migr... |
31 32 |
struct fscrypt_str cstr, pstr; struct fscrypt_symlink_data *sd; |
f348c2523 ext4 crypto: add ... |
33 |
int res; |
a7550b30a ext4 crypto: migr... |
34 |
u32 max_size = inode->i_sb->s_blocksize; |
f348c2523 ext4 crypto: add ... |
35 |
|
6b2553918 replace ->follow_... |
36 37 |
if (!dentry) return ERR_PTR(-ECHILD); |
a7550b30a ext4 crypto: migr... |
38 |
res = fscrypt_get_encryption_info(inode); |
b7236e21d ext4 crypto: reor... |
39 40 |
if (res) return ERR_PTR(res); |
f348c2523 ext4 crypto: add ... |
41 42 |
if (ext4_inode_is_fast_symlink(inode)) { |
9ec3a646f Merge branch 'for... |
43 44 |
caddr = (char *) EXT4_I(inode)->i_data; max_size = sizeof(EXT4_I(inode)->i_data); |
f348c2523 ext4 crypto: add ... |
45 46 |
} else { cpage = read_mapping_page(inode->i_mapping, 0, NULL); |
b7236e21d ext4 crypto: reor... |
47 |
if (IS_ERR(cpage)) |
680baacbc new ->follow_link... |
48 |
return ERR_CAST(cpage); |
21fc61c73 don't put symlink... |
49 |
caddr = page_address(cpage); |
f348c2523 ext4 crypto: add ... |
50 51 52 |
} /* Symlink is encrypted */ |
a7550b30a ext4 crypto: migr... |
53 |
sd = (struct fscrypt_symlink_data *)caddr; |
f348c2523 ext4 crypto: add ... |
54 |
cstr.name = sd->encrypted_path; |
5a1c7f47d ext4: fix an endi... |
55 |
cstr.len = le16_to_cpu(sd->len); |
a7550b30a ext4 crypto: migr... |
56 |
if ((cstr.len + sizeof(struct fscrypt_symlink_data) - 1) > max_size) { |
f348c2523 ext4 crypto: add ... |
57 |
/* Symlink data on the disk is corrupted */ |
6a797d273 ext4: call out CR... |
58 |
res = -EFSCORRUPTED; |
f348c2523 ext4 crypto: add ... |
59 60 |
goto errout; } |
a7550b30a ext4 crypto: migr... |
61 62 63 |
res = fscrypt_fname_alloc_buffer(inode, cstr.len, &pstr); if (res) |
f348c2523 ext4 crypto: add ... |
64 |
goto errout; |
dcce7a46c ext4: fix memory ... |
65 |
paddr = pstr.name; |
a7550b30a ext4 crypto: migr... |
66 67 |
res = fscrypt_fname_disk_to_usr(inode, 0, 0, &cstr, &pstr); |
ef1eb3aa5 fscrypto: make fi... |
68 |
if (res) |
f348c2523 ext4 crypto: add ... |
69 |
goto errout; |
a7550b30a ext4 crypto: migr... |
70 |
|
f348c2523 ext4 crypto: add ... |
71 |
/* Null-terminate the name */ |
ef1eb3aa5 fscrypto: make fi... |
72 |
paddr[pstr.len] = '\0'; |
21fc61c73 don't put symlink... |
73 |
if (cpage) |
09cbfeaf1 mm, fs: get rid o... |
74 |
put_page(cpage); |
fceef393a switch ->get_link... |
75 76 |
set_delayed_call(done, kfree_link, paddr); return paddr; |
f348c2523 ext4 crypto: add ... |
77 |
errout: |
21fc61c73 don't put symlink... |
78 |
if (cpage) |
09cbfeaf1 mm, fs: get rid o... |
79 |
put_page(cpage); |
f348c2523 ext4 crypto: add ... |
80 81 82 |
kfree(paddr); return ERR_PTR(res); } |
a7a67e8a0 ext4: split inode... |
83 |
const struct inode_operations ext4_encrypted_symlink_inode_operations = { |
6b2553918 replace ->follow_... |
84 |
.get_link = ext4_encrypted_get_link, |
a7a67e8a0 ext4: split inode... |
85 |
.setattr = ext4_setattr, |
99652ea56 ext4: Add statx s... |
86 |
.getattr = ext4_getattr, |
a7a67e8a0 ext4: split inode... |
87 |
.listxattr = ext4_listxattr, |
a7a67e8a0 ext4: split inode... |
88 |
}; |
f348c2523 ext4 crypto: add ... |
89 |
|
754661f14 [PATCH] mark stru... |
90 |
const struct inode_operations ext4_symlink_inode_operations = { |
6b2553918 replace ->follow_... |
91 |
.get_link = page_get_link, |
256a45354 ext4: symlink mus... |
92 |
.setattr = ext4_setattr, |
99652ea56 ext4: Add statx s... |
93 |
.getattr = ext4_getattr, |
617ba13b3 [PATCH] ext4: ren... |
94 |
.listxattr = ext4_listxattr, |
ac27a0ec1 [PATCH] ext4: ini... |
95 |
}; |
754661f14 [PATCH] mark stru... |
96 |
const struct inode_operations ext4_fast_symlink_inode_operations = { |
6b2553918 replace ->follow_... |
97 |
.get_link = simple_get_link, |
256a45354 ext4: symlink mus... |
98 |
.setattr = ext4_setattr, |
99652ea56 ext4: Add statx s... |
99 |
.getattr = ext4_getattr, |
617ba13b3 [PATCH] ext4: ren... |
100 |
.listxattr = ext4_listxattr, |
ac27a0ec1 [PATCH] ext4: ini... |
101 |
}; |