[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Please create UUIDs on new swap partitions
From: |
Colin Watson |
Subject: |
Please create UUIDs on new swap partitions |
Date: |
Thu, 31 Aug 2006 10:12:56 +0100 |
User-agent: |
Mutt/1.5.9i |
It would be useful if parted created UUIDs on new swap partitions, as
mkswap does. (The Linux kernel is in the process of renaming a number of
/dev/hd* devices to /dev/sd* by means of moving IDE drivers to libata,
and using UUIDs helps to avoid userspace breakage caused by this.)
Here's a patch:
diff -urNad parted-1.7.1~/libparted/fs/linux_swap/linux_swap.c
parted-1.7.1/libparted/fs/linux_swap/linux_swap.c
--- parted-1.7.1~/libparted/fs/linux_swap/linux_swap.c 2006-05-25
18:29:01.000000000 +0100
+++ parted-1.7.1/libparted/fs/linux_swap/linux_swap.c 2006-08-31
09:37:25.000000000 +0100
@@ -33,6 +33,7 @@
#include <unistd.h>
#include <string.h>
+#include <uuid/uuid.h>
#define SWAP_SPECIFIC(fs) ((SwapSpecific*) (fs->type_specific))
#define BUFFER_SIZE 128
@@ -49,7 +50,9 @@
unsigned int version;
unsigned int last_page;
unsigned int nr_badpages;
- unsigned int padding[125];
+ unsigned char uuid[16];
+ char volume_name[16];
+ unsigned int padding[117];
unsigned int badpages[1];
} SwapNewHeader;
@@ -386,9 +389,13 @@
if (fs_info->version == 0) {
memcpy (sig, "SWAP-SPACE", 10);
} else {
+ uuid_t uuid_dat;
fs_info->header->new.version = 1;
fs_info->header->new.last_page = fs_info->page_count - 1;
fs_info->header->new.nr_badpages = 0;
+ uuid_generate (uuid_dat);
+ memcpy (fs_info->header->new.uuid, uuid_dat,
+ sizeof (fs_info->header->new.uuid));
memcpy (sig, "SWAPSPACE2", 10);
}
Thanks,
--
Colin Watson address@hidden
signature.asc
Description: Digital signature
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- Please create UUIDs on new swap partitions,
Colin Watson <=