VfatDiskMount: fix vfat UUID string
authorArtem Bityutskiy <artem.bityutskiy@intel.com>
Wed, 26 Jun 2013 14:28:13 +0000 (17:28 +0300)
committerArtem Bityutskiy <artem.bityutskiy@intel.com>
Wed, 26 Jun 2013 14:28:13 +0000 (17:28 +0300)
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 <artem.bityutskiy@intel.com>
mic/utils/fs_related.py

index 5292e13..b9b9a97 100644 (file)
@@ -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))