chiark / gitweb /
path: optionally, create watched directories in .path units
[elogind.git] / src / cryptsetup.c
index 506ce9b5c9086bf3d4fec4cd0431affc5bc139ba..3aa822a1d020591f618e5f6e18b8faab467d65f4 100644 (file)
@@ -31,6 +31,7 @@
 #include "util.h"
 #include "strv.h"
 #include "ask-password-api.h"
+#include "def.h"
 
 static const char *opt_type = NULL; /* LUKS1 or PLAIN */
 static char *opt_cipher = NULL;
@@ -207,6 +208,17 @@ finish:
         return mp;
 }
 
+static int help(void) {
+
+        printf("%s attach VOLUME SOURCEDEVICE [PASSWORD] [OPTIONS]\n"
+               "%s detach VOLUME\n\n"
+               "Attaches or detaches an encrypted block device.\n",
+               program_invocation_short_name,
+               program_invocation_short_name);
+
+        return 0;
+}
+
 int main(int argc, char *argv[]) {
         int r = EXIT_FAILURE;
         struct crypt_device *cd = NULL;
@@ -214,6 +226,11 @@ int main(int argc, char *argv[]) {
         const char *cipher = NULL, *cipher_mode = NULL, *hash = NULL, *name = NULL;
         char *description = NULL, *name_buffer = NULL, *mount_point = NULL;
 
+        if (argc <= 1) {
+                help();
+                return EXIT_SUCCESS;
+        }
+
         if (argc < 3) {
                 log_error("This program requires at least two arguments.");
                 return EXIT_FAILURE;
@@ -292,7 +309,7 @@ int main(int argc, char *argv[]) {
                 if (opt_readonly)
                         flags |= CRYPT_ACTIVATE_READONLY;
 
-                until = now(CLOCK_MONOTONIC) + (opt_timeout > 0 ? opt_timeout : 60 * USEC_PER_SEC);
+                until = now(CLOCK_MONOTONIC) + (opt_timeout > 0 ? opt_timeout : DEFAULT_TIMEOUT_USEC);
 
                 opt_tries = opt_tries > 0 ? opt_tries : 3;
                 opt_key_size = (opt_key_size > 0 ? opt_key_size : 256);