aboutsummaryrefslogtreecommitdiffstats
path: root/fs/gfs2/ops_inode.c
diff options
context:
space:
mode:
Diffstat (limited to 'fs/gfs2/ops_inode.c')
-rw-r--r--fs/gfs2/ops_inode.c55
1 files changed, 55 insertions, 0 deletions
diff --git a/fs/gfs2/ops_inode.c b/fs/gfs2/ops_inode.c
index 5dacd647ff0d..f607f0908cff 100644
--- a/fs/gfs2/ops_inode.c
+++ b/fs/gfs2/ops_inode.c
@@ -938,6 +938,61 @@ out:
938} 938}
939 939
940/** 940/**
941 * gfs2_readlinki - return the contents of a symlink
942 * @ip: the symlink's inode
943 * @buf: a pointer to the buffer to be filled
944 * @len: a pointer to the length of @buf
945 *
946 * If @buf is too small, a piece of memory is kmalloc()ed and needs
947 * to be freed by the caller.
948 *
949 * Returns: errno
950 */
951
952static int gfs2_readlinki(struct gfs2_inode *ip, char **buf, unsigned int *len)
953{
954 struct gfs2_holder i_gh;
955 struct buffer_head *dibh;
956 unsigned int x;
957 int error;
958
959 gfs2_holder_init(ip->i_gl, LM_ST_SHARED, 0, &i_gh);
960 error = gfs2_glock_nq(&i_gh);
961 if (error) {
962 gfs2_holder_uninit(&i_gh);
963 return error;
964 }
965
966 if (!ip->i_disksize) {
967 gfs2_consist_inode(ip);
968 error = -EIO;
969 goto out;
970 }
971
972 error = gfs2_meta_inode_buffer(ip, &dibh);
973 if (error)
974 goto out;
975
976 x = ip->i_disksize + 1;
977 if (x > *len) {
978 *buf = kmalloc(x, GFP_NOFS);
979 if (!*buf) {
980 error = -ENOMEM;
981 goto out_brelse;
982 }
983 }
984
985 memcpy(*buf, dibh->b_data + sizeof(struct gfs2_dinode), x);
986 *len = x;
987
988out_brelse:
989 brelse(dibh);
990out:
991 gfs2_glock_dq_uninit(&i_gh);
992 return error;
993}
994
995/**
941 * gfs2_readlink - Read the value of a symlink 996 * gfs2_readlink - Read the value of a symlink
942 * @dentry: the symlink 997 * @dentry: the symlink
943 * @buf: the buffer to read the symlink data into 998 * @buf: the buffer to read the symlink data into