summaryrefslogtreecommitdiffstats
path: root/meta/recipes-extended/logrotate/logrotate-3.8.1
diff options
context:
space:
mode:
authorRobert Yang <liezhi.yang@windriver.com>2012-03-14 17:51:25 +0800
committerRichard Purdie <richard.purdie@linuxfoundation.org>2012-03-19 14:37:36 +0000
commita163d2168ffc3cc72adcb711a59b1331215bb91c (patch)
treebe94cd2ea55f10429109c821df5ce1a6be948c85 /meta/recipes-extended/logrotate/logrotate-3.8.1
parent3f23b2f1b0e8312c947b780e3d1ec7fd981ab94e (diff)
downloadpoky-a163d2168ffc3cc72adcb711a59b1331215bb91c.tar.gz
upgrade logrotate: split the old patch into 3
Split the old patch into 3 during upgrading, this makes it easier for the future's upgrade. (From OE-Core rev: 2ec5f1eab1f3d2eeff9f3984654a3fb4d87679e7) Signed-off-by: Robert Yang <liezhi.yang@windriver.com> Signed-off-by: Richard Purdie <richard.purdie@linuxfoundation.org>
Diffstat (limited to 'meta/recipes-extended/logrotate/logrotate-3.8.1')
-rw-r--r--meta/recipes-extended/logrotate/logrotate-3.8.1/act-as-mv-when-rotate.patch107
-rw-r--r--meta/recipes-extended/logrotate/logrotate-3.8.1/disable-check-different-filesystems.patch34
-rw-r--r--meta/recipes-extended/logrotate/logrotate-3.8.1/update-the-manual.patch42
3 files changed, 183 insertions, 0 deletions
diff --git a/meta/recipes-extended/logrotate/logrotate-3.8.1/act-as-mv-when-rotate.patch b/meta/recipes-extended/logrotate/logrotate-3.8.1/act-as-mv-when-rotate.patch
new file mode 100644
index 0000000000..c9fb1d2525
--- /dev/null
+++ b/meta/recipes-extended/logrotate/logrotate-3.8.1/act-as-mv-when-rotate.patch
@@ -0,0 +1,107 @@
1Act as the "mv" command when rotate log
2
3Act as the "mv" command when rotate log, first rename, if failed, then
4read and write.
5
6Upstream-Status: Pending
7
8Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
9---
10 logrotate.c | 59 +++++++++++++++++++++++++++++++++++++++++++++++++++++------
11 1 files changed, 53 insertions(+), 6 deletions(-)
12
13diff --git a/logrotate.c b/logrotate.c
14index 537e8d6..b04482f 100644
15--- a/logrotate.c
16+++ b/logrotate.c
17@@ -808,6 +808,53 @@ int findNeedRotating(struct logInfo *log, int logNum)
18 return 0;
19 }
20
21+/* Act as the "mv" command, if rename failed, then read the old file and
22+ * write to new file. The function which invokes the mvFile will use
23+ * the strerror(errorno) to handle the error message, so we don't have
24+ * to print the error message here */
25+
26+int mvFile (char *oldName, char *newName, struct logInfo *log)
27+{
28+ struct stat sbprev;
29+ int fd_old, fd_new, n;
30+ char buf[BUFSIZ];
31+
32+ /* Do the rename first */
33+ if (!rename(oldName, newName))
34+ return 0;
35+
36+ /* If the errno is EXDEV, then read old file, write newfile and
37+ * remove the oldfile */
38+ if (errno == EXDEV) {
39+ /* Open the old file to read */
40+ if ((fd_old = open(oldName, O_RDONLY)) < 0)
41+ return 1;
42+
43+ /* Create the file to write, keep the same attribute as the old file */
44+ if (stat(oldName, &sbprev))
45+ return 1;
46+ else {
47+ if ((fd_new = createOutputFile(newName,
48+ O_WRONLY | O_CREAT | O_TRUNC, &sbprev)) < 0 )
49+ return 1;
50+ }
51+
52+ /* Read and write */
53+ while ((n = read(fd_old, buf, BUFSIZ)) > 0)
54+ if (write(fd_new, buf, n) != n)
55+ return 1;
56+
57+ if ((close(fd_old) < 0) ||
58+ removeLogFile(oldName, log) ||
59+ (close(fd_new) < 0))
60+ return 1;
61+
62+ return 0;
63+ }
64+
65+ return 1;
66+}
67+
68 int prerotateSingleLog(struct logInfo *log, int logNum, struct logState *state,
69 struct logNames *rotNames)
70 {
71@@ -1148,15 +1195,15 @@ int prerotateSingleLog(struct logInfo *log, int logNum, struct logState *state,
72 rotNames->baseName, i, fileext, compext);
73
74 message(MESS_DEBUG,
75- "renaming %s to %s (rotatecount %d, logstart %d, i %d), \n",
76+ "moving %s to %s (rotatecount %d, logstart %d, i %d), \n",
77 oldName, newName, rotateCount, logStart, i);
78
79- if (!debug && rename(oldName, newName)) {
80+ if (!debug && mvFile(oldName, newName, log)) {
81 if (errno == ENOENT) {
82 message(MESS_DEBUG, "old log %s does not exist\n",
83 oldName);
84 } else {
85- message(MESS_ERROR, "error renaming %s to %s: %s\n",
86+ message(MESS_ERROR, "error moving %s to %s: %s\n",
87 oldName, newName, strerror(errno));
88 hasErrors = 1;
89 }
90@@ -1286,11 +1333,11 @@ int rotateSingleLog(struct logInfo *log, int logNum, struct logState *state,
91 }
92 }
93 #endif /* WITH_ACL */
94- message(MESS_DEBUG, "renaming %s to %s\n", log->files[logNum],
95+ message(MESS_DEBUG, "moving %s to %s\n", log->files[logNum],
96 rotNames->finalName);
97 if (!debug && !hasErrors &&
98- rename(log->files[logNum], rotNames->finalName)) {
99- message(MESS_ERROR, "failed to rename %s to %s: %s\n",
100+ mvFile(log->files[logNum], rotNames->finalName, log)) {
101+ message(MESS_ERROR, "failed to move %s to %s: %s\n",
102 log->files[logNum], rotNames->finalName,
103 strerror(errno));
104 hasErrors = 1;
105--
1061.7.4.1
107
diff --git a/meta/recipes-extended/logrotate/logrotate-3.8.1/disable-check-different-filesystems.patch b/meta/recipes-extended/logrotate/logrotate-3.8.1/disable-check-different-filesystems.patch
new file mode 100644
index 0000000000..5cb6038404
--- /dev/null
+++ b/meta/recipes-extended/logrotate/logrotate-3.8.1/disable-check-different-filesystems.patch
@@ -0,0 +1,34 @@
1Disable the check for different filesystems
2
3The logrotate supports rotate log across different filesystems now, so
4disable the check for different filesystems.
5
6Upstream-Status: Pending
7
8Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
9---
10 config.c | 8 --------
11 1 files changed, 0 insertions(+), 8 deletions(-)
12
13diff --git a/config.c b/config.c
14index a85d1df..24575b3 100644
15--- a/config.c
16+++ b/config.c
17@@ -1453,14 +1453,6 @@ static int readConfigFile(const char *configFile, struct logInfo *defConfig)
18 dirName, strerror(errno));
19 goto error;
20 }
21-
22- if (sb.st_dev != sb2.st_dev) {
23- message(MESS_ERROR,
24- "%s:%d olddir %s and log file %s "
25- "are on different devices\n", configFile,
26- lineNum, newlog->oldDir, newlog->files[i]);
27- goto error;
28- }
29 }
30 }
31
32--
331.7.4.1
34
diff --git a/meta/recipes-extended/logrotate/logrotate-3.8.1/update-the-manual.patch b/meta/recipes-extended/logrotate/logrotate-3.8.1/update-the-manual.patch
new file mode 100644
index 0000000000..5cab64947b
--- /dev/null
+++ b/meta/recipes-extended/logrotate/logrotate-3.8.1/update-the-manual.patch
@@ -0,0 +1,42 @@
1Update the manual
2
3* Update the mannual
4* Fix a bug in the mannual(\f should be \fR)
5
6Upstream-Status: Pending
7
8Signed-off-by: Robert Yang <liezhi.yang@windriver.com>
9---
10 logrotate.8 | 9 ++++-----
11 1 files changed, 4 insertions(+), 5 deletions(-)
12
13diff --git a/logrotate.8 b/logrotate.8
14index 8b34167..5f15432 100644
15--- a/logrotate.8
16+++ b/logrotate.8
17@@ -374,10 +374,9 @@ Do not rotate the log if it is empty (this overrides the \fBifempty\fR option).
18 .TP
19 \fBolddir \fIdirectory\fR
20 Logs are moved into \fIdirectory\fR for rotation. The \fIdirectory\fR
21-must be on the same physical device as the log file being rotated,
22-and is assumed to be relative to the directory holding the log file
23-unless an absolute path name is specified. When this option is used all
24-old versions of the log end up in \fIdirectory\fR. This option may be
25+is assumed to be relative to the directory holding the log file unless
26+an absolute path name is specified. When this option is used all old
27+versions of the log end up in \fIdirectory\fR. This option may be
28 overridden by the \fBnoolddir\fR option.
29
30 .TP
31@@ -435,7 +434,7 @@ Log files are rotated only if they grow bigger then \fIsize\fR bytes. If
32 \fIsize\fR is followed by \fIk\fR, the size is assumed to be in kilobytes.
33 If the \fIM\fR is used, the size is in megabytes, and if \fIG\fR is used, the
34 size is in gigabytes. So \fBsize 100\fR, \fIsize 100k\fR, \fIsize 100M\fR and
35-\fIsize 100G\f are all valid.
36+\fIsize 100G\fR are all valid.
37
38 .TP
39 \fBsharedscripts\fR
40--
411.7.4.1
42