#include "c-ctype.h"
#include "actions.h"
+/* Confirmed this is true up to ext4 from the Linux sources. */
+#define EXT2_LABEL_MAX 16
+
/* Choose which tools like mke2fs to use. For RHEL 5 (only) there
* is a special set of tools which support ext2/3/4. eg. On RHEL 5,
* mke2fs only supports ext2/3, but mke4fs supports ext2/3/4.
if (e2prog (prog) == -1)
return -1;
+ if (strlen (label) > EXT2_LABEL_MAX) {
+ reply_with_error ("%s: ext2 labels are limited to %d bytes",
+ label, EXT2_LABEL_MAX);
+ return -1;
+ }
+
r = command (NULL, &err, prog, device, label, NULL);
if (r == -1) {
reply_with_error ("%s", err);
if (e2prog (prog) == -1)
return -1;
+ if (strlen (label) > EXT2_LABEL_MAX) {
+ reply_with_error ("%s: ext2 labels are limited to %d bytes",
+ label, EXT2_LABEL_MAX);
+ return -1;
+ }
+
char blocksize_s[32];
snprintf (blocksize_s, sizeof blocksize_s, "%d", blocksize);
if (e2prog (prog) == -1)
return -1;
+ if (strlen (label) > EXT2_LABEL_MAX) {
+ reply_with_error ("%s: ext2 labels are limited to %d bytes",
+ label, EXT2_LABEL_MAX);
+ return -1;
+ }
+
char blocksize_s[32];
snprintf (blocksize_s, sizeof blocksize_s, "%d", blocksize);
#include "actions.h"
#include "optgroups.h"
+/* Confirmed this is true for Linux swap partitions from the Linux sources. */
+#define SWAP_LABEL_MAX 16
+
/* Convenient place to test for the later version of e2fsprogs
* and util-linux which supports -U parameters to specify UUIDs.
* (Not supported in RHEL 5).
int
do_mkswap_L (const char *label, const char *device)
{
+ if (strlen (label) > SWAP_LABEL_MAX) {
+ reply_with_error ("%s: Linux swap labels are limited to %d bytes",
+ label, SWAP_LABEL_MAX);
+ return -1;
+ }
+
return mkswap (device, "-L", label);
}
int
do_swapon_label (const char *label)
{
+ if (strlen (label) > SWAP_LABEL_MAX) {
+ reply_with_error ("%s: Linux swap labels are limited to %d bytes",
+ label, SWAP_LABEL_MAX);
+ return -1;
+ }
+
return swaponoff ("swapon", "-L", label);
}
int
do_swapoff_label (const char *label)
{
+ if (strlen (label) > SWAP_LABEL_MAX) {
+ reply_with_error ("%s: Linux swap labels are limited to %d bytes",
+ label, SWAP_LABEL_MAX);
+ return -1;
+ }
+
return swaponoff ("swapoff", "-L", label);
}