fcntl - Generic interface to vfs#include Get...

Info iconThis preview shows pages 1–2. Sign up to view the full content.

View Full Document Right Arrow Icon
* Generic interface to vfs. */ #include <fcntl.h> /* * Get Current working directory. This can't be tested from kernel space. */ int getcwd(char *buf, size_t buflen) { int err = 0; // Construct uio to get the data from vfs_getcwd struct uio uio_cwd; uio_cwd.uio_iovec.iov_ubase = (userptr_t)buf; uio_cwd.uio_iovec.iov_len = PATH_MAX; uio_cwd.uio_rw = UIO_READ; uio_cwd.uio_offset = 0; uio_cwd.uio_resid = buflen; uio_cwd.uio_segflg = UIO_SYSSPACE; uio_cwd.uio_space = NULL; // Invoke vfs_getcwd err = vfs_getcwd(&uio_cwd); if(err) return err; if(err) return err; return err; } int chdir(const char *pathname) { return vfs_chdir((char *)pathname); } /* This is what actually does the open part of the system */ int open(char *path, int flags, int *fd) { struct fd *newfd; int ret, err, fd_index = -1; /* Okay, what about ENFILE ? */ ret = EMFILE; //kprintf("Open: We are in Open and we're opening: %s\n", path); /* Allocate new file descriptor */ err = thread_fd_allocate(curthread, &fd_index); if(err)
Background image of page 1

Info iconThis preview has intentionally blurred sections. Sign up to view the full version.

View Full DocumentRight Arrow Icon
Image of page 2
This is the end of the preview. Sign up to access the rest of the document.

This note was uploaded on 11/10/2009 for the course CS 536 taught by Professor Lums during the Spring '09 term at Indiana.

Page1 / 3

fcntl - Generic interface to vfs#include Get...

This preview shows document pages 1 - 2. Sign up to view the full document.

View Full Document Right Arrow Icon
Ask a homework question - tutors are online