From: Ben Pfaff Date: Wed, 1 Sep 2004 04:02:22 +0000 (+0000) Subject: s/disk_sector_no/disk_sector_t/g X-Git-Url: https://pintos-os.org/cgi-bin/gitweb.cgi?p=pintos-anon;a=commitdiff_plain;h=41cc2728b06b5e1eeb4cf5a4979692640049e047 s/disk_sector_no/disk_sector_t/g --- diff --git a/src/devices/disk.c b/src/devices/disk.c index 2381c57..7d44569 100644 --- a/src/devices/disk.c +++ b/src/devices/disk.c @@ -51,7 +51,7 @@ struct disk int dev_no; /* Device 0 or 1 for master or slave. */ bool is_ata; /* 1=This device is an ATA disk. */ - disk_sector_no capacity; /* Capacity in sectors (if is_ata is true). */ + disk_sector_t capacity; /* Capacity in sectors (if is_ata is true). */ }; /* An ATA channel (aka controller). @@ -78,7 +78,7 @@ static void reset_channel (struct channel *); static bool check_device_type (struct disk *); static void identify_ata_device (struct disk *); -static void select_sector (struct disk *, disk_sector_no); +static void select_sector (struct disk *, disk_sector_t); static void issue_pio_command (struct channel *, uint8_t command); static void input_sector (struct channel *, void *); static void output_sector (struct channel *, const void *); @@ -167,7 +167,7 @@ disk_get (int chan_no, int dev_no) /* Returns the size of disk D, measured in DISK_SECTOR_SIZE-byte sectors. */ -disk_sector_no +disk_sector_t disk_size (struct disk *d) { ASSERT (d != NULL); @@ -178,7 +178,7 @@ disk_size (struct disk *d) /* Reads sector SEC_NO from disk D into BUFFER, which must have room for DISK_SECTOR_SIZE bytes. */ void -disk_read (struct disk *d, disk_sector_no sec_no, void *buffer) +disk_read (struct disk *d, disk_sector_t sec_no, void *buffer) { struct channel *c; @@ -200,7 +200,7 @@ disk_read (struct disk *d, disk_sector_no sec_no, void *buffer) DISK_SECTOR_SIZE bytes. Returns after the disk has acknowledged receiving the data. */ void -disk_write (struct disk *d, disk_sector_no sec_no, const void *buffer) +disk_write (struct disk *d, disk_sector_t sec_no, const void *buffer) { struct channel *c; @@ -383,7 +383,7 @@ printk_ata_string (char *string, size_t size) writes SEC_NO to the disk's sector selection registers. (We use LBA mode.) */ static void -select_sector (struct disk *d, disk_sector_no sec_no) +select_sector (struct disk *d, disk_sector_t sec_no) { struct channel *c = d->channel; diff --git a/src/devices/disk.h b/src/devices/disk.h index 9d52164..d149682 100644 --- a/src/devices/disk.h +++ b/src/devices/disk.h @@ -4,15 +4,21 @@ #include #include +/* Size of a disk sector in bytes. */ #define DISK_SECTOR_SIZE 512 -typedef uint32_t disk_sector_no; -#define PRDSNu PRIu32 /* For use with printk(). */ +/* Index of a disk sector within a disk. + Good enough for disks up to 2 TB. */ +typedef uint32_t disk_sector_t; + +/* Format specifier for printk(), e.g.: + printk ("sector=%"PRDSNu"\n", sector); */ +#define PRDSNu PRIu32 void disk_init (void); struct disk *disk_get (int chan_no, int dev_no); -disk_sector_no disk_size (struct disk *); -void disk_read (struct disk *, disk_sector_no, void *); -void disk_write (struct disk *, disk_sector_no, const void *); +disk_sector_t disk_size (struct disk *); +void disk_read (struct disk *, disk_sector_t, void *); +void disk_write (struct disk *, disk_sector_t, const void *); #endif /* disk.h */ diff --git a/src/filesys/directory.c b/src/filesys/directory.c index 93a505b..353260f 100644 --- a/src/filesys/directory.c +++ b/src/filesys/directory.c @@ -58,7 +58,7 @@ lookup (const struct dir *d, const char *name) bool dir_lookup (const struct dir *d, const char *name, - disk_sector_no *filehdr_sector) + disk_sector_t *filehdr_sector) { const struct dir_entry *e; @@ -77,7 +77,7 @@ dir_lookup (const struct dir *d, const char *name, } bool -dir_add (struct dir *d, const char *name, disk_sector_no filehdr_sector) +dir_add (struct dir *d, const char *name, disk_sector_t filehdr_sector) { size_t i; diff --git a/src/filesys/directory.h b/src/filesys/directory.h index aa07ad1..8e4ed47 100644 --- a/src/filesys/directory.h +++ b/src/filesys/directory.h @@ -19,7 +19,7 @@ struct dir_entry { bool in_use; char name[FILENAME_LEN_MAX + 1]; - disk_sector_no filehdr_sector; + disk_sector_t filehdr_sector; }; struct file; @@ -27,8 +27,8 @@ bool dir_init (struct dir *, size_t entry_cnt); void dir_destroy (struct dir *); void dir_read (struct dir *, struct file *); void dir_write (struct dir *, struct file *); -bool dir_lookup (const struct dir *, const char *name, disk_sector_no *); -bool dir_add (struct dir *, const char *name, disk_sector_no); +bool dir_lookup (const struct dir *, const char *name, disk_sector_t *); +bool dir_add (struct dir *, const char *name, disk_sector_t); bool dir_remove (struct dir *, const char *name); void dir_list (const struct dir *); void dir_dump (const struct dir *); diff --git a/src/filesys/file.c b/src/filesys/file.c index e16ff5f..8969e17 100644 --- a/src/filesys/file.c +++ b/src/filesys/file.c @@ -7,7 +7,7 @@ #include "filesys.h" bool -file_open (struct file *file, disk_sector_no hdr_sector) +file_open (struct file *file, disk_sector_t hdr_sector) { file->hdr = filehdr_read (hdr_sector); file->bounce = malloc (DISK_SECTOR_SIZE); diff --git a/src/filesys/file.h b/src/filesys/file.h index b29ce33..c3cde12 100644 --- a/src/filesys/file.h +++ b/src/filesys/file.h @@ -14,7 +14,7 @@ struct file off_t pos; }; -bool file_open (struct file *, disk_sector_no); +bool file_open (struct file *, disk_sector_t); void file_close (struct file *); off_t file_read (struct file *, void *, off_t); off_t file_read_at (struct file *, void *, off_t size, off_t start); diff --git a/src/filesys/filehdr.c b/src/filesys/filehdr.c index aad11e5..2f24d3b 100644 --- a/src/filesys/filehdr.c +++ b/src/filesys/filehdr.c @@ -47,7 +47,7 @@ filehdr_deallocate (struct filehdr *h, struct bitmap *b) } struct filehdr * -filehdr_read (disk_sector_no filehdr_sector) +filehdr_read (disk_sector_t filehdr_sector) { struct filehdr *h = calloc (1, sizeof *h); if (h == NULL) @@ -60,7 +60,7 @@ filehdr_read (disk_sector_no filehdr_sector) } void -filehdr_write (const struct filehdr *h, disk_sector_no filehdr_sector) +filehdr_write (const struct filehdr *h, disk_sector_t filehdr_sector) { ASSERT (h != NULL); ASSERT (sizeof *h == DISK_SECTOR_SIZE); @@ -73,7 +73,7 @@ filehdr_destroy (struct filehdr *h) free (h); } -disk_sector_no +disk_sector_t filehdr_byte_to_sector (const struct filehdr *h, off_t pos) { size_t idx; @@ -81,7 +81,7 @@ filehdr_byte_to_sector (const struct filehdr *h, off_t pos) ASSERT (h != NULL); idx = pos / DISK_SECTOR_SIZE; - return idx < h->sector_cnt ? h->sectors[idx] : (disk_sector_no) -1; + return idx < h->sector_cnt ? h->sectors[idx] : (disk_sector_t) -1; } off_t diff --git a/src/filesys/filehdr.h b/src/filesys/filehdr.h index 7b0ecc2..32792df 100644 --- a/src/filesys/filehdr.h +++ b/src/filesys/filehdr.h @@ -7,22 +7,22 @@ #include "off_t.h" #define DIRECT_CNT ((DISK_SECTOR_SIZE - sizeof (off_t) * 2) \ - / sizeof (disk_sector_no)) + / sizeof (disk_sector_t)) struct filehdr { off_t length; size_t sector_cnt; - disk_sector_no sectors[DIRECT_CNT]; + disk_sector_t sectors[DIRECT_CNT]; }; struct bitmap; struct filehdr *filehdr_allocate (struct bitmap *, off_t length); void filehdr_deallocate (struct filehdr *, struct bitmap *); -struct filehdr *filehdr_read (disk_sector_no); -void filehdr_write (const struct filehdr *, disk_sector_no); +struct filehdr *filehdr_read (disk_sector_t); +void filehdr_write (const struct filehdr *, disk_sector_t); void filehdr_destroy (struct filehdr *); -disk_sector_no filehdr_byte_to_sector (const struct filehdr *, off_t); +disk_sector_t filehdr_byte_to_sector (const struct filehdr *, off_t); off_t filehdr_length (const struct filehdr *); void filehdr_print (const struct filehdr *); diff --git a/src/filesys/filesys.c b/src/filesys/filesys.c index cae53ea..acd7123 100644 --- a/src/filesys/filesys.c +++ b/src/filesys/filesys.c @@ -90,7 +90,7 @@ filesys_create (const char *name, off_t initial_size) { struct dir dir; struct bitmap free_map; - disk_sector_no hdr_sector; + disk_sector_t hdr_sector; struct filehdr *filehdr; bool success = false; @@ -139,7 +139,7 @@ bool filesys_open (const char *name, struct file *file) { struct dir dir; - disk_sector_no hdr_sector; + disk_sector_t hdr_sector; bool success = false; if (!dir_init (&dir, NUM_DIR_ENTRIES)) @@ -156,7 +156,7 @@ bool filesys_remove (const char *name) { struct dir dir; - disk_sector_no hdr_sector; + disk_sector_t hdr_sector; struct filehdr *filehdr; struct bitmap free_map; bool success = false; diff --git a/src/filesys/fsutil.c b/src/filesys/fsutil.c index 9c814e1..fb9a81b 100644 --- a/src/filesys/fsutil.c +++ b/src/filesys/fsutil.c @@ -18,7 +18,7 @@ copy (const char *filename, off_t size) { struct disk *src; struct file dst; - disk_sector_no sector; + disk_sector_t sector; void *buffer; /* Open source disk. */