PKUOS - Pintos
Pintos source browser for PKU Operating System course
Functions
fsutil.c File Reference
#include "filesys/fsutil.h"
#include <debug.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ustar.h>
#include "filesys/directory.h"
#include "filesys/file.h"
#include "filesys/filesys.h"
#include "threads/malloc.h"
#include "threads/palloc.h"
#include "threads/vaddr.h"
Include dependency graph for fsutil.c:

Go to the source code of this file.

Functions

void fsutil_ls (char **argv UNUSED)
 List files in the root directory. More...
 
void fsutil_cat (char **argv)
 Prints the contents of file ARGV[1] to the system console as hex and ASCII. More...
 
void fsutil_rm (char **argv)
 Deletes file ARGV[1]. More...
 
void fsutil_extract (char **argv UNUSED)
 Extracts a ustar-format tar archive from the scratch block device into the Pintos file system. More...
 
void fsutil_append (char **argv)
 Copies file FILE_NAME from the file system to the scratch device, in ustar format. More...
 

Function Documentation

◆ fsutil_append()

void fsutil_append ( char **  argv)

Copies file FILE_NAME from the file system to the scratch device, in ustar format.

filesys/fsutil.h

The first call to this function will write starting at the beginning of the scratch device. Later calls advance across the device. This position is independent of that used for fsutil_extract(), so ‘extract’ should precede all `append's.

Definition at line 167 of file fsutil.c.

References block_get_role(), BLOCK_SCRATCH, BLOCK_SECTOR_SIZE, block_size(), block_write(), buffer, file_close(), file_length(), file_name, file_read(), filesys_open(), free(), malloc(), memset(), NULL, PANIC, printf(), PROTd, block::size, ustar_make_header(), and USTAR_REGULAR.

Referenced by run_actions().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fsutil_cat()

void fsutil_cat ( char **  argv)

Prints the contents of file ARGV[1] to the system console as hex and ASCII.

Definition at line 34 of file fsutil.c.

References buffer, file_close(), file_name, file_read(), file_tell(), filesys_open(), hex_dump(), NULL, PAL_ASSERT, palloc_free_page(), palloc_get_page(), PANIC, PGSIZE, file::pos, and printf().

Referenced by run_actions().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fsutil_extract()

void fsutil_extract ( char **argv  UNUSED)

Extracts a ustar-format tar archive from the scratch block device into the Pintos file system.

Definition at line 73 of file fsutil.c.

References block_get_role(), block_read(), BLOCK_SCRATCH, BLOCK_SECTOR_SIZE, block_write(), file_close(), file_name, file_write(), filesys_create(), filesys_open(), free(), malloc(), memset(), NULL, PANIC, PRDSNu, printf(), block::size, block::type, USTAR_DIRECTORY, USTAR_EOF, ustar_parse_header(), and USTAR_REGULAR.

Referenced by run_actions().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fsutil_ls()

void fsutil_ls ( char **argv  UNUSED)

List files in the root directory.

Definition at line 16 of file fsutil.c.

References dir_close(), dir_open_root(), dir_readdir(), name, NAME_MAX, NULL, PANIC, and printf().

Referenced by run_actions().

Here is the call graph for this function:
Here is the caller graph for this function:

◆ fsutil_rm()

void fsutil_rm ( char **  argv)

Deletes file ARGV[1].

Definition at line 61 of file fsutil.c.

References file_name, filesys_remove(), PANIC, and printf().

Referenced by run_actions().

Here is the call graph for this function:
Here is the caller graph for this function: