Commit 536baf02f650f4547f105386878b4736fbc181e8

Authored by Steven Whitehouse
1 parent 2286dbfad1

GFS2: Move gfs2_readlinki into ops_inode.c

Move gfs2_readlinki into ops_inode.c and make it static

Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>

Showing 3 changed files with 56 additions and 58 deletions Side-by-side Diff

... ... @@ -1085,63 +1085,7 @@
1085 1085 return 0;
1086 1086 }
1087 1087  
1088   -/**
1089   - * gfs2_readlinki - return the contents of a symlink
1090   - * @ip: the symlink's inode
1091   - * @buf: a pointer to the buffer to be filled
1092   - * @len: a pointer to the length of @buf
1093   - *
1094   - * If @buf is too small, a piece of memory is kmalloc()ed and needs
1095   - * to be freed by the caller.
1096   - *
1097   - * Returns: errno
1098   - */
1099   -
1100   -int gfs2_readlinki(struct gfs2_inode *ip, char **buf, unsigned int *len)
1101   -{
1102   - struct gfs2_holder i_gh;
1103   - struct buffer_head *dibh;
1104   - unsigned int x;
1105   - int error;
1106   -
1107   - gfs2_holder_init(ip->i_gl, LM_ST_SHARED, 0, &i_gh);
1108   - error = gfs2_glock_nq(&i_gh);
1109   - if (error) {
1110   - gfs2_holder_uninit(&i_gh);
1111   - return error;
1112   - }
1113   -
1114   - if (!ip->i_disksize) {
1115   - gfs2_consist_inode(ip);
1116   - error = -EIO;
1117   - goto out;
1118   - }
1119   -
1120   - error = gfs2_meta_inode_buffer(ip, &dibh);
1121   - if (error)
1122   - goto out;
1123   -
1124   - x = ip->i_disksize + 1;
1125   - if (x > *len) {
1126   - *buf = kmalloc(x, GFP_NOFS);
1127   - if (!*buf) {
1128   - error = -ENOMEM;
1129   - goto out_brelse;
1130   - }
1131   - }
1132   -
1133   - memcpy(*buf, dibh->b_data + sizeof(struct gfs2_dinode), x);
1134   - *len = x;
1135   -
1136   -out_brelse:
1137   - brelse(dibh);
1138   -out:
1139   - gfs2_glock_dq_uninit(&i_gh);
1140   - return error;
1141   -}
1142   -
1143   -static int
1144   -__gfs2_setattr_simple(struct gfs2_inode *ip, struct iattr *attr)
  1088 +static int __gfs2_setattr_simple(struct gfs2_inode *ip, struct iattr *attr)
1145 1089 {
1146 1090 struct buffer_head *dibh;
1147 1091 int error;
... ... @@ -99,7 +99,6 @@
99 99 extern int gfs2_unlink_ok(struct gfs2_inode *dip, const struct qstr *name,
100 100 const struct gfs2_inode *ip);
101 101 extern int gfs2_permission(struct inode *inode, int mask);
102   -extern int gfs2_readlinki(struct gfs2_inode *ip, char **buf, unsigned int *len);
103 102 extern int gfs2_setattr_simple(struct gfs2_inode *ip, struct iattr *attr);
104 103 extern struct inode *gfs2_lookup_simple(struct inode *dip, const char *name);
105 104 extern void gfs2_dinode_out(const struct gfs2_inode *ip, void *buf);
... ... @@ -938,6 +938,61 @@
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 +
  952 +static 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 +
  988 +out_brelse:
  989 + brelse(dibh);
  990 +out:
  991 + gfs2_glock_dq_uninit(&i_gh);
  992 + return error;
  993 +}
  994 +
  995 +/**
941 996 * gfs2_readlink - Read the value of a symlink
942 997 * @dentry: the symlink
943 998 * @buf: the buffer to read the symlink data into