Whamcloud - gitweb
libext2fs: add the ext2fs_symlink() function
authorDarren Hart <dvhart@infradead.org>
Fri, 4 Jan 2013 20:00:58 +0000 (12:00 -0800)
committerTheodore Ts'o <tytso@mit.edu>
Wed, 16 Jan 2013 19:09:17 +0000 (14:09 -0500)
commitf01c1a6bce5e6674cbfa5260db1691bca01a4410
tree077beeb6e772bc6b8bef8ebbb3f88ea2afa0e6bc
parent53f2a1eaf051b9ef8a2927cdd7d6de281c8d5a03
libext2fs: add the ext2fs_symlink() function

Creating symlinks is a complex affair when accounting for slowlinks.

Create a new function, ext2fs_symlink(), modeled after ext2fs_mkdir().
Like ext2fs_mkdir(), ext2fs_symlink() takes on the task of allocating a
new inode and block (for slowlinks), setting up sane default values in
the inode, copying the target path to either the inode (for fastlinks)
or to the first block (for slowlinks), and accounting for the inode and
block stats.  Disallow link targets longer than blocksize as the Linux
kernel prevents this.

It does not attempt to expand the parent directory, instead returning
EXT2_ET_DIR_NO_SPACE and leaving it to the caller to expand just as
ext2fs_mkdir() does.  Ideally, I think both of these functions should
make a single attempt to expand the directory.

[ Fixed a few bugs discovered when creating a test case for ext2fs_symlink() ]

Signed-off-by: Darren Hart <dvhart@infradead.org>
Signed-off-by: "Theodore Ts'o" <tytso@mit.edu>
Cc: "Darrick J. Wong" <darrick.wong@oracle.com>
Cc: Andreas Dilger <adilger@dilger.ca>
debian/e2fslibs.symbols
lib/ext2fs/Makefile.in
lib/ext2fs/ext2_err.et.in
lib/ext2fs/symlink.c [new file with mode: 0644]