From 3577b518715c29175c5f517c6f3cf7a70b0e3d39 Mon Sep 17 00:00:00 2001 From: Artem Bityutskiy Date: Wed, 26 Jun 2013 17:28:13 +0300 Subject: [PATCH] VfatDiskMount: fix vfat UUID string The right format for the UUID string for vfat in Linux is 'XXXX-XXXX'. This is how it can be used in fstab, for example (UUID='XXXX-XXXX'). Also, Linux udev creates /dev/disk/by-uuid/XXXX-XXXX entries for vfat volumes. The problem in VfatDiskMount is that it provides it in the 'XXXXXXXX' form (without dash). However, mkfs.vfat does not like the dash, and this is why we did not have it, I guess. This patch fixes the situation and makes VfatDiskMount class expose UUID in a fstab-friendly format. This makes --fstab-entry=uuid option also work for VFAT volumes (I tested this). Change-Id: I1d676e3707ef1777df910273381fe4437b415f41 Signed-off-by: Artem Bityutskiy --- mic/utils/fs_related.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/mic/utils/fs_related.py b/mic/utils/fs_related.py index 5292e13..b9b9a97 100644 --- a/mic/utils/fs_related.py +++ b/mic/utils/fs_related.py @@ -550,7 +550,9 @@ class VfatDiskMount(DiskMount): DiskMount.__init__(self, disk, mountdir, fstype, rmmountdir) self.blocksize = blocksize self.fslabel = fslabel.replace("/", "") - self.uuid = "%08X" % int(time.time()) + rand1 = random.randint(0, 2**16 - 1) + rand2 = random.randint(0, 2**16 - 1) + self.uuid = "%04X-%04X" % (rand1, rand2) self.skipformat = skipformat self.fsopts = fsopts self.fsckcmd = find_binary_path("fsck." + self.fstype) @@ -561,7 +563,8 @@ class VfatDiskMount(DiskMount): return msger.verbose("Formating %s filesystem on %s" % (self.fstype, self.disk.device)) - rc = runner.show([self.mkfscmd, "-n", self.fslabel, "-i", self.uuid, self.disk.device]) + rc = runner.show([self.mkfscmd, "-n", self.fslabel, + "-i", self.uuid.replace("-", ""), self.disk.device]) if rc != 0: raise MountError("Error creating %s filesystem on disk %s" % (self.fstype,self.disk.device)) -- 2.7.4