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

Go to the source code of this file.

Macros

#define MAX_LEVEL   20
 

Functions

static bool getcwd (char *cwd, size_t cwd_size)
 pwd.c More...
 
int main (void)
 
static bool get_inumber (const char *file_name, int *inum)
 Stores the inode number for FILE_NAME in *INUM. More...
 
static bool prepend (const char *prefix, char *dst, size_t *dst_len, size_t dst_size)
 Prepends PREFIX to the characters stored in the final *DST_LEN bytes of the DST_SIZE-byte buffer that starts at DST. More...
 

Macro Definition Documentation

◆ MAX_LEVEL

#define MAX_LEVEL   20

Function Documentation

◆ get_inumber()

static bool get_inumber ( const char *  file_name,
int *  inum 
)
static

Stores the inode number for FILE_NAME in *INUM.

Returns true if successful, false if the file could not be opened.

Definition at line 32 of file pwd.c.

References close(), file_name, inumber(), and open().

Referenced by getcwd().

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

◆ getcwd()

static bool getcwd ( char *  cwd,
size_t  cwd_size 
)
static

pwd.c

Stores the current working directory, as a null-terminated string, in the CWD_SIZE bytes in CWD.

Prints the absolute name of the present working directory.

Returns true if successful, false on error. Errors include system errors, directory trees deeper than MAX_LEVEL levels, and insufficient space in CWD.

Definition at line 72 of file pwd.c.

References close(), get_inumber(), inumber(), MAX_LEVEL, memmove(), name, open(), prepend(), readdir(), READDIR_MAX_LEN, and strlcpy().

Referenced by main().

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

◆ main()

int main ( void  )

Definition at line 13 of file pwd.c.

References EXIT_FAILURE, EXIT_SUCCESS, getcwd(), and printf().

Here is the call graph for this function:

◆ prepend()

static bool prepend ( const char *  prefix,
char *  dst,
size_t dst_len,
size_t  dst_size 
)
static

Prepends PREFIX to the characters stored in the final *DST_LEN bytes of the DST_SIZE-byte buffer that starts at DST.

Returns true if successful, false if adding that many characters, plus a null terminator, would overflow the buffer. (No null terminator is actually added or depended upon, but its space is accounted for.)

Definition at line 52 of file pwd.c.

References memcpy(), and strlen().

Referenced by getcwd().

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