diff options
Diffstat (limited to 'meta/recipes-extended/logrotate/logrotate/act-as-mv-when-rotate.patch')
-rw-r--r-- | meta/recipes-extended/logrotate/logrotate/act-as-mv-when-rotate.patch | 65 |
1 files changed, 39 insertions, 26 deletions
diff --git a/meta/recipes-extended/logrotate/logrotate/act-as-mv-when-rotate.patch b/meta/recipes-extended/logrotate/logrotate/act-as-mv-when-rotate.patch index ce64040d5f..2e931a2876 100644 --- a/meta/recipes-extended/logrotate/logrotate/act-as-mv-when-rotate.patch +++ b/meta/recipes-extended/logrotate/logrotate/act-as-mv-when-rotate.patch @@ -1,20 +1,23 @@ -Act as the "mv" command when rotate log +From 68f29ab490cf987aa34b5f4caf1784b58a021308 Mon Sep 17 00:00:00 2001 +From: Robert Yang <liezhi.yang@windriver.com> +Date: Tue, 17 Feb 2015 21:08:07 -0800 +Subject: [PATCH] Act as the "mv" command when rotate log Act as the "mv" command when rotate log, first rename, if failed, then read and write. -Upstream-Status: Submitted +Upstream-Status: Pending Signed-off-by: Robert Yang <liezhi.yang@windriver.com> --- - logrotate.c | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++--------- - 1 file changed, 56 insertions(+), 9 deletions(-) + logrotate.c | 71 +++++++++++++++++++++++++++++++++++++++++++++++++---------- + 1 file changed, 59 insertions(+), 12 deletions(-) diff --git a/logrotate.c b/logrotate.c -index 174a26b..b18b629 100644 +index d3deb6a..cf8bf2c 100644 --- a/logrotate.c +++ b/logrotate.c -@@ -906,6 +906,53 @@ int findNeedRotating(struct logInfo *log, int logNum, int force) +@@ -1157,6 +1157,53 @@ int findNeedRotating(struct logInfo *log, int logNum, int force) return 0; } @@ -68,7 +71,7 @@ index 174a26b..b18b629 100644 int prerotateSingleLog(struct logInfo *log, int logNum, struct logState *state, struct logNames *rotNames) { -@@ -1268,15 +1315,15 @@ int prerotateSingleLog(struct logInfo *log, int logNum, struct logState *state, +@@ -1523,15 +1570,15 @@ int prerotateSingleLog(struct logInfo *log, int logNum, struct logState *state, } message(MESS_DEBUG, @@ -87,22 +90,35 @@ index 174a26b..b18b629 100644 oldName, newName, strerror(errno)); hasErrors = 1; } -@@ -1408,11 +1455,11 @@ int rotateSingleLog(struct logInfo *log, int logNum, struct logState *state, +@@ -1669,21 +1716,21 @@ int rotateSingleLog(struct logInfo *log, int logNum, struct logState *state, + return 1; + } + +- message(MESS_DEBUG, "renaming %s to %s\n", log->files[logNum], ++ message(MESS_DEBUG, "moving %s to %s\n", log->files[logNum], + tmpFilename); +- if (!debug && !hasErrors && rename(log->files[logNum], tmpFilename)) { +- message(MESS_ERROR, "failed to rename %s to %s: %s\n", ++ if (!debug && !hasErrors && mvFile(log->files[logNum], rotNames->finalName, log, prev_acl)) { ++ message(MESS_ERROR, "failed to move %s to %s: %s\n", + log->files[logNum], tmpFilename, + strerror(errno)); + hasErrors = 1; } } - #endif /* WITH_ACL */ -- message(MESS_DEBUG, "renaming %s to %s\n", log->files[logNum], -+ message(MESS_DEBUG, "moving %s to %s\n", log->files[logNum], - rotNames->finalName); - if (!debug && !hasErrors && -- rename(log->files[logNum], rotNames->finalName)) { -- message(MESS_ERROR, "failed to rename %s to %s: %s\n", -+ mvFile(log->files[logNum], rotNames->finalName, log, prev_acl)) { -+ message(MESS_ERROR, "failed to move %s to %s: %s\n", - log->files[logNum], rotNames->finalName, - strerror(errno)); - hasErrors = 1; -@@ -1775,7 +1822,7 @@ int rotateLogSet(struct logInfo *log, int force) + else { +- message(MESS_DEBUG, "renaming %s to %s\n", log->files[logNum], ++ message(MESS_DEBUG, "moving %s to %s\n", log->files[logNum], + rotNames->finalName); + if (!debug && !hasErrors && +- rename(log->files[logNum], rotNames->finalName)) { +- message(MESS_ERROR, "failed to rename %s to %s: %s\n", ++ mvFile(log->files[logNum], rotNames->finalName, log, prev_acl)) { ++ message(MESS_ERROR, "failed to move %s to %s: %s\n", + log->files[logNum], tmpFilename, + strerror(errno)); + hasErrors = 1; +@@ -2063,7 +2110,7 @@ int rotateLogSet(struct logInfo *log, int force) return hasErrors; } @@ -111,7 +127,7 @@ index 174a26b..b18b629 100644 { struct logState *p; FILE *f; -@@ -1939,7 +1986,7 @@ static int writeState(char *stateFilename) +@@ -2227,7 +2274,7 @@ static int writeState(char *stateFilename) fclose(f); if (error == 0) { @@ -120,7 +136,7 @@ index 174a26b..b18b629 100644 unlink(tmpFilename); error = 1; message(MESS_ERROR, "error renaming temp state file %s\n", -@@ -2223,7 +2270,7 @@ int main(int argc, const char **argv) +@@ -2525,7 +2572,7 @@ int main(int argc, const char **argv) rc |= rotateLogSet(log, force); if (!debug) @@ -129,6 +145,3 @@ index 174a26b..b18b629 100644 return (rc != 0); } --- -1.7.10.4 - |