From: Michael Meffie Date: Sun, 13 Mar 2016 20:55:48 +0000 (-0400) Subject: util: open mrafs-style logs with O_APPEND too X-Git-Tag: upstream/1.8.0_pre1^2~122 X-Git-Url: https://git.michaelhowe.org/gitweb/?a=commitdiff_plain;h=1a72f4a917f14c97ab067eb303252e3244cb59d1;p=packages%2Fo%2Fopenafs.git util: open mrafs-style logs with O_APPEND too Commit b71a041364d28d6a56905a770cd20d1497ee26ec added the O_APPEND flag when opening the log file to allow sites to use logrotate's "copy and truncate" feature. Add the O_APPEND to MR-AFS style logs as well so MR-AFS style logs can also be handled correctly with logrotate, we have consistent open flags, and can remove a duplicate call to open the log file descriptor. Change-Id: I8370838e1e2c7ddaa042508d6b9cbe1299339f68 Reviewed-on: https://gerrit.openafs.org/12218 Reviewed-by: Benjamin Kaduk Tested-by: BuildBot --- diff --git a/src/util/serverLog.c b/src/util/serverLog.c index 44112943d..1f4639c5e 100644 --- a/src/util/serverLog.c +++ b/src/util/serverLog.c @@ -377,7 +377,6 @@ OpenLog(const char *fileName) } if (!isfifo) rk_rename(fileName, FileName); /* don't check error code */ - tempfd = open(fileName, O_WRONLY | O_TRUNC | O_CREAT | (isfifo?O_NONBLOCK:0), 0666); } else { strcpy(oldName, fileName); strcat(oldName, ".old"); @@ -385,9 +384,9 @@ OpenLog(const char *fileName) /* don't check error */ if (!isfifo) rk_rename(fileName, oldName); - tempfd = open(fileName, O_WRONLY | O_TRUNC | O_CREAT | O_APPEND | (isfifo?O_NONBLOCK:0), 0666); } + tempfd = open(fileName, O_WRONLY | O_TRUNC | O_CREAT | O_APPEND | (isfifo?O_NONBLOCK:0), 0666); if (tempfd < 0) { printf("Unable to open log file %s\n", fileName); return -1;