Dave Kleikamp | ac27a0e | 2006-10-11 01:20:50 -0700 | [diff] [blame] | 1 | /* |
Mingming Cao | 617ba13 | 2006-10-11 01:20:53 -0700 | [diff] [blame] | 2 | * linux/fs/ext4/symlink.c |
Dave Kleikamp | ac27a0e | 2006-10-11 01:20:50 -0700 | [diff] [blame] | 3 | * |
| 4 | * Only fast symlinks left here - the rest is done by generic code. AV, 1999 |
| 5 | * |
| 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) |
| 10 | * |
| 11 | * from |
| 12 | * |
| 13 | * linux/fs/minix/symlink.c |
| 14 | * |
| 15 | * Copyright (C) 1991, 1992 Linus Torvalds |
| 16 | * |
Mingming Cao | 617ba13 | 2006-10-11 01:20:53 -0700 | [diff] [blame] | 17 | * ext4 symlink handling code |
Dave Kleikamp | ac27a0e | 2006-10-11 01:20:50 -0700 | [diff] [blame] | 18 | */ |
| 19 | |
| 20 | #include <linux/fs.h> |
Dave Kleikamp | ac27a0e | 2006-10-11 01:20:50 -0700 | [diff] [blame] | 21 | #include <linux/namei.h> |
Christoph Hellwig | 3dcf545 | 2008-04-29 18:13:32 -0400 | [diff] [blame] | 22 | #include "ext4.h" |
Dave Kleikamp | ac27a0e | 2006-10-11 01:20:50 -0700 | [diff] [blame] | 23 | #include "xattr.h" |
| 24 | |
Al Viro | 6b25539 | 2015-11-17 10:20:54 -0500 | [diff] [blame] | 25 | static const char *ext4_encrypted_get_link(struct dentry *dentry, |
Al Viro | fceef39 | 2015-12-29 15:58:39 -0500 | [diff] [blame] | 26 | struct inode *inode, |
| 27 | struct delayed_call *done) |
Dave Kleikamp | ac27a0e | 2006-10-11 01:20:50 -0700 | [diff] [blame] | 28 | { |
Theodore Ts'o | f348c25 | 2015-04-16 01:55:00 -0400 | [diff] [blame] | 29 | struct page *cpage = NULL; |
Jaegeuk Kim | d919765 | 2018-01-05 10:44:52 -0800 | [diff] [blame] | 30 | const void *caddr; |
| 31 | unsigned int max_size; |
| 32 | const char *paddr; |
Theodore Ts'o | f348c25 | 2015-04-16 01:55:00 -0400 | [diff] [blame] | 33 | |
Al Viro | 6b25539 | 2015-11-17 10:20:54 -0500 | [diff] [blame] | 34 | if (!dentry) |
| 35 | return ERR_PTR(-ECHILD); |
| 36 | |
Theodore Ts'o | f348c25 | 2015-04-16 01:55:00 -0400 | [diff] [blame] | 37 | if (ext4_inode_is_fast_symlink(inode)) { |
Jaegeuk Kim | d919765 | 2018-01-05 10:44:52 -0800 | [diff] [blame] | 38 | caddr = EXT4_I(inode)->i_data; |
Linus Torvalds | 9ec3a64 | 2015-04-26 15:48:49 -0700 | [diff] [blame] | 39 | max_size = sizeof(EXT4_I(inode)->i_data); |
Theodore Ts'o | f348c25 | 2015-04-16 01:55:00 -0400 | [diff] [blame] | 40 | } else { |
| 41 | cpage = read_mapping_page(inode->i_mapping, 0, NULL); |
Theodore Ts'o | b7236e2 | 2015-05-18 13:17:47 -0400 | [diff] [blame] | 42 | if (IS_ERR(cpage)) |
Al Viro | 680baac | 2015-05-02 13:32:22 -0400 | [diff] [blame] | 43 | return ERR_CAST(cpage); |
Al Viro | 21fc61c | 2015-11-17 01:07:57 -0500 | [diff] [blame] | 44 | caddr = page_address(cpage); |
Jaegeuk Kim | d919765 | 2018-01-05 10:44:52 -0800 | [diff] [blame] | 45 | max_size = inode->i_sb->s_blocksize; |
Theodore Ts'o | f348c25 | 2015-04-16 01:55:00 -0400 | [diff] [blame] | 46 | } |
| 47 | |
Jaegeuk Kim | d919765 | 2018-01-05 10:44:52 -0800 | [diff] [blame] | 48 | paddr = fscrypt_get_symlink(inode, caddr, max_size, done); |
Al Viro | 21fc61c | 2015-11-17 01:07:57 -0500 | [diff] [blame] | 49 | if (cpage) |
Kirill A. Shutemov | 09cbfea | 2016-04-01 15:29:47 +0300 | [diff] [blame] | 50 | put_page(cpage); |
Al Viro | fceef39 | 2015-12-29 15:58:39 -0500 | [diff] [blame] | 51 | return paddr; |
Theodore Ts'o | f348c25 | 2015-04-16 01:55:00 -0400 | [diff] [blame] | 52 | } |
| 53 | |
Al Viro | a7a67e8 | 2015-04-27 17:51:30 -0400 | [diff] [blame] | 54 | const struct inode_operations ext4_encrypted_symlink_inode_operations = { |
| 55 | .readlink = generic_readlink, |
Al Viro | 6b25539 | 2015-11-17 10:20:54 -0500 | [diff] [blame] | 56 | .get_link = ext4_encrypted_get_link, |
Al Viro | a7a67e8 | 2015-04-27 17:51:30 -0400 | [diff] [blame] | 57 | .setattr = ext4_setattr, |
Al Viro | a7a67e8 | 2015-04-27 17:51:30 -0400 | [diff] [blame] | 58 | .listxattr = ext4_listxattr, |
Al Viro | a7a67e8 | 2015-04-27 17:51:30 -0400 | [diff] [blame] | 59 | }; |
Theodore Ts'o | f348c25 | 2015-04-16 01:55:00 -0400 | [diff] [blame] | 60 | |
Arjan van de Ven | 754661f | 2007-02-12 00:55:38 -0800 | [diff] [blame] | 61 | const struct inode_operations ext4_symlink_inode_operations = { |
Dave Kleikamp | ac27a0e | 2006-10-11 01:20:50 -0700 | [diff] [blame] | 62 | .readlink = generic_readlink, |
Al Viro | 6b25539 | 2015-11-17 10:20:54 -0500 | [diff] [blame] | 63 | .get_link = page_get_link, |
Dmitry Monakhov | 256a453 | 2010-05-16 02:00:00 -0400 | [diff] [blame] | 64 | .setattr = ext4_setattr, |
Mingming Cao | 617ba13 | 2006-10-11 01:20:53 -0700 | [diff] [blame] | 65 | .listxattr = ext4_listxattr, |
Dave Kleikamp | ac27a0e | 2006-10-11 01:20:50 -0700 | [diff] [blame] | 66 | }; |
| 67 | |
Arjan van de Ven | 754661f | 2007-02-12 00:55:38 -0800 | [diff] [blame] | 68 | const struct inode_operations ext4_fast_symlink_inode_operations = { |
Dave Kleikamp | ac27a0e | 2006-10-11 01:20:50 -0700 | [diff] [blame] | 69 | .readlink = generic_readlink, |
Al Viro | 6b25539 | 2015-11-17 10:20:54 -0500 | [diff] [blame] | 70 | .get_link = simple_get_link, |
Dmitry Monakhov | 256a453 | 2010-05-16 02:00:00 -0400 | [diff] [blame] | 71 | .setattr = ext4_setattr, |
Mingming Cao | 617ba13 | 2006-10-11 01:20:53 -0700 | [diff] [blame] | 72 | .listxattr = ext4_listxattr, |
Dave Kleikamp | ac27a0e | 2006-10-11 01:20:50 -0700 | [diff] [blame] | 73 | }; |