From: "RĂ©mi Bernon" Subject: [RFC PATCH 3/5] wineboot: Open update-timestamp read-only first. Message-Id: <20200330122430.2945061-4-rbernon@codeweavers.com> Date: Mon, 30 Mar 2020 14:24:28 +0200 In-Reply-To: <20200330122430.2945061-1-rbernon@codeweavers.com> References: <20200330122430.2945061-1-rbernon@codeweavers.com> Opening it with O_RDWR makes the overlay copy it to the upper layer, although we are only reading it first. --- programs/wineboot/wineboot.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/programs/wineboot/wineboot.c b/programs/wineboot/wineboot.c index 913c967d4d4d..2463b7a0e050 100644 --- a/programs/wineboot/wineboot.c +++ b/programs/wineboot/wineboot.c @@ -123,7 +123,7 @@ static BOOL update_timestamp( const WCHAR *config_dir, unsigned long timestamp ) int fd, count; char buffer[100]; - if ((fd = _wopen( timestampW, O_RDWR )) != -1) + if ((fd = _wopen( timestampW, O_RDONLY )) != -1) { if ((count = read( fd, buffer, sizeof(buffer) - 1 )) >= 0) { @@ -131,14 +131,11 @@ static BOOL update_timestamp( const WCHAR *config_dir, unsigned long timestamp ) if (!strncmp( buffer, "disable", sizeof("disable")-1 )) goto done; if (timestamp == strtoul( buffer, NULL, 10 )) goto done; } - lseek( fd, 0, SEEK_SET ); - chsize( fd, 0 ); - } - else - { - if (errno != ENOENT) goto done; - if ((fd = _wopen( timestampW, O_WRONLY | O_CREAT | O_TRUNC, 0666 )) == -1) goto done; + close( fd ); } + else if (errno != ENOENT) goto done; + + if ((fd = _wopen( timestampW, O_WRONLY | O_CREAT | O_TRUNC, 0666 )) == -1) goto done; count = sprintf( buffer, "%lu\n", timestamp ); if (write( fd, buffer, count ) != count) -- 2.26.0.rc2