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 @@ | |||
1 | Act as the "mv" command when rotate log | 1 | From 68f29ab490cf987aa34b5f4caf1784b58a021308 Mon Sep 17 00:00:00 2001 |
2 | From: Robert Yang <liezhi.yang@windriver.com> | ||
3 | Date: Tue, 17 Feb 2015 21:08:07 -0800 | ||
4 | Subject: [PATCH] Act as the "mv" command when rotate log | ||
2 | 5 | ||
3 | Act as the "mv" command when rotate log, first rename, if failed, then | 6 | Act as the "mv" command when rotate log, first rename, if failed, then |
4 | read and write. | 7 | read and write. |
5 | 8 | ||
6 | Upstream-Status: Submitted | 9 | Upstream-Status: Pending |
7 | 10 | ||
8 | Signed-off-by: Robert Yang <liezhi.yang@windriver.com> | 11 | Signed-off-by: Robert Yang <liezhi.yang@windriver.com> |
9 | --- | 12 | --- |
10 | logrotate.c | 65 ++++++++++++++++++++++++++++++++++++++++++++++++++--------- | 13 | logrotate.c | 71 +++++++++++++++++++++++++++++++++++++++++++++++++---------- |
11 | 1 file changed, 56 insertions(+), 9 deletions(-) | 14 | 1 file changed, 59 insertions(+), 12 deletions(-) |
12 | 15 | ||
13 | diff --git a/logrotate.c b/logrotate.c | 16 | diff --git a/logrotate.c b/logrotate.c |
14 | index 174a26b..b18b629 100644 | 17 | index d3deb6a..cf8bf2c 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 | @@ -1157,6 +1157,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 | @@ -1523,15 +1570,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,35 @@ 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 | @@ -1669,21 +1716,21 @@ int rotateSingleLog(struct logInfo *log, int logNum, struct logState *state, |
94 | return 1; | ||
95 | } | ||
96 | |||
97 | - message(MESS_DEBUG, "renaming %s to %s\n", log->files[logNum], | ||
98 | + message(MESS_DEBUG, "moving %s to %s\n", log->files[logNum], | ||
99 | tmpFilename); | ||
100 | - if (!debug && !hasErrors && rename(log->files[logNum], tmpFilename)) { | ||
101 | - message(MESS_ERROR, "failed to rename %s to %s: %s\n", | ||
102 | + if (!debug && !hasErrors && mvFile(log->files[logNum], rotNames->finalName, log, prev_acl)) { | ||
103 | + message(MESS_ERROR, "failed to move %s to %s: %s\n", | ||
104 | log->files[logNum], tmpFilename, | ||
105 | strerror(errno)); | ||
106 | hasErrors = 1; | ||
91 | } | 107 | } |
92 | } | 108 | } |
93 | #endif /* WITH_ACL */ | 109 | else { |
94 | - message(MESS_DEBUG, "renaming %s to %s\n", log->files[logNum], | 110 | - message(MESS_DEBUG, "renaming %s to %s\n", log->files[logNum], |
95 | + message(MESS_DEBUG, "moving %s to %s\n", log->files[logNum], | 111 | + message(MESS_DEBUG, "moving %s to %s\n", log->files[logNum], |
96 | rotNames->finalName); | 112 | rotNames->finalName); |
97 | if (!debug && !hasErrors && | 113 | if (!debug && !hasErrors && |
98 | - rename(log->files[logNum], rotNames->finalName)) { | 114 | - rename(log->files[logNum], rotNames->finalName)) { |
99 | - message(MESS_ERROR, "failed to rename %s to %s: %s\n", | 115 | - message(MESS_ERROR, "failed to rename %s to %s: %s\n", |
100 | + mvFile(log->files[logNum], rotNames->finalName, log, prev_acl)) { | 116 | + mvFile(log->files[logNum], rotNames->finalName, log, prev_acl)) { |
101 | + message(MESS_ERROR, "failed to move %s to %s: %s\n", | 117 | + message(MESS_ERROR, "failed to move %s to %s: %s\n", |
102 | log->files[logNum], rotNames->finalName, | 118 | log->files[logNum], tmpFilename, |
103 | strerror(errno)); | 119 | strerror(errno)); |
104 | hasErrors = 1; | 120 | hasErrors = 1; |
105 | @@ -1775,7 +1822,7 @@ int rotateLogSet(struct logInfo *log, int force) | 121 | @@ -2063,7 +2110,7 @@ int rotateLogSet(struct logInfo *log, int force) |
106 | return hasErrors; | 122 | return hasErrors; |
107 | } | 123 | } |
108 | 124 | ||
@@ -111,7 +127,7 @@ index 174a26b..b18b629 100644 | |||
111 | { | 127 | { |
112 | struct logState *p; | 128 | struct logState *p; |
113 | FILE *f; | 129 | FILE *f; |
114 | @@ -1939,7 +1986,7 @@ static int writeState(char *stateFilename) | 130 | @@ -2227,7 +2274,7 @@ static int writeState(char *stateFilename) |
115 | fclose(f); | 131 | fclose(f); |
116 | 132 | ||
117 | if (error == 0) { | 133 | if (error == 0) { |
@@ -120,7 +136,7 @@ index 174a26b..b18b629 100644 | |||
120 | unlink(tmpFilename); | 136 | unlink(tmpFilename); |
121 | error = 1; | 137 | error = 1; |
122 | message(MESS_ERROR, "error renaming temp state file %s\n", | 138 | message(MESS_ERROR, "error renaming temp state file %s\n", |
123 | @@ -2223,7 +2270,7 @@ int main(int argc, const char **argv) | 139 | @@ -2525,7 +2572,7 @@ int main(int argc, const char **argv) |
124 | rc |= rotateLogSet(log, force); | 140 | rc |= rotateLogSet(log, force); |
125 | 141 | ||
126 | if (!debug) | 142 | if (!debug) |
@@ -129,6 +145,3 @@ index 174a26b..b18b629 100644 | |||
129 | 145 | ||
130 | return (rc != 0); | 146 | return (rc != 0); |
131 | } | 147 | } |
132 | -- | ||
133 | 1.7.10.4 | ||
134 | |||