revert-mm-fix-blkdev-size-calculation-in-generic_write_checks
[linux-2.6/linux-trees-mm.git] / fs / reiser4 / plugin / file / symlink.c
blobbcf3ef80c4dcfbcca7dcb28a3a970e534be6eaa4
1 /* Copyright 2002, 2003, 2005 by Hans Reiser, licensing governed by reiser4/README */
3 #include "../../inode.h"
5 #include <linux/types.h>
6 #include <linux/fs.h>
8 /* file plugin methods specific for symlink files
9 (SYMLINK_FILE_PLUGIN_ID) */
11 /* this is implementation of create_object method of file plugin for
12 SYMLINK_FILE_PLUGIN_ID
15 /**
16 * reiser4_create_symlink - create_object of file plugin for SYMLINK_FILE_PLUGIN_ID
17 * @symlink: inode of symlink object
18 * @dir: inode of parent directory
19 * @info: parameters of new object
21 * Inserts stat data with symlink extension where into the tree.
23 int reiser4_create_symlink(struct inode *symlink,
24 struct inode *dir UNUSED_ARG,
25 reiser4_object_create_data *data /* info passed to us
26 * this is filled by
27 * reiser4() syscall
28 * in particular */)
30 int result;
32 assert("nikita-680", symlink != NULL);
33 assert("nikita-681", S_ISLNK(symlink->i_mode));
34 assert("nikita-685", reiser4_inode_get_flag(symlink, REISER4_NO_SD));
35 assert("nikita-682", dir != NULL);
36 assert("nikita-684", data != NULL);
37 assert("nikita-686", data->id == SYMLINK_FILE_PLUGIN_ID);
40 * stat data of symlink has symlink extension in which we store
41 * symlink content, that is, path symlink is pointing to.
43 reiser4_inode_data(symlink)->extmask |= (1 << SYMLINK_STAT);
45 assert("vs-838", symlink->i_private == NULL);
46 symlink->i_private = (void *)data->name;
48 assert("vs-843", symlink->i_size == 0);
49 INODE_SET_FIELD(symlink, i_size, strlen(data->name));
51 /* insert stat data appended with data->name */
52 result = inode_file_plugin(symlink)->write_sd_by_inode(symlink);
53 if (result) {
54 /* FIXME-VS: Make sure that symlink->i_private is not attached
55 to kmalloced data */
56 INODE_SET_FIELD(symlink, i_size, 0);
57 } else {
58 assert("vs-849", symlink->i_private
59 && reiser4_inode_get_flag(symlink,
60 REISER4_GENERIC_PTR_USED));
61 assert("vs-850",
62 !memcmp((char *)symlink->i_private, data->name,
63 (size_t) symlink->i_size + 1));
65 return result;
68 /* this is implementation of destroy_inode method of file plugin for
69 SYMLINK_FILE_PLUGIN_ID
71 void destroy_inode_symlink(struct inode *inode)
73 assert("edward-799",
74 inode_file_plugin(inode) ==
75 file_plugin_by_id(SYMLINK_FILE_PLUGIN_ID));
76 assert("edward-800", !is_bad_inode(inode) && is_inode_loaded(inode));
77 assert("edward-801", reiser4_inode_get_flag(inode,
78 REISER4_GENERIC_PTR_USED));
79 assert("vs-839", S_ISLNK(inode->i_mode));
81 kfree(inode->i_private);
82 inode->i_private = NULL;
83 reiser4_inode_clr_flag(inode, REISER4_GENERIC_PTR_USED);
87 Local variables:
88 c-indentation-style: "K&R"
89 mode-name: "LC"
90 c-basic-offset: 8
91 tab-width: 8
92 fill-column: 80
93 scroll-step: 1
94 End: