projects
/
pintos-anon
/ commitdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
| commitdiff |
tree
raw
|
patch
|
inline
| side by side (parent:
aa9a8ed
)
s/disk_sector_no/disk_sector_t/g
author
Ben Pfaff
<blp@cs.stanford.edu>
Wed, 1 Sep 2004 04:02:22 +0000
(
04:02
+0000)
committer
Ben Pfaff
<blp@cs.stanford.edu>
Wed, 1 Sep 2004 04:02:22 +0000
(
04:02
+0000)
src/devices/disk.c
patch
|
blob
|
history
src/devices/disk.h
patch
|
blob
|
history
src/filesys/directory.c
patch
|
blob
|
history
src/filesys/directory.h
patch
|
blob
|
history
src/filesys/file.c
patch
|
blob
|
history
src/filesys/file.h
patch
|
blob
|
history
src/filesys/filehdr.c
patch
|
blob
|
history
src/filesys/filehdr.h
patch
|
blob
|
history
src/filesys/filesys.c
patch
|
blob
|
history
src/filesys/fsutil.c
patch
|
blob
|
history
diff --git
a/src/devices/disk.c
b/src/devices/disk.c
index 2381c57a045284762d29652efd7896e02f0b829a..7d445692688f31a8413d13198efb1da87b8962bd 100644
(file)
--- 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. */
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).
};
/* 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 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 *);
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. */
/* 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);
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
/* 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;
{
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_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;
{
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
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;
{
struct channel *c = d->channel;
diff --git
a/src/devices/disk.h
b/src/devices/disk.h
index 9d5216418e02128cf62ecd45a1d210a1cd1c9ece..d1496827282e06262b0574ccb129f79e17a5f849 100644
(file)
--- a/
src/devices/disk.h
+++ b/
src/devices/disk.h
@@
-4,15
+4,21
@@
#include <inttypes.h>
#include <stdint.h>
#include <inttypes.h>
#include <stdint.h>
+/* Size of a disk sector in bytes. */
#define DISK_SECTOR_SIZE 512
#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);
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 */
#endif /* disk.h */
diff --git
a/src/filesys/directory.c
b/src/filesys/directory.c
index 93a505b2424500f12c24087dcf01b20efd61d6ef..353260f91bed04547ea5a56c4dd1b6513e1070fe 100644
(file)
--- 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,
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;
{
const struct dir_entry *e;
@@
-77,7
+77,7
@@
dir_lookup (const struct dir *d, const char *name,
}
bool
}
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;
{
size_t i;
diff --git
a/src/filesys/directory.h
b/src/filesys/directory.h
index aa07ad1b25586e5f1aa4f3c43a00b99241d4ed0f..8e4ed47c8b4c0c196de7d016278f6d2a35fa028f 100644
(file)
--- 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];
{
bool in_use;
char name[FILENAME_LEN_MAX + 1];
- disk_sector_
no
filehdr_sector;
+ disk_sector_
t
filehdr_sector;
};
struct file;
};
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 *);
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 *);
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 e16ff5fc695630cc55b4571f36d27a9d1f3e3fbb..8969e179e093ec6c9fd540e995867cfb08ba198f 100644
(file)
--- a/
src/filesys/file.c
+++ b/
src/filesys/file.c
@@
-7,7
+7,7
@@
#include "filesys.h"
bool
#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);
{
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 b29ce33a5a488bb15c513a25f998a8e323535988..c3cde121ad0b55ef6189272382019602b55ac0e8 100644
(file)
--- a/
src/filesys/file.h
+++ b/
src/filesys/file.h
@@
-14,7
+14,7
@@
struct file
off_t pos;
};
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);
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 aad11e564c2ad15199b639c7827f8b70ecc04256..2f24d3bb1134c9925bb594643a675a88d8618a7e 100644
(file)
--- a/
src/filesys/filehdr.c
+++ b/
src/filesys/filehdr.c
@@
-47,7
+47,7
@@
filehdr_deallocate (struct filehdr *h, struct bitmap *b)
}
struct filehdr *
}
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)
{
struct filehdr *h = calloc (1, sizeof *h);
if (h == NULL)
@@
-60,7
+60,7
@@
filehdr_read (disk_sector_no filehdr_sector)
}
void
}
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);
{
ASSERT (h != NULL);
ASSERT (sizeof *h == DISK_SECTOR_SIZE);
@@
-73,7
+73,7
@@
filehdr_destroy (struct filehdr *h)
free (h);
}
free (h);
}
-disk_sector_
no
+disk_sector_
t
filehdr_byte_to_sector (const struct filehdr *h, off_t pos)
{
size_t idx;
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;
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
}
off_t
diff --git
a/src/filesys/filehdr.h
b/src/filesys/filehdr.h
index 7b0ecc234005887332b2eb6f97f7c9a55e0087ba..32792df804fc9172e03822ea54312e9943f5b7b2 100644
(file)
--- 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) \
#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;
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 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 *);
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 *);
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 cae53eac492d42cea94a34b5b9da173bdb6034a3..acd712347859350b0a7ba7cdf37097e42fd96841 100644
(file)
--- 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;
{
struct dir dir;
struct bitmap free_map;
- disk_sector_
no
hdr_sector;
+ disk_sector_
t
hdr_sector;
struct filehdr *filehdr;
bool success = false;
struct filehdr *filehdr;
bool success = false;
@@
-139,7
+139,7
@@
bool
filesys_open (const char *name, struct file *file)
{
struct dir dir;
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))
bool success = false;
if (!dir_init (&dir, NUM_DIR_ENTRIES))
@@
-156,7
+156,7
@@
bool
filesys_remove (const char *name)
{
struct dir dir;
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;
struct filehdr *filehdr;
struct bitmap free_map;
bool success = false;
diff --git
a/src/filesys/fsutil.c
b/src/filesys/fsutil.c
index 9c814e1a44b0d8f0f245498df45e5e22ebb1c8d4..fb9a81b79cbe93fc0df6c50cbce72e1ad925f0b3 100644
(file)
--- 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;
{
struct disk *src;
struct file dst;
- disk_sector_
no
sector;
+ disk_sector_
t
sector;
void *buffer;
/* Open source disk. */
void *buffer;
/* Open source disk. */