* 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%
* %End-Header%
*/
+#include "config.h"
#include <stdio.h>
#include <string.h>
#include <fcntl.h>
#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>
#ifdef HAVE_ERRNO_H
#include <errno.h>
#endif
-#include "nls-enable.h"
+#include "support/nls-enable.h"
#define EXT2_SUPER_MAGIC 0xEF53
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);
}