summaryrefslogtreecommitdiffstats
path: root/meta/recipes-extended/logrotate/logrotate/act-as-mv-when-rotate.patch
diff options
context:
space:
mode:
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.patch48
1 files changed, 25 insertions, 23 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..15f171ed6f 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,9 +1,12 @@
1Act as the "mv" command when rotate log 1From 68f29ab490cf987aa34b5f4caf1784b58a021308 Mon Sep 17 00:00:00 2001
2From: Robert Yang <liezhi.yang@windriver.com>
3Date: Tue, 17 Feb 2015 21:08:07 -0800
4Subject: [PATCH] Act as the "mv" command when rotate log
2 5
3Act as the "mv" command when rotate log, first rename, if failed, then 6Act as the "mv" command when rotate log, first rename, if failed, then
4read and write. 7read and write.
5 8
6Upstream-Status: Submitted 9Upstream-Status: Pending
7 10
8Signed-off-by: Robert Yang <liezhi.yang@windriver.com> 11Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
9--- 12---
@@ -11,10 +14,10 @@ Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
11 1 file changed, 56 insertions(+), 9 deletions(-) 14 1 file changed, 56 insertions(+), 9 deletions(-)
12 15
13diff --git a/logrotate.c b/logrotate.c 16diff --git a/logrotate.c b/logrotate.c
14index 174a26b..b18b629 100644 17index 05e74c9..616418f 100644
15--- a/logrotate.c 18--- a/logrotate.c
16+++ b/logrotate.c 19+++ b/logrotate.c
17@@ -906,6 +906,53 @@ int findNeedRotating(struct logInfo *log, int logNum, int force) 20@@ -1000,6 +1000,53 @@ int findNeedRotating(struct logInfo *log, int logNum, int force)
18 return 0; 21 return 0;
19 } 22 }
20 23
@@ -68,7 +71,7 @@ index 174a26b..b18b629 100644
68 int prerotateSingleLog(struct logInfo *log, int logNum, struct logState *state, 71 int prerotateSingleLog(struct logInfo *log, int logNum, struct logState *state,
69 struct logNames *rotNames) 72 struct logNames *rotNames)
70 { 73 {
71@@ -1268,15 +1315,15 @@ int prerotateSingleLog(struct logInfo *log, int logNum, struct logState *state, 74@@ -1364,15 +1411,15 @@ int prerotateSingleLog(struct logInfo *log, int logNum, struct logState *state,
72 } 75 }
73 76
74 message(MESS_DEBUG, 77 message(MESS_DEBUG,
@@ -87,22 +90,21 @@ index 174a26b..b18b629 100644
87 oldName, newName, strerror(errno)); 90 oldName, newName, strerror(errno));
88 hasErrors = 1; 91 hasErrors = 1;
89 } 92 }
90@@ -1408,11 +1455,11 @@ int rotateSingleLog(struct logInfo *log, int logNum, struct logState *state, 93@@ -1511,10 +1558,10 @@ int rotateSingleLog(struct logInfo *log, int logNum, struct logState *state,
94 return 1;
91 } 95 }
92 } 96
93 #endif /* WITH_ACL */ 97- message(MESS_DEBUG, "renaming %s to %s\n", log->files[logNum],
94- message(MESS_DEBUG, "renaming %s to %s\n", log->files[logNum], 98+ message(MESS_DEBUG, "moving %s to %s\n", log->files[logNum],
95+ message(MESS_DEBUG, "moving %s to %s\n", log->files[logNum], 99 tmpFilename);
96 rotNames->finalName); 100- if (!debug && !hasErrors && rename(log->files[logNum], tmpFilename)) {
97 if (!debug && !hasErrors && 101- message(MESS_ERROR, "failed to rename %s to %s: %s\n",
98- rename(log->files[logNum], rotNames->finalName)) { 102+ if (!debug && !hasErrors && mvFile(log->files[logNum], rotNames->finalName, log, prev_acl)) {
99- message(MESS_ERROR, "failed to rename %s to %s: %s\n", 103+ message(MESS_ERROR, "failed to move %s to %s: %s\n",
100+ mvFile(log->files[logNum], rotNames->finalName, log, prev_acl)) { 104 log->files[logNum], tmpFilename,
101+ message(MESS_ERROR, "failed to move %s to %s: %s\n", 105 strerror(errno));
102 log->files[logNum], rotNames->finalName, 106 if (errno == ENOENT) {
103 strerror(errno)); 107@@ -1912,7 +1959,7 @@ int rotateLogSet(struct logInfo *log, int force)
104 hasErrors = 1;
105@@ -1775,7 +1822,7 @@ int rotateLogSet(struct logInfo *log, int force)
106 return hasErrors; 108 return hasErrors;
107 } 109 }
108 110
@@ -111,7 +113,7 @@ index 174a26b..b18b629 100644
111 { 113 {
112 struct logState *p; 114 struct logState *p;
113 FILE *f; 115 FILE *f;
114@@ -1939,7 +1986,7 @@ static int writeState(char *stateFilename) 116@@ -2076,7 +2123,7 @@ static int writeState(char *stateFilename)
115 fclose(f); 117 fclose(f);
116 118
117 if (error == 0) { 119 if (error == 0) {
@@ -120,7 +122,7 @@ index 174a26b..b18b629 100644
120 unlink(tmpFilename); 122 unlink(tmpFilename);
121 error = 1; 123 error = 1;
122 message(MESS_ERROR, "error renaming temp state file %s\n", 124 message(MESS_ERROR, "error renaming temp state file %s\n",
123@@ -2223,7 +2270,7 @@ int main(int argc, const char **argv) 125@@ -2362,7 +2409,7 @@ int main(int argc, const char **argv)
124 rc |= rotateLogSet(log, force); 126 rc |= rotateLogSet(log, force);
125 127
126 if (!debug) 128 if (!debug)
@@ -130,5 +132,5 @@ index 174a26b..b18b629 100644
130 return (rc != 0); 132 return (rc != 0);
131 } 133 }
132-- 134--
1331.7.10.4 1351.7.9.5
134 136