Whamcloud - gitweb
e2fsck: map PROMPT_* values to prompt messages
[tools/e2fsprogs.git] / misc / e2label.c
index 477c34b..910ccc7 100644 (file)
@@ -2,7 +2,7 @@
  * e2label.c           - Print or change the volume label on an ext2 fs
  *
  * Written by Andries Brouwer (aeb@cwi.nl), 970714
- * 
+ *
  * Copyright 1997, 1998 by Theodore Ts'o.
  *
  * %Begin-Header%
@@ -11,6 +11,7 @@
  * %End-Header%
  */
 
+#include "config.h"
 #include <stdio.h>
 #include <string.h>
 #include <fcntl.h>
@@ -19,6 +20,9 @@
 #include <time.h>
 #ifdef HAVE_GETOPT_H
 #include <getopt.h>
+#else
+extern char *optarg;
+extern int optind;
 #endif
 #ifdef HAVE_UNISTD_H
 #include <unistd.h>
@@ -29,7 +33,7 @@
 #ifdef HAVE_ERRNO_H
 #include <errno.h>
 #endif
-#include "nls-enable.h"
+#include "support/nls-enable.h"
 
 #define EXT2_SUPER_MAGIC 0xEF53
 
@@ -77,7 +81,7 @@ static void print_label (char *dev)
        char label[VOLNAMSZ+1];
 
        open_e2fs (dev, O_RDONLY);
-       strncpy(label, sb.s_volume_name, VOLNAMSZ);
+       snprintf(label, sizeof(label), "%.*s", EXT2_LEN_STR(sb.s_volume_name));
        label[VOLNAMSZ] = 0;
        printf("%s\n", label);
 }