1 /* Copyright 2002, 2003, 2005 by Hans Reiser, licensing governed by reiser4/README */
3 #include "../../inode.h"
5 #include <linux/types.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
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
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
);
54 /* FIXME-VS: Make sure that symlink->i_private is not attached
56 INODE_SET_FIELD(symlink
, i_size
, 0);
58 assert("vs-849", symlink
->i_private
59 && reiser4_inode_get_flag(symlink
,
60 REISER4_GENERIC_PTR_USED
));
62 !memcmp((char *)symlink
->i_private
, data
->name
,
63 (size_t) symlink
->i_size
+ 1));
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
)
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
);
88 c-indentation-style: "K&R"