From: Ralph Boehme Date: Fri, 5 Oct 2018 17:13:16 +0000 (+0200) Subject: vfs_fruit: split out truncating from ad_convert() X-Git-Tag: samba-4.8.8~125 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=5c79f7c1cea5e385c2441fb126776f01447a8a0f;p=thirdparty%2Fsamba.git vfs_fruit: split out truncating from ad_convert() This may look a little ill-advised as this increases line count, but the goal here is modularizing ad_convert() itself and making it as slick as possible helps achieving that goal. Bug: https://bugzilla.samba.org/show_bug.cgi?id=13649 Signed-off-by: Ralph Boehme Reviewed-by: Jeremy Allison (cherry picked from commit 98bd7c0a46f72b097011a5c59e899ac4862ff651) --- diff --git a/source3/modules/vfs_fruit.c b/source3/modules/vfs_fruit.c index aa49422ee67..a77f365f5ae 100644 --- a/source3/modules/vfs_fruit.c +++ b/source3/modules/vfs_fruit.c @@ -1152,6 +1152,24 @@ static bool ad_convert_finderinfo(struct adouble *ad, return true; } +static bool ad_convert_truncate(struct adouble *ad, + const struct smb_filename *smb_fname) +{ + int rc; + + /* + * FIXME: direct ftruncate(), but we don't have a fsp for the + * VFS call + */ + rc = ftruncate(ad->ad_fd, ad_getentryoff(ad, ADEID_RFORK) + + ad_getentrylen(ad, ADEID_RFORK)); + if (rc != 0) { + return false; + } + + return true; +} + /** * Convert from Apple's ._ file to Netatalk * @@ -1200,13 +1218,8 @@ static int ad_convert(struct adouble *ad, ad_setentryoff(ad, ADEID_RFORK, ad_getentryoff(ad, ADEID_FINDERI) + ADEDLEN_FINDERI); - /* - * FIXME: direct ftruncate(), but we don't have a fsp for the - * VFS call - */ - rc = ftruncate(ad->ad_fd, ad_getentryoff(ad, ADEID_RFORK) - + ad_getentrylen(ad, ADEID_RFORK)); - if (rc != 0) { + ok = ad_convert_truncate(ad, smb_fname); + if (!ok) { munmap(map, origlen); return -1; }