From adace43107e3a77dcb3d24c87e7a631c0f099602 Mon Sep 17 00:00:00 2001 From: Emmanuel Dreyfus Date: Tue, 16 Sep 2014 17:11:39 +0200 Subject: 32 bit fix: use off_t and not size_t for truncate() Make sure off_t and not size_t is used when holding file offsets for ftruncate()/truncate(). It works on 64 bit machines where sizeof(size_t) == sizeof(off_t) == 8, but breaks for big offsets on 32 bit machines because sizeof(size_t) == 4 and sizeof(off_t) == 8 BUG: 1129939 Change-Id: Ia2637be772ba9b11731d59fdbffbd269f0ff56c8 Signed-off-by: Emmanuel Dreyfus Reviewed-on: http://review.gluster.org/8742 Tested-by: Gluster Build System Reviewed-by: Vijay Bellur --- xlators/mount/fuse/src/fuse-bridge.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) (limited to 'xlators/mount/fuse/src/fuse-bridge.c') diff --git a/xlators/mount/fuse/src/fuse-bridge.c b/xlators/mount/fuse/src/fuse-bridge.c index dd51f5a6608..17335492465 100644 --- a/xlators/mount/fuse/src/fuse-bridge.c +++ b/xlators/mount/fuse/src/fuse-bridge.c @@ -1010,14 +1010,14 @@ out: } static void -fuse_do_truncate (fuse_state_t *state, size_t size) +fuse_do_truncate (fuse_state_t *state) { if (state->fd) { FUSE_FOP (state, fuse_truncate_cbk, GF_FOP_FTRUNCATE, - ftruncate, state->fd, size, state->xdata); + ftruncate, state->fd, state->off, state->xdata); } else { FUSE_FOP (state, fuse_truncate_cbk, GF_FOP_TRUNCATE, - truncate, &state->loc, size, state->xdata); + truncate, &state->loc, state->off, state->xdata); } return; @@ -1059,7 +1059,7 @@ fuse_setattr_cbk (call_frame_t *frame, void *cookie, xlator_t *this, calc_timeout_nsec (priv->attribute_timeout); if (state->truncate_needed) { - fuse_do_truncate (state, state->size); + fuse_do_truncate (state); } else { #if FUSE_KERNEL_MINOR_VERSION >= 9 priv->proto_minor >= 9 ? @@ -1166,7 +1166,7 @@ fuse_setattr_resume (fuse_state_t *state) state->xdata); } } else { - fuse_do_truncate (state, state->size); + fuse_do_truncate (state); } } @@ -1216,7 +1216,7 @@ fuse_setattr (xlator_t *this, fuse_in_header_t *finh, void *msg) if ((fsi->valid & (FATTR_MASK)) != FATTR_SIZE) { if (fsi->valid & FATTR_SIZE) { - state->size = fsi->size; + state->off = fsi->size; state->truncate_needed = _gf_true; } @@ -1230,7 +1230,7 @@ fuse_setattr (xlator_t *this, fuse_in_header_t *finh, void *msg) state->attr.ia_uid = fsi->uid; state->attr.ia_gid = fsi->gid; } else { - state->size = fsi->size; + state->off = fsi->size; } fuse_resolve_and_resume (state, fuse_setattr_resume); -- cgit