X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?p=pintos-anon;a=blobdiff_plain;f=src%2Fdevices%2Fdisk.c;fp=src%2Fdevices%2Fdisk.c;h=5320d2e48f602c8eb1b5a36f9899b789263fb362;hp=971f3af537288f38523d92e0807e2489870e33f6;hb=fba4443410241dd95c25a0fd7c5f8c0d8ff30ada;hpb=76d7f305a649ad998194b7b5184a07fa7544c360 diff --git a/src/devices/disk.c b/src/devices/disk.c index 971f3af..5320d2e 100644 --- a/src/devices/disk.c +++ b/src/devices/disk.c @@ -204,6 +204,15 @@ disk_size (struct disk *d) return d->capacity; } +/* Returns a human-readable name for disk D. */ +const char * +disk_name (struct disk *d) +{ + ASSERT (d != NULL); + + return d->name; +} + /* Reads sector SEC_NO from disk D into BUFFER, which must have room for DISK_SECTOR_SIZE bytes. */ void @@ -373,15 +382,7 @@ identify_ata_device (struct disk *d) /* Print identification message. */ printf ("%s: detected %'"PRDSNu" sector (", d->name, d->capacity); - if (d->capacity > 1024 / DISK_SECTOR_SIZE * 1024 * 1024) - printf ("%"PRDSNu" GB", - d->capacity / (1024 / DISK_SECTOR_SIZE * 1024 * 1024)); - else if (d->capacity > 1024 / DISK_SECTOR_SIZE * 1024) - printf ("%"PRDSNu" MB", d->capacity / (1024 / DISK_SECTOR_SIZE * 1024)); - else if (d->capacity > 1024 / DISK_SECTOR_SIZE) - printf ("%"PRDSNu" kB", d->capacity / (1024 / DISK_SECTOR_SIZE)); - else - printf ("%"PRDSNu" byte", d->capacity * DISK_SECTOR_SIZE); + print_human_readable_size ((uint64_t) d->capacity * DISK_SECTOR_SIZE); printf (") disk, model \""); print_ata_string ((char *) &id[27], 40); printf ("\", serial \"");