[RFC PATCH 3/5] wineboot: Open update-timestamp read-only first.
Rémi Bernon
rbernon at codeweavers.com
Mon Mar 30 07:24:28 CDT 2020
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
More information about the wine-devel
mailing list