Skip to content

Commit

Permalink
---
Browse files Browse the repository at this point in the history
yaml
---
r: 146928
b: refs/heads/master
c: 536baf0
h: refs/heads/master
v: v3
  • Loading branch information
Steven Whitehouse committed May 22, 2009
1 parent fb26920 commit 2fe0d4a
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 59 deletions.
2 changes: 1 addition & 1 deletion [refs]
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
---
refs/heads/master: 2286dbfad1fb622ee2691537e5caaedee4618860
refs/heads/master: 536baf02f650f4547f105386878b4736fbc181e8
58 changes: 1 addition & 57 deletions trunk/fs/gfs2/inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -1085,63 +1085,7 @@ int gfs2_unlink_ok(struct gfs2_inode *dip, const struct qstr *name,
return 0;
}

/**
* gfs2_readlinki - return the contents of a symlink
* @ip: the symlink's inode
* @buf: a pointer to the buffer to be filled
* @len: a pointer to the length of @buf
*
* If @buf is too small, a piece of memory is kmalloc()ed and needs
* to be freed by the caller.
*
* Returns: errno
*/

int gfs2_readlinki(struct gfs2_inode *ip, char **buf, unsigned int *len)
{
struct gfs2_holder i_gh;
struct buffer_head *dibh;
unsigned int x;
int error;

gfs2_holder_init(ip->i_gl, LM_ST_SHARED, 0, &i_gh);
error = gfs2_glock_nq(&i_gh);
if (error) {
gfs2_holder_uninit(&i_gh);
return error;
}

if (!ip->i_disksize) {
gfs2_consist_inode(ip);
error = -EIO;
goto out;
}

error = gfs2_meta_inode_buffer(ip, &dibh);
if (error)
goto out;

x = ip->i_disksize + 1;
if (x > *len) {
*buf = kmalloc(x, GFP_NOFS);
if (!*buf) {
error = -ENOMEM;
goto out_brelse;
}
}

memcpy(*buf, dibh->b_data + sizeof(struct gfs2_dinode), x);
*len = x;

out_brelse:
brelse(dibh);
out:
gfs2_glock_dq_uninit(&i_gh);
return error;
}

static int
__gfs2_setattr_simple(struct gfs2_inode *ip, struct iattr *attr)
static int __gfs2_setattr_simple(struct gfs2_inode *ip, struct iattr *attr)
{
struct buffer_head *dibh;
int error;
Expand Down
1 change: 0 additions & 1 deletion trunk/fs/gfs2/inode.h
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,6 @@ extern struct inode *gfs2_createi(struct gfs2_holder *ghs,
extern int gfs2_unlink_ok(struct gfs2_inode *dip, const struct qstr *name,
const struct gfs2_inode *ip);
extern int gfs2_permission(struct inode *inode, int mask);
extern int gfs2_readlinki(struct gfs2_inode *ip, char **buf, unsigned int *len);
extern int gfs2_setattr_simple(struct gfs2_inode *ip, struct iattr *attr);
extern struct inode *gfs2_lookup_simple(struct inode *dip, const char *name);
extern void gfs2_dinode_out(const struct gfs2_inode *ip, void *buf);
Expand Down
55 changes: 55 additions & 0 deletions trunk/fs/gfs2/ops_inode.c
Original file line number Diff line number Diff line change
Expand Up @@ -937,6 +937,61 @@ static int gfs2_rename(struct inode *odir, struct dentry *odentry,
return error;
}

/**
* gfs2_readlinki - return the contents of a symlink
* @ip: the symlink's inode
* @buf: a pointer to the buffer to be filled
* @len: a pointer to the length of @buf
*
* If @buf is too small, a piece of memory is kmalloc()ed and needs
* to be freed by the caller.
*
* Returns: errno
*/

static int gfs2_readlinki(struct gfs2_inode *ip, char **buf, unsigned int *len)
{
struct gfs2_holder i_gh;
struct buffer_head *dibh;
unsigned int x;
int error;

gfs2_holder_init(ip->i_gl, LM_ST_SHARED, 0, &i_gh);
error = gfs2_glock_nq(&i_gh);
if (error) {
gfs2_holder_uninit(&i_gh);
return error;
}

if (!ip->i_disksize) {
gfs2_consist_inode(ip);
error = -EIO;
goto out;
}

error = gfs2_meta_inode_buffer(ip, &dibh);
if (error)
goto out;

x = ip->i_disksize + 1;
if (x > *len) {
*buf = kmalloc(x, GFP_NOFS);
if (!*buf) {
error = -ENOMEM;
goto out_brelse;
}
}

memcpy(*buf, dibh->b_data + sizeof(struct gfs2_dinode), x);
*len = x;

out_brelse:
brelse(dibh);
out:
gfs2_glock_dq_uninit(&i_gh);
return error;
}

/**
* gfs2_readlink - Read the value of a symlink
* @dentry: the symlink
Expand Down

0 comments on commit 2fe0d4a

Please sign in to comment.