--- linux-2.4.24/arch/um/drivers/ubd_kern.c 2004-04-11 20:56:19.000000000 +0100 +++ linux-2.4.24.new/arch/um/drivers/ubd_kern.c 2004-04-11 20:51:37.000000000 +0100 @@ -1100,6 +1100,37 @@ } } +static void create_ubd_serial(char *file, char *serial) +{ + struct uml_stat buf; + int i, device, err; + long long inode ; + char *val = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"; + + serial[0] = '\0'; + if(file == NULL) return; + + err = os_stat_file(file, &buf); + if(err < 0){ + return; + } + + device = buf.ust_dev; + for ( i=0; i<6; ++i ) { + serial[i] = val[device%36]; + device /= 36; + } + + inode = buf.ust_ino; + for ( i=0; i<13; ++i ) { + serial[i+6] = val[inode%36]; + inode /= 36; + } + serial[19] = '\0'; + + return; +} + static int ubd_ioctl(struct inode * inode, struct file * file, unsigned int cmd, unsigned long arg) { @@ -1164,6 +1195,7 @@ case HDIO_GET_IDENTITY: ubd_id.cyls = dev->size / (128 * 32 * hardsect_sizes[minor]); + create_ubd_serial(dev->file, ubd_id.serial_no); if(copy_to_user((char *) arg, (char *) &ubd_id, sizeof(ubd_id))) return(-EFAULT);