As per Jan Engelhardt's request and also a few of my own. It has
been possible to add a few most const to the code as a result of
the change in gfs2_ea_name2type.
Cc: Jan Engelhardt <jengelh@linux01.gwdg.de>
Signed-off-by: Steven Whitehouse <swhiteho@redhat.com>
* Returns: GFS2_EATYPE_XXX
*/
* Returns: GFS2_EATYPE_XXX
*/
-unsigned int gfs2_ea_name2type(const char *name, char **truncated_name)
+unsigned int gfs2_ea_name2type(const char *name, const char **truncated_name)
{
unsigned int type;
if (strncmp(name, "system.", 7) == 0) {
type = GFS2_EATYPE_SYS;
if (truncated_name)
{
unsigned int type;
if (strncmp(name, "system.", 7) == 0) {
type = GFS2_EATYPE_SYS;
if (truncated_name)
- *truncated_name = strchr(name, '.') + 1;
+ *truncated_name = name + sizeof("system.") - 1;
} else if (strncmp(name, "user.", 5) == 0) {
type = GFS2_EATYPE_USR;
if (truncated_name)
} else if (strncmp(name, "user.", 5) == 0) {
type = GFS2_EATYPE_USR;
if (truncated_name)
- *truncated_name = strchr(name, '.') + 1;
+ *truncated_name = name + sizeof("user.") - 1;
} else if (strncmp(name, "security.", 9) == 0) {
type = GFS2_EATYPE_SECURITY;
if (truncated_name)
} else if (strncmp(name, "security.", 9) == 0) {
type = GFS2_EATYPE_SECURITY;
if (truncated_name)
- *truncated_name = strchr(name, '.') + 1;
+ *truncated_name = name + sizeof("security.") - 1;
} else {
type = GFS2_EATYPE_UNUSED;
if (truncated_name)
} else {
type = GFS2_EATYPE_UNUSED;
if (truncated_name)
-unsigned int gfs2_ea_name2type(const char *name, char **truncated_name);
+unsigned int gfs2_ea_name2type(const char *name, const char **truncated_name);
extern struct gfs2_eattr_operations gfs2_system_eaops;
extern struct gfs2_eattr_operations gfs2_system_eaops;
-typedef int (*ea_call_t) (struct gfs2_inode *ip,
- struct buffer_head *bh,
+typedef int (*ea_call_t) (struct gfs2_inode *ip, struct buffer_head *bh,
struct gfs2_ea_header *ea,
struct gfs2_ea_header *ea,
- struct gfs2_ea_header *prev,
- void *private);
+ struct gfs2_ea_header *prev, void *private);
static int ea_foreach_i(struct gfs2_inode *ip, struct buffer_head *bh,
ea_call_t ea_call, void *data)
static int ea_foreach_i(struct gfs2_inode *ip, struct buffer_head *bh,
ea_call_t ea_call, void *data)
for (ea = GFS2_EA_BH2FIRST(bh);; prev = ea, ea = GFS2_EA2NEXT(ea)) {
if (!GFS2_EA_REC_LEN(ea))
goto fail;
for (ea = GFS2_EA_BH2FIRST(bh);; prev = ea, ea = GFS2_EA2NEXT(ea)) {
if (!GFS2_EA_REC_LEN(ea))
goto fail;
- if (!(bh->b_data <= (char *)ea &&
- (char *)GFS2_EA2NEXT(ea) <=
- bh->b_data + bh->b_size))
+ if (!(bh->b_data <= (char *)ea && (char *)GFS2_EA2NEXT(ea) <=
+ bh->b_data + bh->b_size))
goto fail;
if (!GFS2_EATYPE_VALID(ea->ea_type))
goto fail;
goto fail;
if (!GFS2_EATYPE_VALID(ea->ea_type))
goto fail;
u64 *eablk, *end;
int error;
u64 *eablk, *end;
int error;
- error = gfs2_meta_read(ip->i_gl, ip->i_di.di_eattr,
- DIO_START | DIO_WAIT, &bh);
+ error = gfs2_meta_read(ip->i_gl, ip->i_di.di_eattr, DIO_START | DIO_WAIT, &bh);
break;
bn = be64_to_cpu(*eablk);
break;
bn = be64_to_cpu(*eablk);
- error = gfs2_meta_read(ip->i_gl, bn, DIO_START | DIO_WAIT,
- &eabh);
+ error = gfs2_meta_read(ip->i_gl, bn, DIO_START | DIO_WAIT, &eabh);
if (error)
break;
error = ea_foreach_i(ip, eabh, ea_call, data);
if (error)
break;
error = ea_foreach_i(ip, eabh, ea_call, data);
-#if 0
- else if ((ip->i_di.di_flags & GFS2_DIF_EA_PACKED) &&
- er->er_type == GFS2_EATYPE_SYS)
- return 1;
-#endif
-
return 0;
dataptrs = GFS2_EA2DATAPTRS(ea);
return 0;
dataptrs = GFS2_EA2DATAPTRS(ea);
- for (x = 0; x < ea->ea_num_ptrs; x++, dataptrs++)
+ for (x = 0; x < ea->ea_num_ptrs; x++, dataptrs++) {
if (*dataptrs) {
blks++;
bn = be64_to_cpu(*dataptrs);
}
if (*dataptrs) {
blks++;
bn = be64_to_cpu(*dataptrs);
}
- error = gfs2_trans_begin(sdp, rgd->rd_ri.ri_length +
- RES_DINODE + RES_EATTR + RES_STATFS +
- RES_QUOTA, blks);
+ error = gfs2_trans_begin(sdp, rgd->rd_ri.ri_length + RES_DINODE +
+ RES_EATTR + RES_STATFS + RES_QUOTA, blks);
if (error)
goto out_gunlock;
if (error)
goto out_gunlock;
if (error)
goto out_quota;
if (error)
goto out_quota;
- error = ea_dealloc_unstuffed(ip,
- bh, ea, prev,
- (leave) ? &error : NULL);
+ error = ea_dealloc_unstuffed(ip, bh, ea, prev, (leave) ? &error : NULL);
gfs2_glock_dq_uninit(&al->al_ri_gh);
gfs2_glock_dq_uninit(&al->al_ri_gh);
- error = gfs2_glock_nq_init(ip->i_gl,
- LM_ST_SHARED, LM_FLAG_ANY,
- &i_gh);
+ error = gfs2_glock_nq_init(ip->i_gl, LM_ST_SHARED, LM_FLAG_ANY, &i_gh);
/**
* ea_get_unstuffed - actually copies the unstuffed data into the
* request buffer
/**
* ea_get_unstuffed - actually copies the unstuffed data into the
* request buffer
- * @ip:
- * @ea:
- * @data:
+ * @ip: The GFS2 inode
+ * @ea: The extended attribute header structure
+ * @data: The data to be copied
- memcpy(data,
- bh[x]->b_data + sizeof(struct gfs2_meta_header),
+ memcpy(data, bh[x]->b_data + sizeof(struct gfs2_meta_header),
(sdp->sd_jbsize > amount) ? amount : sdp->sd_jbsize);
amount -= sdp->sd_jbsize;
(sdp->sd_jbsize > amount) ? amount : sdp->sd_jbsize);
amount -= sdp->sd_jbsize;
char *data)
{
if (GFS2_EA_IS_STUFFED(el->el_ea)) {
char *data)
{
if (GFS2_EA_IS_STUFFED(el->el_ea)) {
- memcpy(data,
- GFS2_EA2DATA(el->el_ea),
- GFS2_EA_DATA_LEN(el->el_ea));
+ memcpy(data, GFS2_EA2DATA(el->el_ea), GFS2_EA_DATA_LEN(el->el_ea));
return 0;
} else
return ea_get_unstuffed(ip, el->el_ea, data);
return 0;
} else
return ea_get_unstuffed(ip, el->el_ea, data);
+ * @ip: The GFS2 inode
+ * @er: The request structure
*
* Returns: actual size of data on success, -errno on error
*/
*
* Returns: actual size of data on success, -errno on error
*/
+ * @ip: The GFS2 inode
+ * @er: The request structure
*
* Returns: actual size of data on success, -errno on error
*/
*
* Returns: actual size of data on success, -errno on error
*/
- error = gfs2_glock_nq_init(ip->i_gl,
- LM_ST_SHARED, LM_FLAG_ANY,
- &i_gh);
+ error = gfs2_glock_nq_init(ip->i_gl, LM_ST_SHARED, LM_FLAG_ANY, &i_gh);
/**
* ea_alloc_blk - allocates a new block for extended attributes.
* @ip: A pointer to the inode that's getting extended attributes
/**
* ea_alloc_blk - allocates a new block for extended attributes.
* @ip: A pointer to the inode that's getting extended attributes
+ * @bhp: Pointer to pointer to a struct buffer_head
/**
* ea_write - writes the request info to an ea, creating new blocks if
* necessary
/**
* ea_write - writes the request info to an ea, creating new blocks if
* necessary
- * @ip: inode that is being modified
- * @ea: the location of the new ea in a block
+ * @ip: inode that is being modified
+ * @ea: the location of the new ea in a block
* @er: the write request
*
* Note: does not update ea_rec_len or the GFS2_EAFLAG_LAST bin of ea_flags
* @er: the write request
*
* Note: does not update ea_rec_len or the GFS2_EAFLAG_LAST bin of ea_flags
- copy = (data_len > sdp->sd_jbsize) ? sdp->sd_jbsize :
- data_len;
+ copy = data_len > sdp->sd_jbsize ? sdp->sd_jbsize :
+ data_len;
memcpy(bh->b_data + mh_size, data, copy);
if (copy < sdp->sd_jbsize)
memset(bh->b_data + mh_size + copy, 0,
sdp->sd_jbsize - copy);
memcpy(bh->b_data + mh_size, data, copy);
if (copy < sdp->sd_jbsize)
memset(bh->b_data + mh_size + copy, 0,
sdp->sd_jbsize - copy);
- *dataptr++ = cpu_to_be64((u64)bh->b_blocknr);
+ *dataptr++ = cpu_to_be64(bh->b_blocknr);
data += copy;
data_len -= copy;
data += copy;
data_len -= copy;
}
typedef int (*ea_skeleton_call_t) (struct gfs2_inode *ip,
}
typedef int (*ea_skeleton_call_t) (struct gfs2_inode *ip,
- struct gfs2_ea_request *er,
- void *private);
+ struct gfs2_ea_request *er, void *private);
static int ea_alloc_skeleton(struct gfs2_inode *ip, struct gfs2_ea_request *er,
unsigned int blks,
static int ea_alloc_skeleton(struct gfs2_inode *ip, struct gfs2_ea_request *er,
unsigned int blks,
- ea_skeleton_call_t skeleton_call,
- void *private)
+ ea_skeleton_call_t skeleton_call, void *private)
{
struct gfs2_alloc *al;
struct buffer_head *dibh;
{
struct gfs2_alloc *al;
struct buffer_head *dibh;
- ea_set_remove_stuffed(ip, (struct gfs2_ea_location *)private);
+ ea_set_remove_stuffed(ip, private);
struct gfs2_holder i_gh;
int error;
struct gfs2_holder i_gh;
int error;
- if (!er->er_name_len ||
- er->er_name_len > GFS2_EA_MAX_NAME_LEN)
+ if (!er->er_name_len || er->er_name_len > GFS2_EA_MAX_NAME_LEN)
return -EINVAL;
if (!er->er_data || !er->er_data_len) {
er->er_data = NULL;
return -EINVAL;
if (!er->er_data || !er->er_data_len) {
er->er_data = NULL;
gfs2_trans_add_bh(ip->i_gl, bh[x], 1);
gfs2_trans_add_bh(ip->i_gl, bh[x], 1);
- memcpy(bh[x]->b_data + sizeof(struct gfs2_meta_header),
- data,
+ memcpy(bh[x]->b_data + sizeof(struct gfs2_meta_header), data,
(sdp->sd_jbsize > amount) ? amount : sdp->sd_jbsize);
amount -= sdp->sd_jbsize;
(sdp->sd_jbsize > amount) ? amount : sdp->sd_jbsize);
amount -= sdp->sd_jbsize;
return error;
gfs2_trans_add_bh(ip->i_gl, el->el_bh, 1);
return error;
gfs2_trans_add_bh(ip->i_gl, el->el_bh, 1);
- memcpy(GFS2_EA2DATA(el->el_ea),
- data,
+ memcpy(GFS2_EA2DATA(el->el_ea), data,
GFS2_EA_DATA_LEN(el->el_ea));
} else
error = ea_acl_chmod_unstuffed(ip, el->el_ea, data);
GFS2_EA_DATA_LEN(el->el_ea));
} else
error = ea_acl_chmod_unstuffed(ip, el->el_ea, data);
if (error)
goto out_rlist_free;
if (error)
goto out_rlist_free;
- error = gfs2_trans_begin(sdp, rg_blocks + RES_DINODE +
- RES_INDIRECT + RES_STATFS +
- RES_QUOTA, blks);
+ error = gfs2_trans_begin(sdp, rg_blocks + RES_DINODE + RES_INDIRECT +
+ RES_STATFS + RES_QUOTA, blks);
if (error)
goto out_gunlock;
if (error)
goto out_gunlock;
- error = gfs2_trans_begin(sdp, RES_RG_BIT + RES_DINODE +
- RES_STATFS + RES_QUOTA, 1);
+ error = gfs2_trans_begin(sdp, RES_RG_BIT + RES_DINODE + RES_STATFS +
+ RES_QUOTA, 1);
if (error)
goto out_gunlock;
if (error)
goto out_gunlock;
#define GFS2_ERF_MODE 0x80000000
struct gfs2_ea_request {
#define GFS2_ERF_MODE 0x80000000
struct gfs2_ea_request {
char *er_data;
unsigned int er_name_len;
unsigned int er_data_len;
char *er_data;
unsigned int er_name_len;
unsigned int er_data_len;
{
switch (ea->ea_type) {
case GFS2_EATYPE_USR:
{
switch (ea->ea_type) {
case GFS2_EATYPE_USR:
- return (5 + (ea->ea_name_len + 1));
+ return 5 + ea->ea_name_len + 1;
- return (7 + (ea->ea_name_len + 1));
+ return 7 + ea->ea_name_len + 1;
case GFS2_EATYPE_SECURITY:
case GFS2_EATYPE_SECURITY:
- return (9 + (ea->ea_name_len + 1));
+ return 9 + ea->ea_name_len + 1;