Page Menu
Home
FreeBSD
Search
Configure Global Search
Log In
Files
F171880462
D5409.id13647.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Flag For Later
Award Token
Size
1 KB
Referenced Files
None
Subscribers
None
D5409.id13647.diff
View Options
Index: gr_util.c
===================================================================
--- gr_util.c
+++ gr_util.c
@@ -141,13 +141,13 @@
errno = ENAMETOOLONG;
return (-1);
}
- if ((tfd = mkostemp(tempname, O_SYNC)) == -1)
+ if ((tfd = mkstemp(tempname)) == -1)
return (-1);
if (mfd != -1) {
while ((nr = read(mfd, buf, sizeof(buf))) > 0)
if (write(tfd, buf, (size_t)nr) != nr)
break;
- if (nr != 0) {
+ if (nr != 0 || fsync(tfd) != 0) {
unlink(tempname);
*tempname = '\0';
close(tfd);
@@ -305,6 +305,8 @@
done:
if (line != NULL)
free(line);
+ if (fsync(tfd) != 0)
+ goto err;
return (0);
err:
if (line != NULL)
Index: pw_util.c
===================================================================
--- pw_util.c
+++ pw_util.c
@@ -226,13 +226,13 @@
errno = ENAMETOOLONG;
return (-1);
}
- if ((tfd = mkostemp(tempname, O_SYNC)) == -1)
+ if ((tfd = mkstemp(tempname)) == -1)
return (-1);
if (mfd != -1) {
while ((nr = read(mfd, buf, sizeof(buf))) > 0)
if (write(tfd, buf, (size_t)nr) != nr)
break;
- if (nr != 0) {
+ if (nr != 0 || fsync(tfd) != 0) {
unlink(tempname);
*tempname = '\0';
close(tfd);
@@ -289,7 +289,7 @@
sigset_t oldsigset, nsigset;
struct stat st1, st2;
const char *editor;
- int pstat;
+ int pstat, fd;
if ((editor = getenv("EDITOR")) == NULL)
editor = _PATH_VI;
@@ -344,6 +344,11 @@
sigprocmask(SIG_SETMASK, &oldsigset, NULL);
if (stat(tempname, &st2) == -1)
return (-1);
+ if ((fd = open(tempname, O_RDONLY)) == -1 || fsync(fd) == -1) {
+ close(fd);
+ return (-1);
+ }
+ close(fd);
return (st1.st_mtim.tv_sec != st2.st_mtim.tv_sec ||
st1.st_mtim.tv_nsec != st2.st_mtim.tv_nsec);
}
@@ -570,6 +575,8 @@
done:
if (line != NULL)
free(line);
+ if (fsync(tfd) != 0)
+ goto err;
return (0);
err:
if (line != NULL)
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Tue, Sep 15, 7:35 AM (14 h, 57 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
38948974
Default Alt Text
D5409.id13647.diff (1 KB)
Attached To
Mode
D5409: Reduce use of O_SYNC in libutil
Attached
Detach File
Event Timeline
Log In to Comment