1 diff -uwr metalog-0.7beta/configure.in metalog-0.7beta-ext2attr/configure.in
2 --- metalog-0.7beta/configure.in 2002-04-29 23:30:00.000000000 +0200
3 +++ metalog-0.7beta-ext2attr/configure.in 2002-10-30 00:35:28.000000000 +0100
5 AC_CHECK_HEADERS(unistd.h)
6 AC_CHECK_HEADERS(sys/time.h sys/wait.h fcntl.h sys/fcntl.h)
7 AC_CHECK_HEADERS(getopt.h stddef.h sys/klog.h)
8 +AC_CHECK_HEADERS(linux/ext2_fs.h)
12 diff -uwr metalog-0.7beta/src/metalog.h metalog-0.7beta-ext2attr/src/metalog.h
13 --- metalog-0.7beta/src/metalog.h 2002-04-29 23:35:16.000000000 +0200
14 +++ metalog-0.7beta-ext2attr/src/metalog.h 2002-10-30 00:44:53.000000000 +0100
20 +/* PinG's ext2 patch */
21 +/* Include headers if needed */
22 +#if defined(__linux__) && defined(HAVE_LINUX_EXT2_FS_H)
24 +# include <linux/ext2_fs.h>
25 +# include <sys/ioctl.h>
33 diff -uwr metalog-0.7beta/src/metalog.c metalog-0.7beta-ext2attr/src/metalogch
34 --- metalog-0.7beta/src/metalog.c 2002-04-29 23:35:16.000000000 +0200
35 +++ metalog-0.7beta-ext2attr/src/metalog.c 2002-10-30 01:13:57.000000000 +0100
38 static int rotateLogFiles(const char * const directory, const int maxfiles)
41 +/* PinG's ext2 patch. I need a file descriptor 'n a long :op */
48 char old_name[PATH_MAX];
51 int older_year, older_mon = INT_MAX, older_mday = INT_MAX,
52 older_hour = INT_MAX, older_min = INT_MAX, older_sec = INT_MAX;
63 + /* PinG's ext2 patch. Un-immutate file before unlink it ;) */
65 + if ((fd = open(path,O_RDONLY))>0){
67 + ioctl(fd,EXT2_IOC_SETFLAGS,&flags);
71 if (unlink(path) < 0) {
75 static int writeLogLine(Output * const output, const char * const date,
76 const char * const prg, const char * const info)
78 +/* PinG's ext2 patch. */
86 time_t now = time(NULL);
88 if (output == NULL || output->directory == NULL) {
90 fprintf(stderr, "Can't create [%s]\n", output->directory);
93 + /* PinG's ext2 patch. Set noatime flag */
95 + if ((fd = open(output->directory,O_RDONLY))>0){
96 + flags = EXT2_NOATIME_FL;
97 + ioctl(fd,EXT2_IOC_SETFLAGS,&flags);
102 } else if (!S_ISDIR(st.st_mode)) {
103 + /* PinG's ext2 patch. Blank flags */
105 + if ((fd = open(output->directory,O_RDONLY))>0){
107 + ioctl(fd,EXT2_IOC_SETFLAGS,&flags);
112 if (unlink(output->directory) < 0) {
113 fprintf(stderr, "Can't unlink [%s]\n", output->directory);
120 +/* PinG's ext2 patch. Set append-only & noatime flags */
122 + if ((fd = open(path,O_RDONLY|O_CREAT))>0){
123 + flags = EXT2_APPEND_FL | EXT2_NOATIME_FL;
124 + ioctl(fd,EXT2_IOC_SETFLAGS,&flags);
130 if ((fp = fopen(path, "at")) == NULL) {
131 fprintf(stderr, "Unable to access [%s]\n", path);
137 + /* PinG's ext2 patch. */
139 + if ((fd = open(path,O_RDONLY|O_CREAT))>0){
141 + ioctl(fd,EXT2_IOC_SETFLAGS,&flags);
146 if ((fp_ts = fopen(path, "rt")) == NULL) {
148 creatime = time(NULL);
150 fprintf(stderr, "Unable to close [%s]\n", path);
153 + /* PinG's ext2 patch. */
155 + if ((fd = open(path,O_RDONLY|O_CREAT))>0){
156 + flags = EXT2_IMMUTABLE_FL | EXT2_NOATIME_FL;
157 + ioctl(fd,EXT2_IOC_SETFLAGS,&flags);
162 output->creatime = creatime;
163 output->size = (off_t) ftell(fp);
165 @@ -871,11 +943,33 @@
166 rotateLogFiles(output->directory, output->maxfiles);
171 +/* PinG's ext2 patch. */
173 + if ((fd = open(path,O_RDONLY))>0){
175 + ioctl(fd,EXT2_IOC_SETFLAGS,&flags);
181 if (rename(path, newpath) < 0 && unlink(path) < 0) {
182 fprintf(stderr, "Unable to rename [%s] to [%s]\n",
187 +/* PinG's ext2 patch. Set immutable & noatime flags */
189 + if ((fd = open(newpath,O_RDONLY))>0){
190 + flags = EXT2_IMMUTABLE_FL | EXT2_NOATIME_FL;
191 + ioctl(fd,EXT2_IOC_SETFLAGS,&flags);
196 if (snprintf(path, sizeof path, "%s/" OUTPUT_DIR_TIMESTAMP,
197 output->directory) < 0) {
198 fprintf(stderr, "Path name too long for timestamp in [%s]\n",