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.patch141
1 files changed, 70 insertions, 71 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 04cb588db1..79805b5148 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,4 +1,4 @@
1From 517cbff66c8bdbf455bc3b7c1a85a4f990d0f9a6 Mon Sep 17 00:00:00 2001 1From c637948ebab5aff5641700c5cf613321ca0a6e6b Mon Sep 17 00:00:00 2001
2From: Robert Yang <liezhi.yang@windriver.com> 2From: Robert Yang <liezhi.yang@windriver.com>
3Date: Tue, 17 Feb 2015 21:08:07 -0800 3Date: Tue, 17 Feb 2015 21:08:07 -0800
4Subject: [PATCH] Act as the "mv" command when rotate log 4Subject: [PATCH] Act as the "mv" command when rotate log
@@ -10,14 +10,14 @@ Upstream-Status: Pending
10 10
11Signed-off-by: Robert Yang <liezhi.yang@windriver.com> 11Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
12--- 12---
13 logrotate.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++----------- 13 logrotate.c | 71 ++++++++++++++++++++++++++++++++++++++++++++---------
14 1 file changed, 60 insertions(+), 12 deletions(-) 14 1 file changed, 59 insertions(+), 12 deletions(-)
15 15
16diff --git a/logrotate.c b/logrotate.c 16diff --git a/logrotate.c b/logrotate.c
17index 4ad58d4..ba05884 100644 17index 54dac90..bf3ec23 100644
18--- a/logrotate.c 18--- a/logrotate.c
19+++ b/logrotate.c 19+++ b/logrotate.c
20@@ -1315,6 +1315,54 @@ static int findNeedRotating(struct logInfo *log, int logNum, int force) 20@@ -1360,6 +1360,53 @@ static int findNeedRotating(struct logInfo *log, int logNum, int force)
21 return 0; 21 return 0;
22 } 22 }
23 23
@@ -68,84 +68,83 @@ index 4ad58d4..ba05884 100644
68+ return 1; 68+ return 1;
69+} 69+}
70+ 70+
71+ 71 /* find the rotated file with the highest index */
72 static int prerotateSingleLog(struct logInfo *log, int logNum, 72 static int findLastRotated(const struct logNames *rotNames,
73 struct logState *state, struct logNames *rotNames) 73 const char *fileext, const char *compext)
74 { 74@@ -1800,15 +1847,15 @@ static int prerotateSingleLog(struct logInfo *log, int logNum,
75@@ -1674,15 +1722,15 @@ static int prerotateSingleLog(struct logInfo *log, int logNum, 75 }
76 }
77 76
78 message(MESS_DEBUG, 77 message(MESS_DEBUG,
79- "renaming %s to %s (rotatecount %d, logstart %d, i %d), \n", 78- "renaming %s to %s (rotatecount %d, logstart %d, i %d), \n",
80+ "moving %s to %s (rotatecount %d, logstart %d, i %d), \n", 79+ "moving %s to %s (rotatecount %d, logstart %d, i %d), \n",
81 oldName, newName, rotateCount, logStart, i); 80 oldName, newName, rotateCount, logStart, i);
82 81
83- if (!debug && rename(oldName, newName)) { 82- if (!debug && rename(oldName, newName)) {
84+ if (!debug && mvFile(oldName, newName, log, prev_acl)) { 83+ if (!debug && mvFile(oldName, newName, log, prev_acl)) {
85 if (errno == ENOENT) { 84 if (errno == ENOENT) {
86 message(MESS_DEBUG, "old log %s does not exist\n", 85 message(MESS_DEBUG, "old log %s does not exist\n",
87 oldName); 86 oldName);
88 } else { 87 } else {
89- message(MESS_ERROR, "error renaming %s to %s: %s\n", 88- message(MESS_ERROR, "error renaming %s to %s: %s\n",
90+ message(MESS_ERROR, "error moving %s to %s: %s\n", 89+ message(MESS_ERROR, "error moving %s to %s: %s\n",
91 oldName, newName, strerror(errno)); 90 oldName, newName, strerror(errno));
92 hasErrors = 1; 91 hasErrors = 1;
93 } 92 }
94@@ -1767,21 +1815,21 @@ static int rotateSingleLog(struct logInfo *log, int logNum, 93@@ -1891,21 +1938,21 @@ static int rotateSingleLog(struct logInfo *log, int logNum,
95 return 1; 94 return 1;
96 } 95 }
97 96
98- message(MESS_DEBUG, "renaming %s to %s\n", log->files[logNum], 97- message(MESS_DEBUG, "renaming %s to %s\n", log->files[logNum],
99+ message(MESS_DEBUG, "moving %s to %s\n", log->files[logNum], 98+ message(MESS_DEBUG, "moving %s to %s\n", log->files[logNum],
100 tmpFilename); 99 tmpFilename);
101- if (!debug && !hasErrors && rename(log->files[logNum], tmpFilename)) { 100- if (!debug && !hasErrors && rename(log->files[logNum], tmpFilename)) {
102- message(MESS_ERROR, "failed to rename %s to %s: %s\n", 101- message(MESS_ERROR, "failed to rename %s to %s: %s\n",
103+ if (!debug && !hasErrors && mvFile(log->files[logNum], rotNames->finalName, log, prev_acl)) { 102+ if (!debug && !hasErrors && mvFile(log->files[logNum], rotNames->finalName, log, prev_acl)) {
104+ message(MESS_ERROR, "failed to move %s to %s: %s\n", 103+ message(MESS_ERROR, "failed to move %s to %s: %s\n",
105 log->files[logNum], tmpFilename, 104 log->files[logNum], tmpFilename,
106 strerror(errno)); 105 strerror(errno));
107 hasErrors = 1; 106 hasErrors = 1;
108 } 107 }
109 } 108 }
110 else { 109 else {
111- message(MESS_DEBUG, "renaming %s to %s\n", log->files[logNum], 110- message(MESS_DEBUG, "renaming %s to %s\n", log->files[logNum],
112+ message(MESS_DEBUG, "moving %s to %s\n", log->files[logNum], 111+ message(MESS_DEBUG, "moving %s to %s\n", log->files[logNum],
113 rotNames->finalName); 112 rotNames->finalName);
114 if (!debug && !hasErrors && 113 if (!debug && !hasErrors &&
115- rename(log->files[logNum], rotNames->finalName)) { 114- rename(log->files[logNum], rotNames->finalName)) {
116- message(MESS_ERROR, "failed to rename %s to %s: %s\n", 115- message(MESS_ERROR, "failed to rename %s to %s: %s\n",
117+ mvFile(log->files[logNum], rotNames->finalName, log, prev_acl)) { 116+ mvFile(log->files[logNum], rotNames->finalName, log, prev_acl)) {
118+ message(MESS_ERROR, "failed to move %s to %s: %s\n", 117+ message(MESS_ERROR, "failed to move %s to %s: %s\n",
119 log->files[logNum], rotNames->finalName, 118 log->files[logNum], rotNames->finalName,
120 strerror(errno)); 119 strerror(errno));
121 hasErrors = 1; 120 hasErrors = 1;
122@@ -2170,7 +2218,7 @@ static int rotateLogSet(struct logInfo *log, int force) 121@@ -2297,7 +2344,7 @@ static int rotateLogSet(struct logInfo *log, int force)
123 return hasErrors; 122 return hasErrors;
124 } 123 }
125 124
126-static int writeState(const char *stateFilename) 125-static int writeState(const char *stateFilename)
127+static int writeState(struct logInfo *log, char *stateFilename) 126+static int writeState(struct logInfo *log, char *stateFilename)
128 { 127 {
129 struct logState *p; 128 struct logState *p;
130 FILE *f; 129 FILE *f;
131@@ -2322,7 +2370,7 @@ static int writeState(const char *stateFilename) 130@@ -2460,7 +2507,7 @@ static int writeState(const char *stateFilename)
132 fclose(f); 131 fclose(f);
133 132
134 if (error == 0) { 133 if (error == 0) {
135- if (rename(tmpFilename, stateFilename)) { 134- if (rename(tmpFilename, stateFilename)) {
136+ if (mvFile(tmpFilename, stateFilename, log, prev_acl)) { 135+ if (mvFile(tmpFilename, stateFilename, log, prev_acl)) {
137 unlink(tmpFilename); 136 unlink(tmpFilename);
138 error = 1; 137 error = 1;
139 message(MESS_ERROR, "error renaming temp state file %s\n", 138 message(MESS_ERROR, "error renaming temp state file %s\n",
140@@ -2648,7 +2696,7 @@ int main(int argc, const char **argv) 139@@ -2805,7 +2852,7 @@ int main(int argc, const char **argv)
141 rc |= rotateLogSet(log, force); 140 rc |= rotateLogSet(log, force);
142 141
143 if (!debug) 142 if (!debug)
144- rc |= writeState(stateFile); 143- rc |= writeState(stateFile);
145+ rc |= writeState(log, stateFile); 144+ rc |= writeState(log, stateFile);
146 145
147 return (rc != 0); 146 return (rc != 0);
148 } 147 }
149-- 148--
1501.8.3.1 1492.18.1
151 150