[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[tyndur-devel] [PATCH 2/2] shell: Neuer Befehl sync



+ shell: Neuer Befehl sync, der lio_sync_all() aufruft. Geht im Moment
  natürlich noch schief, weil der Kernel das noch nicht kann.

Signed-off-by: Kevin Wolf <kevin@xxxxxxxxxx>
---
 src/modules/c/shell/cmds/sync.c    |   61 ++++++++++++++++++++++++++++++++++++
 src/modules/c/shell/commmands.c    |    1 +
 src/modules/c/shell/lang/lang_en.c |    1 +
 src/modules/c/shell/shell.c        |    1 +
 src/modules/c/shell/shell.h        |    1 +
 5 files changed, 65 insertions(+), 0 deletions(-)
 create mode 100644 src/modules/c/shell/cmds/sync.c

diff --git a/src/modules/c/shell/cmds/sync.c b/src/modules/c/shell/cmds/sync.c
new file mode 100644
index 0000000..70ade7a
--- /dev/null
+++ b/src/modules/c/shell/cmds/sync.c
@@ -0,0 +1,61 @@
+/*
+ * Copyright (c) 2010 The tyndur Project. All rights reserved.
+ *
+ * This code is derived from software contributed to the tyndur Project
+ * by Antoine Kaufmann.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * 1. Redistributions of source code must retain the above copyright
+ *    notice, this list of conditions and the following disclaimer.
+ * 2. Redistributions in binary form must reproduce the above copyright
+ *    notice, this list of conditions and the following disclaimer in the
+ *    documentation and/or other materials provided with the distribution.
+ * 3. All advertising materials mentioning features or use of this software
+ *    must display the following acknowledgement:
+ *     This product includes software developed by the tyndur Project
+ *     and its contributors.
+ * 4. Neither the name of the tyndur Project nor the names of its
+ *    contributors may be used to endorse or promote products derived
+ *    from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED
+ * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
+ * PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE COPYRIGHT HOLDERS OR
+ * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
+ * OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
+ * WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
+ * OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
+ * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <syscall.h>
+
+static void sync_display_usage(void);
+
+#ifdef CONFIG_SHELL_BUILTIN_ONLY
+    int shell_command_sync(int argc, char* argv[], const char* args)
+#else
+    int main(int argc, char* argv[])
+#endif
+{
+    if (argc != 1) {
+        sync_display_usage();
+        return -1;
+    }
+
+    lio_sync_all();
+    return EXIT_SUCCESS;
+}
+
+static void sync_display_usage()
+{
+    puts("\nAufruf: sync");
+}
+
diff --git a/src/modules/c/shell/commmands.c b/src/modules/c/shell/commmands.c
index 816aae2..419a453 100644
--- a/src/modules/c/shell/commmands.c
+++ b/src/modules/c/shell/commmands.c
@@ -190,6 +190,7 @@ int shell_command_help(int argc, char* argv[], const char* args)
         "  cat <Pfad>     Zeigt den Inhalt der Datei an\n"
         "  bincat <Pfad>  Zeigt den Inhalt der Datei als einzelne Bytes an\n"
         "  pipe <Pfad>    Ein-/Ausgabe auf einer Datei (z.B. TCP-Verbindung)\n"
+        "  sync           Alle veraenderten Block im Cache rausschreiben\n"
         "\n"
         "  date           Zeigt das Datum und die Uhrzeit an\n"
         "  free           Zeigt den Speicherverbrauch des Systems an\n"
diff --git a/src/modules/c/shell/lang/lang_en.c b/src/modules/c/shell/lang/lang_en.c
index a73a518..6a7c050 100644
--- a/src/modules/c/shell/lang/lang_en.c
+++ b/src/modules/c/shell/lang/lang_en.c
@@ -83,6 +83,7 @@ static const struct tms_strings dict[] = {
     "  cat <path>      Show contents of a file\n"
     "  bincat <path>   Show binary contents of a file (byte-wise)\n"
     "  pipe <path>     In-/Output to a file (e.g. TCP connection)\n"
+    "  sync            Write all changes from the cache to disk\n"
     "\n"
     "  date            Show current date and time\n"
     "  free            Show total system memory usage\n"
diff --git a/src/modules/c/shell/shell.c b/src/modules/c/shell/shell.c
index 72492f9..d111124 100644
--- a/src/modules/c/shell/shell.c
+++ b/src/modules/c/shell/shell.c
@@ -103,6 +103,7 @@ shell_command_t shell_commands[] = {
     {"sleep",       &shell_command_sleep},
     {"bench",       &shell_command_bench},
     {"read",        &shell_command_read},
+    {"sync",        &shell_command_sync},
 #endif
     {NULL,          NULL}
 };
diff --git a/src/modules/c/shell/shell.h b/src/modules/c/shell/shell.h
index e69323c..40f91c9 100644
--- a/src/modules/c/shell/shell.h
+++ b/src/modules/c/shell/shell.h
@@ -84,6 +84,7 @@ int shell_command_clear(int argc, char* argv[], const char* args);
     int shell_command_sleep(int argc, char* argv[], const char* args);
     int shell_command_bench(int argc, char* argv[], const char* args);
     int shell_command_read(int argc, char* argv[], const char* args);
+    int shell_command_sync(int argc, char* argv[], const char* args);
 #endif
 
 #endif
-- 
1.6.0.2