Blame view

fs/ext4/symlink.c 1.73 KB
b24413180   Greg Kroah-Hartman   License cleanup: ...
1
  // SPDX-License-Identifier: GPL-2.0
ac27a0ec1   Dave Kleikamp   [PATCH] ext4: ini...
2
  /*
617ba13b3   Mingming Cao   [PATCH] ext4: ren...
3
   *  linux/fs/ext4/symlink.c
ac27a0ec1   Dave Kleikamp   [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   Mingming Cao   [PATCH] ext4: ren...
18
   *  ext4 symlink handling code
ac27a0ec1   Dave Kleikamp   [PATCH] ext4: ini...
19
20
21
   */
  
  #include <linux/fs.h>
ac27a0ec1   Dave Kleikamp   [PATCH] ext4: ini...
22
  #include <linux/namei.h>
3dcf54515   Christoph Hellwig   ext4: move header...
23
  #include "ext4.h"
ac27a0ec1   Dave Kleikamp   [PATCH] ext4: ini...
24
  #include "xattr.h"
6b2553918   Al Viro   replace ->follow_...
25
  static const char *ext4_encrypted_get_link(struct dentry *dentry,
fceef393a   Al Viro   switch ->get_link...
26
27
  					   struct inode *inode,
  					   struct delayed_call *done)
ac27a0ec1   Dave Kleikamp   [PATCH] ext4: ini...
28
  {
f348c2523   Theodore Ts'o   ext4 crypto: add ...
29
  	struct page *cpage = NULL;
6a9269c83   Eric Biggers   ext4: switch to f...
30
31
32
  	const void *caddr;
  	unsigned int max_size;
  	const char *paddr;
f348c2523   Theodore Ts'o   ext4 crypto: add ...
33

6b2553918   Al Viro   replace ->follow_...
34
35
  	if (!dentry)
  		return ERR_PTR(-ECHILD);
f348c2523   Theodore Ts'o   ext4 crypto: add ...
36
  	if (ext4_inode_is_fast_symlink(inode)) {
6a9269c83   Eric Biggers   ext4: switch to f...
37
  		caddr = EXT4_I(inode)->i_data;
9ec3a646f   Linus Torvalds   Merge branch 'for...
38
  		max_size = sizeof(EXT4_I(inode)->i_data);
f348c2523   Theodore Ts'o   ext4 crypto: add ...
39
40
  	} else {
  		cpage = read_mapping_page(inode->i_mapping, 0, NULL);
b7236e21d   Theodore Ts'o   ext4 crypto: reor...
41
  		if (IS_ERR(cpage))
680baacbc   Al Viro   new ->follow_link...
42
  			return ERR_CAST(cpage);
21fc61c73   Al Viro   don't put symlink...
43
  		caddr = page_address(cpage);
6a9269c83   Eric Biggers   ext4: switch to f...
44
  		max_size = inode->i_sb->s_blocksize;
f348c2523   Theodore Ts'o   ext4 crypto: add ...
45
  	}
6a9269c83   Eric Biggers   ext4: switch to f...
46
  	paddr = fscrypt_get_symlink(inode, caddr, max_size, done);
21fc61c73   Al Viro   don't put symlink...
47
  	if (cpage)
09cbfeaf1   Kirill A. Shutemov   mm, fs: get rid o...
48
  		put_page(cpage);
fceef393a   Al Viro   switch ->get_link...
49
  	return paddr;
f348c2523   Theodore Ts'o   ext4 crypto: add ...
50
  }
a7a67e8a0   Al Viro   ext4: split inode...
51
  const struct inode_operations ext4_encrypted_symlink_inode_operations = {
6b2553918   Al Viro   replace ->follow_...
52
  	.get_link	= ext4_encrypted_get_link,
a7a67e8a0   Al Viro   ext4: split inode...
53
  	.setattr	= ext4_setattr,
99652ea56   David Howells   ext4: Add statx s...
54
  	.getattr	= ext4_getattr,
a7a67e8a0   Al Viro   ext4: split inode...
55
  	.listxattr	= ext4_listxattr,
a7a67e8a0   Al Viro   ext4: split inode...
56
  };
f348c2523   Theodore Ts'o   ext4 crypto: add ...
57

754661f14   Arjan van de Ven   [PATCH] mark stru...
58
  const struct inode_operations ext4_symlink_inode_operations = {
6b2553918   Al Viro   replace ->follow_...
59
  	.get_link	= page_get_link,
256a45354   Dmitry Monakhov   ext4: symlink mus...
60
  	.setattr	= ext4_setattr,
99652ea56   David Howells   ext4: Add statx s...
61
  	.getattr	= ext4_getattr,
617ba13b3   Mingming Cao   [PATCH] ext4: ren...
62
  	.listxattr	= ext4_listxattr,
ac27a0ec1   Dave Kleikamp   [PATCH] ext4: ini...
63
  };
754661f14   Arjan van de Ven   [PATCH] mark stru...
64
  const struct inode_operations ext4_fast_symlink_inode_operations = {
6b2553918   Al Viro   replace ->follow_...
65
  	.get_link	= simple_get_link,
256a45354   Dmitry Monakhov   ext4: symlink mus...
66
  	.setattr	= ext4_setattr,
99652ea56   David Howells   ext4: Add statx s...
67
  	.getattr	= ext4_getattr,
617ba13b3   Mingming Cao   [PATCH] ext4: ren...
68
  	.listxattr	= ext4_listxattr,
ac27a0ec1   Dave Kleikamp   [PATCH] ext4: ini...
69
  };