2007-06-18 17:19:15 +02:00
|
|
|
--- Makefile
|
|
|
|
+++ Makefile 2007-06-18 16:40:20.300899354 +0200
|
|
|
|
@@ -53,6 +53,7 @@ UBINPRG =
|
|
|
|
|
|
|
|
ifeq ($(DISTRO),SuSE)
|
|
|
|
UBINPRG += usleep
|
|
|
|
+ UBINPRG += fsync
|
|
|
|
endif
|
|
|
|
|
|
|
|
all: $(SBINPRG) $(UBINPRG)
|
|
|
|
@@ -72,8 +73,11 @@ checkproc: checkproc.c libinit.o
|
|
|
|
usleep: usleep.c
|
|
|
|
$(CC) $(CFLAGS) -o $@ $^
|
|
|
|
|
|
|
|
+fsync: fsync.c
|
|
|
|
+ $(CC) $(CFLAGS) -o $@ $^
|
|
|
|
+
|
|
|
|
clean:
|
|
|
|
- $(RM) *.o *~ killproc startproc checkproc pidofproc start_daemon usleep
|
|
|
|
+ $(RM) *.o *~ killproc startproc checkproc pidofproc start_daemon usleep fsync
|
|
|
|
|
|
|
|
install: $(TODO)
|
|
|
|
if test -n "$(SBINPRG)" ; then \
|
|
|
|
@@ -116,6 +120,8 @@ FILES = README \
|
|
|
|
libinit.h \
|
|
|
|
usleep.c \
|
|
|
|
usleep.1 \
|
|
|
|
+ fsync.c \
|
|
|
|
+ fsync.1 \
|
|
|
|
killproc-$(VERSION).lsm
|
|
|
|
|
|
|
|
dest:
|
2007-04-19 22:43:28 +02:00
|
|
|
--- checkproc.c
|
|
|
|
+++ checkproc.c 2007-03-09 14:05:44.000000000 +0100
|
|
|
|
@@ -162,8 +162,8 @@ int main(int argc, char **argv)
|
|
|
|
if (remember_pids(pid_file,fullname,root,flags) < 0)
|
|
|
|
exit(LSB_PROOFX);
|
|
|
|
|
|
|
|
- if (!remember && (flags & KILL))
|
|
|
|
- exit(LSB_NOPROC); /* New LSB: no pid file is no job */
|
|
|
|
+ if (!remember)
|
|
|
|
+ exit(LSB_STATUS_NOPROC); /* New LSB: no pid file is no job */
|
|
|
|
}
|
|
|
|
/* No pid file means that we have to search in /proc/ */
|
|
|
|
free(pid_file);
|
2007-06-18 17:19:15 +02:00
|
|
|
--- fsync.1
|
|
|
|
+++ fsync.1 2007-06-18 16:45:14.768333714 +0200
|
|
|
|
@@ -0,0 +1,39 @@
|
|
|
|
+.\"
|
|
|
|
+.\" Copyright 2007 Werner Fink, 2007 SuSE GmbH Nuernberg, Germany.
|
|
|
|
+.\"
|
|
|
|
+.\" This program is free software; you can redistribute it and/or modify
|
|
|
|
+.\" it under the terms of the GNU General Public License as published by
|
|
|
|
+.\" the Free Software Foundation; either version 2 of the License, or
|
|
|
|
+.\" (at your option) any later version.
|
|
|
|
+.\"
|
|
|
|
+.TH FSYNC 1 "Jun 18, 2007" "Version 1.16" "The SuSE boot concept"
|
|
|
|
+.UC 1
|
|
|
|
+.SH NAME
|
|
|
|
+fsync \- synchronize the specified file with storage device
|
|
|
|
+.\"
|
|
|
|
+.SH SYNOPSIS
|
|
|
|
+.\"
|
|
|
|
+.B fsync
|
|
|
|
+.I file
|
|
|
|
+.\"
|
|
|
|
+.SH DESCRIPTION
|
|
|
|
+.B fsync
|
|
|
|
+synchronize the in-core state of the specified file with the storage device
|
|
|
|
+.\"
|
|
|
|
+.SH BUGS
|
|
|
|
+The
|
|
|
|
+.B fsync
|
|
|
|
+program uses the
|
|
|
|
+.BR fsync (2)
|
|
|
|
+function and therefore shows the same weaknesses
|
|
|
|
+by any system activity.
|
|
|
|
+\."
|
|
|
|
+.SH SEE ALSO
|
|
|
|
+.BR fsync (2),
|
|
|
|
+.BR fdatasync (2).
|
|
|
|
+\."
|
|
|
|
+.SH COPYRIGHT
|
|
|
|
+2007 Werner Fink,
|
|
|
|
+2007 SuSE GmbH Nuernberg, Germany.
|
|
|
|
+.SH AUTHOR
|
|
|
|
+Werner Fink <werner@suse.de>
|
|
|
|
--- fsync.c
|
|
|
|
+++ fsync.c 2007-06-18 16:37:20.393692218 +0200
|
|
|
|
@@ -0,0 +1,89 @@
|
|
|
|
+/*
|
|
|
|
+ * fsync.c File data sync for the specified file
|
|
|
|
+ *
|
|
|
|
+ * Usage: fsync file
|
|
|
|
+ *
|
|
|
|
+ * Copyright 2007 Werner Fink, 2007 SUSE LINUX Products GmbH, Germany.
|
|
|
|
+ *
|
|
|
|
+ * This program is free software; you can redistribute it and/or modify
|
|
|
|
+ * it under the terms of the GNU General Public License as published by
|
|
|
|
+ * the Free Software Foundation; either version 2 of the License, or
|
|
|
|
+ * (at your option) any later version.
|
|
|
|
+ *
|
|
|
|
+ * Author: Werner Fink <werner@suse.de>
|
|
|
|
+ */
|
|
|
|
+
|
|
|
|
+#ifndef __USE_STRING_INLINES
|
|
|
|
+# define __USE_STRING_INLINES
|
|
|
|
+#endif
|
|
|
|
+#ifdef __NO_STRING_INLINES
|
|
|
|
+# undef __NO_STRING_INLINES
|
|
|
|
+#endif
|
|
|
|
+#ifndef _GNU_SOURCE
|
|
|
|
+#define _GNU_SOURCE
|
|
|
|
+#endif
|
|
|
|
+#include <string.h>
|
|
|
|
+#include <libgen.h>
|
|
|
|
+#include <stdio.h>
|
|
|
|
+#include <stdlib.h>
|
|
|
|
+#include <unistd.h>
|
|
|
|
+#include <sys/types.h>
|
|
|
|
+#include <sys/stat.h>
|
|
|
|
+#include <fcntl.h>
|
|
|
|
+#include <errno.h>
|
|
|
|
+
|
|
|
|
+#define USAGE "Usage:\t%s file\n", we_are
|
|
|
|
+
|
|
|
|
+static char *we_are;
|
|
|
|
+int main(int argc, char **argv)
|
|
|
|
+{
|
|
|
|
+ int ret, fd, flags;
|
|
|
|
+ char *path, *dir = NULL;
|
|
|
|
+
|
|
|
|
+ if (argc != 2)
|
|
|
|
+ goto err;
|
|
|
|
+
|
|
|
|
+ if ((path = strdup(argv[1])) == (char*)0)
|
|
|
|
+ goto err;
|
|
|
|
+
|
|
|
|
+ dir = dirname(path);
|
|
|
|
+ flags = O_RDONLY|O_NOCTTY|O_NONBLOCK;
|
|
|
|
+
|
|
|
|
+ if (getuid() == 0)
|
|
|
|
+ flags |= O_NOATIME;
|
|
|
|
+
|
|
|
|
+ if ((fd = open(argv[1], flags)) < 0) {
|
|
|
|
+ if (errno != ENOENT)
|
|
|
|
+ goto err;
|
|
|
|
+ if ((fd = open(dir, flags|O_DIRECTORY)) < 0)
|
|
|
|
+ goto err;
|
|
|
|
+ ret = fsync(fd);
|
|
|
|
+ close(fd);
|
|
|
|
+ if (ret < 0)
|
|
|
|
+ goto err;
|
|
|
|
+ if ((fd = open(argv[1], flags)) < 0)
|
|
|
|
+ goto err;
|
|
|
|
+ }
|
|
|
|
+ ret = fsync(fd);
|
|
|
|
+ close(fd);
|
|
|
|
+ if (ret < 0)
|
|
|
|
+ goto err;
|
|
|
|
+
|
|
|
|
+ return 0;
|
|
|
|
+ /* Do this at the end for speed */
|
|
|
|
+err:
|
|
|
|
+ we_are = basename(argv[0]);
|
|
|
|
+ fprintf(stderr, USAGE);
|
|
|
|
+
|
|
|
|
+ if (argc > 1 && *(argv[1]) == '-') {
|
|
|
|
+ argv[1]++;
|
|
|
|
+ if (!strcmp(argv[1], "-help") || *(argv[1]) == 'h' || *(argv[1]) == '?') {
|
|
|
|
+ fprintf(stderr, "Do a fsync(2) on the specified file.\n\n");
|
|
|
|
+ fprintf(stderr, "Help options:\n");
|
|
|
|
+ fprintf(stderr, " -h, -?, --help display this help and exit.\n");
|
|
|
|
+ exit (0);
|
|
|
|
+ }
|
|
|
|
+ } else if (errno != 0)
|
|
|
|
+ fprintf(stderr, "%s: %s\n", argv[1], strerror(errno));
|
|
|
|
+ exit (1);
|
|
|
|
+}
|