chiark / gitweb /
delete vol_id and require util-linux-ng's blkid
[elogind.git] / extras / volume_id / lib / ntfs.c
index 8154e7685ae625660a7d8fcface78972a9a6b153..f727634094916c08e1d831eb4653c35ff2b82976 100644 (file)
@@ -97,6 +97,7 @@ static struct volume_info {
 
 int volume_id_probe_ntfs(struct volume_id *id, uint64_t off, uint64_t size)
 {
+       uint8_t volume_serial[8];
        unsigned int sector_size;
        unsigned int cluster_size;
        uint64_t mft_cluster;
@@ -110,7 +111,7 @@ int volume_id_probe_ntfs(struct volume_id *id, uint64_t off, uint64_t size)
        const uint8_t *buf;
        const uint8_t *val;
 
-       info("probing at offset 0x%llx\n", (unsigned long long) off);
+       info("probing at offset 0x%" PRIx64 "\n", off);
 
        ns = (struct ntfs_super_block *) volume_id_get_buffer(id, off, 0x200);
        if (ns == NULL)
@@ -119,7 +120,7 @@ int volume_id_probe_ntfs(struct volume_id *id, uint64_t off, uint64_t size)
        if (memcmp(ns->oem_id, "NTFS", 4) != 0)
                return -1;
 
-       volume_id_set_uuid(id, ns->volume_serial, 0, UUID_64BIT_LE);
+       memcpy(volume_serial, ns->volume_serial, sizeof(volume_serial));
 
        sector_size = le16_to_cpu(ns->bytes_per_sector);
        if (sector_size < 0x200)
@@ -137,8 +138,8 @@ int volume_id_probe_ntfs(struct volume_id *id, uint64_t off, uint64_t size)
 
        dbg("sectorsize  0x%x\n", sector_size);
        dbg("clustersize 0x%x\n", cluster_size);
-       dbg("mftcluster  %llu\n", (unsigned long long) mft_cluster);
-       dbg("mftoffset  0x%llx\n", (unsigned long long) mft_off);
+       dbg("mftcluster  %" PRIu64 "\n", mft_cluster);
+       dbg("mftoffset  0x%" PRIx64 "\n", mft_off);
        dbg("cluster per mft_record  %i\n", ns->cluster_per_mft_record);
        dbg("mft record size  %i\n", mft_record_size);
 
@@ -193,8 +194,10 @@ int volume_id_probe_ntfs(struct volume_id *id, uint64_t off, uint64_t size)
                }
        }
 
+       volume_id_set_uuid(id, volume_serial, 0, UUID_64BIT_LE);
        volume_id_set_usage(id, VOLUME_ID_FILESYSTEM);
        id->type = "ntfs";
-
+       /* we think this is ntfs, but we make sure no other signatures are found */
+       id->force_unique_result = 1;
        return 0;
 }