void
fsutil_cat (char **argv)
{
- const char *filename = argv[1];
+ const char *file_name = argv[1];
struct file *file;
char *buffer;
- printf ("Printing '%s' to the console...\n", filename);
- file = filesys_open (filename);
+ printf ("Printing '%s' to the console...\n", file_name);
+ file = filesys_open (file_name);
if (file == NULL)
- PANIC ("%s: open failed", filename);
+ PANIC ("%s: open failed", file_name);
buffer = palloc_get_page (PAL_ASSERT);
for (;;)
{
void
fsutil_rm (char **argv)
{
- const char *filename = argv[1];
+ const char *file_name = argv[1];
- printf ("Deleting '%s'...\n", filename);
- if (!filesys_remove (filename))
- PANIC ("%s: delete failed\n", filename);
+ printf ("Deleting '%s'...\n", file_name);
+ if (!filesys_remove (file_name))
+ PANIC ("%s: delete failed\n", file_name);
}
/* Copies from the "scratch" disk, hdc or hd1:0 to file ARGV[1]
- in the filesystem.
+ in the file system.
The current sector on the scratch disk must begin with the
string "PUT\0" followed by a 32-bit little-endian integer
{
static disk_sector_t sector = 0;
- const char *filename = argv[1];
+ const char *file_name = argv[1];
struct disk *src;
struct file *dst;
off_t size;
void *buffer;
- printf ("Putting '%s' into the file system...\n", filename);
+ printf ("Putting '%s' into the file system...\n", file_name);
/* Allocate buffer. */
buffer = malloc (DISK_SECTOR_SIZE);
/* Read file size. */
disk_read (src, sector++, buffer);
if (memcmp (buffer, "PUT", 4))
- PANIC ("%s: missing PUT signature on scratch disk", filename);
+ PANIC ("%s: missing PUT signature on scratch disk", file_name);
size = ((int32_t *) buffer)[1];
if (size < 0)
- PANIC ("%s: invalid file size %d", filename, size);
+ PANIC ("%s: invalid file size %d", file_name, size);
/* Create destination file. */
- if (!filesys_create (filename, size))
- PANIC ("%s: create failed", filename);
- dst = filesys_open (filename);
+ if (!filesys_create (file_name, size))
+ PANIC ("%s: create failed", file_name);
+ dst = filesys_open (file_name);
if (dst == NULL)
- PANIC ("%s: open failed", filename);
+ PANIC ("%s: open failed", file_name);
/* Do copy. */
while (size > 0)
disk_read (src, sector++, buffer);
if (file_write (dst, buffer, chunk_size) != chunk_size)
PANIC ("%s: write failed with %"PROTd" bytes unwritten",
- filename, size);
+ file_name, size);
size -= chunk_size;
}
free (buffer);
}
-/* Copies file FILENAME from the file system to the scratch disk.
+/* Copies file FILE_NAME from the file system to the scratch disk.
The current sector on the scratch disk will receive "GET\0"
followed by the file's size in bytes as a 32-bit,
{
static disk_sector_t sector = 0;
- const char *filename = argv[1];
+ const char *file_name = argv[1];
void *buffer;
struct file *src;
struct disk *dst;
off_t size;
- printf ("Getting '%s' from the file system...\n", filename);
+ printf ("Getting '%s' from the file system...\n", file_name);
/* Allocate buffer. */
buffer = malloc (DISK_SECTOR_SIZE);
PANIC ("couldn't allocate buffer");
/* Open source file. */
- src = filesys_open (filename);
+ src = filesys_open (file_name);
if (src == NULL)
- PANIC ("%s: open failed", filename);
+ PANIC ("%s: open failed", file_name);
size = file_length (src);
/* Open target disk. */
{
int chunk_size = size > DISK_SECTOR_SIZE ? DISK_SECTOR_SIZE : size;
if (sector >= disk_size (dst))
- PANIC ("%s: out of space on scratch disk", filename);
+ PANIC ("%s: out of space on scratch disk", file_name);
if (file_read (src, buffer, chunk_size) != chunk_size)
- PANIC ("%s: read failed with %"PROTd" bytes unread", filename, size);
+ PANIC ("%s: read failed with %"PROTd" bytes unread", file_name, size);
memset (buffer + chunk_size, 0, DISK_SECTOR_SIZE - chunk_size);
disk_write (dst, sector++, buffer);
size -= chunk_size;