]> git.ipfire.org Git - thirdparty/mdadm.git/commitdiff
imsm: only use the device name as a fallback when IMSM_DEVNAME_AS_SERIAL=1
authorDan Williams <dan.j.williams@intel.com>
Tue, 16 Sep 2008 03:58:41 +0000 (20:58 -0700)
committerDan Williams <dan.j.williams@intel.com>
Tue, 16 Sep 2008 03:58:41 +0000 (20:58 -0700)
Also ensure that the serial buffer is initialized.

Signed-off-by: Dan Williams <dan.j.williams@intel.com>
super-intel.c

index c6b7be433b601a693f8c85bce10ae28dc50285d6..4b05fbed51c7322f0a1e0a3fdc755466203e52a2 100644 (file)
@@ -849,16 +849,14 @@ static int imsm_read_serial(int fd, char *devname,
 
        memset(scsi_serial, 0, sizeof(scsi_serial));
 
-       if (imsm_env_devname_as_serial()) {
-               char name[MAX_RAID_SERIAL_LEN];
-               
-               fd2devname(fd, name);
-               strcpy((char *) serial, name);
+       rv = scsi_get_serial(fd, scsi_serial, sizeof(scsi_serial));
+
+       if (rv && imsm_env_devname_as_serial()) {
+               memset(serial, 0, MAX_RAID_SERIAL_LEN);
+               fd2devname(fd, (char *) serial);
                return 0;
        }
 
-       rv = scsi_get_serial(fd, scsi_serial, sizeof(scsi_serial));
-
        if (rv != 0) {
                if (devname)
                        fprintf(stderr,