summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog11
-rw-r--r--include/device/device_types.h5
-rw-r--r--linux/dev/glue/block.c36
3 files changed, 52 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 42d07ce..edad8a6 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,14 @@
+2001-01-09 Marcus Brinkmann <marcus@gnu.org>
+
+ * include/device/device_types.h: New get_status call
+ DEV_GET_RECORDS to get the number of records of a device (rather
+ than the number of bytes). Accordingly define
+ DEV_GET_RECORDS_DEVICE_RECORDS, DEV_GET_RECORDS_RECORD_SIZE and
+ DEV_GET_RECORDS_COUNT.
+
+ * linux/dev/glue/block.c (device_get_status): Handle
+ DEV_GET_RECORDS.
+
2000-11-26 David Welch <david.welch@seh.ox.ac.uk>
* i386/Makefrag (i386-installed-headers): Removed dead files
diff --git a/include/device/device_types.h b/include/device/device_types.h
index d02b8f1..08eec4a 100644
--- a/include/device/device_types.h
+++ b/include/device/device_types.h
@@ -110,6 +110,11 @@ typedef int dev_status_data_t[DEV_STATUS_MAX];
# define DEV_GET_SIZE_DEVICE_SIZE 0 /* 0 if unknown */
# define DEV_GET_SIZE_RECORD_SIZE 1 /* 1 if sequential */
#define DEV_GET_SIZE_COUNT 2
+/* size a device in record numbers, not bytes */
+#define DEV_GET_RECORDS 1
+# define DEV_GET_RECORDS_DEVICE_RECORDS 0 /* 0 if unknown */
+# define DEV_GET_RECORDS_RECORD_SIZE 1 /* 1 if sequential */
+#define DEV_GET_RECORDS_COUNT 2
/*
* Device error codes
diff --git a/linux/dev/glue/block.c b/linux/dev/glue/block.c
index c450ea4..f6506ee 100644
--- a/linux/dev/glue/block.c
+++ b/linux/dev/glue/block.c
@@ -1632,6 +1632,42 @@ device_get_status (void *d, dev_flavor_t flavor, dev_status_t status,
*status_count = DEV_GET_SIZE_COUNT;
break;
+ case DEV_GET_RECORDS:
+ if (disk_major (MAJOR (bd->dev)))
+ {
+ assert (bd->ds->gd);
+
+ if (bd->part >= 0)
+ {
+ struct disklabel *lp;
+
+ assert (bd->ds->labels);
+ lp = bd->ds->labels[MINOR (bd->dev)];
+ assert (lp);
+ (status[DEV_GET_RECORDS_DEVICE_RECORDS]
+ = lp->d_partitions[bd->part].p_size);
+ }
+ else
+ (status[DEV_GET_RECORDS_DEVICE_RECORDS]
+ = bd->ds->gd->part[MINOR (bd->dev)].nr_sects);
+
+ status[DEV_GET_RECORDS_RECORD_SIZE] = 512;
+ }
+ else
+ {
+ assert (blk_size[MAJOR (bd->dev)]);
+ (status[DEV_GET_RECORDS_DEVICE_RECORDS]
+ = blk_size[MAJOR (bd->dev)][MINOR (bd->dev)]);
+ status[DEV_GET_RECORDS_RECORD_SIZE] = BLOCK_SIZE;
+ }
+ /* Always return DEV_GET_RECORDS_COUNT. This is what all native
+ Mach drivers do, and makes it possible to detect the absence
+ of the call by setting it to a different value on input. MiG
+ makes sure that we will never return more integers than the
+ user asked for. */
+ *status_count = DEV_GET_RECORDS_COUNT;
+ break;
+
case V_GETPARMS:
if (*status_count < (sizeof (struct disk_parms) / sizeof (int)))
return D_INVALID_OPERATION;