[PATCH] vfs_fruit TM size calculation on 32-bit platforms
Jeremy Allison
jra at samba.org
Thu Feb 22 20:36:45 UTC 2018
On Thu, Feb 22, 2018 at 04:20:49PM +0100, Ralph Böhme via samba-technical wrote:
> Hi!
>
> Attached is a simple fix for a bug in vfs_fruit where I used the wrong integer
> type for file sizes: size_t, instead of off_t.
>
> Bug: ...
LGTM. RB+ and pushed.
> --
> Ralph Boehme, Samba Team https://samba.org/
> Samba Developer, SerNet GmbH https://sernet.de/en/samba/
> GPG Key Fingerprint: FAE2 C608 8A24 2520 51C5 59E4 AA1E 9B71 2639 9E46
> From f78fe9470c66bb30f26ed9c27a432ff8e09e1563 Mon Sep 17 00:00:00 2001
> From: Ralph Boehme <slow at samba.org>
> Date: Thu, 22 Feb 2018 15:52:46 +0100
> Subject: [PATCH] vfs_fruit: use off_t, not size_t for TM size calculations
>
> size_t is only a 32-bit integer on 32-bit platforms. We must use off_t
> for file sizes.
>
> https://bugzilla.samba.org/show_bug.cgi?id=13296
>
> Signed-off-by: Ralph Boehme <slow at samba.org>
> ---
> source3/modules/vfs_fruit.c | 13 ++++++-------
> 1 file changed, 6 insertions(+), 7 deletions(-)
>
> diff --git a/source3/modules/vfs_fruit.c b/source3/modules/vfs_fruit.c
> index 40ee2553a12..ec76f718c37 100644
> --- a/source3/modules/vfs_fruit.c
> +++ b/source3/modules/vfs_fruit.c
> @@ -141,7 +141,7 @@ struct fruit_config_data {
> bool aapl_zero_file_id;
> const char *model;
> bool time_machine;
> - size_t time_machine_max_size;
> + off_t time_machine_max_size;
>
> /*
> * Additional options, all enabled by default,
> @@ -1989,8 +1989,7 @@ static int init_fruit_config(vfs_handle_struct *handle)
> SNUM(handle->conn), FRUIT_PARAM_TYPE_NAME,
> "time machine max size", NULL);
> if (tm_size_str != NULL) {
> - config->time_machine_max_size =
> - (size_t)conv_str_size(tm_size_str);
> + config->time_machine_max_size = conv_str_size(tm_size_str);
> }
>
> SMB_VFS_HANDLE_SET_DATA(handle, config,
> @@ -6321,7 +6320,7 @@ static bool fruit_get_bandsize(vfs_handle_struct *handle,
> }
>
> struct fruit_disk_free_state {
> - size_t total_size;
> + off_t total_size;
> };
>
> static bool fruit_get_num_bands(vfs_handle_struct *handle,
> @@ -6394,7 +6393,7 @@ static bool fruit_tmsize_do_dirent(vfs_handle_struct *handle,
> size_t sparsebundle_strlen = strlen("sparsebundle");
> size_t bandsize = 0;
> size_t nbands;
> - double tm_size;
> + off_t tm_size;
>
> p = strstr(e->d_name, "sparsebundle");
> if (p == NULL) {
> @@ -6444,8 +6443,8 @@ static bool fruit_tmsize_do_dirent(vfs_handle_struct *handle,
>
> state->total_size += tm_size;
>
> - DBG_DEBUG("[%s] tm_size [%.0f] total_size [%zu]\n",
> - e->d_name, tm_size, state->total_size);
> + DBG_DEBUG("[%s] tm_size [%jd] total_size [%jd]\n",
> + e->d_name, (intmax_t)tm_size, (intmax_t)state->total_size);
>
> return true;
> }
> --
> 2.13.6
>
More information about the samba-technical
mailing list