2
* Copyright (c) 2008-2010 Alper Akcan <alper.akcan@gmail.com>
3
* Copyright (c) 2009-2010 Renzo Davoli <renzo@cs.unibo.it>
5
* This program is free software; you can redistribute it and/or modify
6
* it under the terms of the GNU General Public License as published by
7
* the Free Software Foundation; either version 2 of the License, or
8
* (at your option) any later version.
10
* This program is distributed in the hope that it will be useful,
11
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13
* GNU General Public License for more details.
15
* You should have received a copy of the GNU General Public License
16
* along with this program (in the main directory of the fuse-ext2
17
* distribution in the file COPYING); if not, write to the Free Software
18
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
21
#include "fuse-ext2.h"
23
int op_readlink (const char *path, char *buf, size_t size)
31
struct ext2_inode inode;
34
e2fs = current_ext2fs();
37
debugf("path = %s", path);
39
rt = do_readinode(e2fs, path, &ino, &inode);
41
debugf("do_readinode(%s, &ino, &inode); failed", path);
45
if (!LINUX_S_ISLNK(inode.i_mode)) {
46
debugf("%s is not a link", path);
51
if (ext2fs_inode_data_blocks(e2fs, &inode)) {
52
rc = ext2fs_get_mem(EXT2_BLOCK_SIZE(e2fs->super), &b);
54
debugf("ext2fs_get_mem(EXT2_BLOCK_SIZE(e2fs->super), &b); failed");
58
rc = io_channel_read_blk(e2fs->io, inode.i_block[0], 1, b);
61
debugf("io_channel_read_blk(e2fs->io, inode.i_block[0], 1, b); failed");
67
pathname = (char *) &(inode.i_block[0]);
70
debugf("pathname: %s", pathname);
72
s = (size < strlen(pathname) + 1) ? size : strlen(pathname) + 1;
73
snprintf(buf, s, "%s", pathname);