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