Added fchdir() system call, with corresponding manpage, Changelog and

system include modifications.
This commit is contained in:
Ben Gras
2005-06-29 19:28:26 +00:00
parent 62f7f9e6d2
commit af27dc0cf7
8 changed files with 47 additions and 5 deletions

View File

@@ -142,6 +142,7 @@ _PROTOTYPE( zone_t rd_indir, (struct buf *bp, int index) );
/* stadir.c */
_PROTOTYPE( int do_chdir, (void) );
_PROTOTYPE( int do_fchdir, (void) );
_PROTOTYPE( int do_chroot, (void) );
_PROTOTYPE( int do_fstat, (void) );
_PROTOTYPE( int do_stat, (void) );

View File

@@ -20,9 +20,24 @@
#include "super.h"
FORWARD _PROTOTYPE( int change, (struct inode **iip, char *name_ptr, int len));
FORWARD _PROTOTYPE( int change_into, (struct inode **iip, struct inode *ip));
FORWARD _PROTOTYPE( int stat_inode, (struct inode *rip, struct filp *fil_ptr,
char *user_addr) );
/*===========================================================================*
* do_fchdir *
*===========================================================================*/
PUBLIC int do_fchdir()
{
/* Change directory on already-opened fd. */
struct filp *rfilp;
/* Is the file descriptor valid? */
if ( (rfilp = get_filp(m_in.fd)) == NIL_FILP) return(err_code);
return change_into(&fp->fp_workdir, rfilp->filp_ino);
}
/*===========================================================================*
* do_chdir *
*===========================================================================*/
@@ -86,13 +101,22 @@ char *name_ptr; /* pointer to the directory name to change to */
int len; /* length of the directory name string */
{
/* Do the actual work for chdir() and chroot(). */
struct inode *rip;
register int r;
/* Try to open the new directory. */
if (fetch_name(name_ptr, len, M3) != OK) return(err_code);
if ( (rip = eat_path(user_path)) == NIL_INODE) return(err_code);
return change_into(iip, rip);
}
/*===========================================================================*
* change_into *
*===========================================================================*/
PRIVATE int change_into(iip, rip)
struct inode **iip; /* pointer to the inode pointer for the dir */
struct inode *rip; /* this is what the inode has to become */
{
register int r;
/* It must be a directory and also be searchable. */
if ( (rip->i_mode & I_TYPE) != I_DIRECTORY)
@@ -112,7 +136,6 @@ int len; /* length of the directory name string */
return(OK);
}
/*===========================================================================*
* do_stat *
*===========================================================================*/

View File

@@ -103,6 +103,7 @@ PUBLIC _PROTOTYPE (int (*call_vec[]), (void) ) = {
no_sys, /* 83 = memalloc */
no_sys, /* 84 = memfree */
do_select, /* 85 = select */
do_fchdir, /* 86 = fchdir */
};
/* This should not fail with "array size is negative": */
extern int dummy[sizeof(call_vec) == NCALLS * sizeof(call_vec[0]) ? 1 : -1];

View File

@@ -102,6 +102,7 @@ _PROTOTYPE (int (*call_vec[NCALLS]), (void) ) = {
do_allocmem, /* 83 = memalloc */
do_freemem, /* 84 = memfree */
no_sys, /* 85 = select */
no_sys, /* 86 = fchdir */
};
/* This should not fail with "array size is negative": */
extern int dummy[sizeof(call_vec) == NCALLS * sizeof(call_vec[0]) ? 1 : -1];