10static bool getcwd (
char *cwd,
size_t cwd_size);
16 if (
getcwd (cwd,
sizeof cwd))
53 char *dst,
size_t *dst_len,
size_t dst_size)
55 size_t prefix_len =
strlen (prefix);
56 if (prefix_len + *dst_len + 1 <= dst_size)
58 *dst_len += prefix_len;
59 memcpy ((dst + dst_size) - *dst_len, prefix, prefix_len);
93 int parent_inum, parent_fd;
110 parent_inum =
inumber (parent_fd);
111 if (parent_inum == child_inum)
124 if (test_inum == child_inum)
130 if (!
prepend (namep - 1, cwd, &cwd_len, cwd_size))
134 child_inum = parent_inum;
142 memmove (cwd, (cwd + cwd_size) - cwd_len, cwd_len);
int printf(const char *format,...)
Writes formatted output to the console.
bool readdir(int fd, char name[READDIR_MAX_LEN+1])
int open(const char *file)
int inumber(int fd)
lib/user/syscall.h
#define EXIT_SUCCESS
Typical return values from main() and arguments to exit().
#define EXIT_FAILURE
Unsuccessful execution.
#define READDIR_MAX_LEN
Maximum characters in a filename written by readdir().
static bool getcwd(char *cwd, size_t cwd_size)
pwd.c
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...
static bool get_inumber(const char *file_name, int *inum)
Stores the inode number for FILE_NAME in *INUM.
size_t strlen(const char *string)
Returns the length of STRING.
size_t strlcpy(char *dst, const char *src, size_t size)
Copies string SRC to DST.
void * memmove(void *dst_, const void *src_, size_t size)
Copies SIZE bytes from SRC to DST, which are allowed to overlap.
void * memcpy(void *dst_, const void *src_, size_t size)
Copies SIZE bytes from SRC to DST, which must not overlap.
static const char file_name[]
tests/filesys/base/syn-read.h