CS318 - Pintos
Pintos source browser for JHU CS318 course
Functions
tar.c File Reference
#include <ustar.h>
#include <syscall.h>
#include <stdio.h>
#include <string.h>
Include dependency graph for tar.c:

Go to the source code of this file.

Functions

static void usage (void)
 tar.c More...
 
static bool make_tar_archive (const char *archive_name, char *files[], size_t file_cnt)
 
int main (int argc, char *argv[])
 
static bool archive_file (char file_name[], size_t file_name_size, int archive_fd, bool *write_error)
 
static bool archive_ordinary_file (const char *file_name, int file_fd, int archive_fd, bool *write_error)
 
static bool archive_directory (char file_name[], size_t file_name_size, int file_fd, int archive_fd, bool *write_error)
 
static bool write_header (const char *file_name, enum ustar_type, int size, int archive_fd, bool *write_error)
 
static bool do_write (int fd, const char *buffer, int size, bool *write_error)
 

Function Documentation

◆ archive_directory()

static bool archive_directory ( char  file_name[],
size_t  file_name_size,
int  file_fd,
int  archive_fd,
bool write_error 
)
static

Definition at line 160 of file tar.c.

References archive_file(), file_name, printf(), readdir(), READDIR_MAX_LEN, strlen(), USTAR_DIRECTORY, and write_header().

Referenced by archive_file().

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

◆ archive_file()

static bool archive_file ( char  file_name[],
size_t  file_name_size,
int  archive_fd,
bool write_error 
)
static

Definition at line 89 of file tar.c.

References archive_directory(), archive_ordinary_file(), close(), file_name, inumber(), isdir(), open(), and printf().

Referenced by archive_directory(), and make_tar_archive().

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

◆ archive_ordinary_file()

static bool archive_ordinary_file ( const char *  file_name,
int  file_fd,
int  archive_fd,
bool write_error 
)
static

Definition at line 124 of file tar.c.

References buf, do_write(), file_name, filesize(), memset(), printf(), read(), USTAR_REGULAR, and write_header().

Referenced by archive_file().

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

◆ do_write()

static bool do_write ( int  fd,
const char *  buffer,
int  size,
bool write_error 
)
static

Definition at line 195 of file tar.c.

References buffer, printf(), and write().

Referenced by archive_ordinary_file(), make_tar_archive(), and write_header().

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

◆ main()

int main ( int argc   ,
char *  argv[] 
)

Definition at line 15 of file tar.c.

References EXIT_FAILURE, EXIT_SUCCESS, make_tar_archive(), and usage().

Here is the call graph for this function:

◆ make_tar_archive()

static bool make_tar_archive ( const char *  archive_name,
char *  files[],
size_t  file_cnt 
)
static

Definition at line 49 of file tar.c.

References archive_file(), close(), create(), do_write(), file_name, open(), printf(), and strlcpy().

Referenced by main().

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

◆ usage()

static void usage ( void  )
static

tar.c

Creates a tar archive.

Definition at line 25 of file tar.c.

References exit(), EXIT_FAILURE, and printf().

Referenced by main().

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

◆ write_header()

static bool write_header ( const char *  file_name,
enum ustar_type  type,
int  size,
int  archive_fd,
bool write_error 
)
static

Definition at line 186 of file tar.c.

References do_write(), file_name, and ustar_make_header().

Referenced by archive_directory(), and archive_ordinary_file().

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