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

@ -1,4 +1,4 @@
#define NCALLS 86 /* number of system calls allowed */
#define NCALLS 87 /* number of system calls allowed */
#define EXIT 1
#define FORK 2
@ -74,3 +74,4 @@
#define ALLOCMEM 83 /* to PM */
#define FREEMEM 84 /* to PM */
#define SELECT 85 /* to FS */
#define FCHDIR 86 /* to FS */

View file

@ -85,6 +85,7 @@ _PROTOTYPE( void _exit, (int _status) );
_PROTOTYPE( int access, (const char *_path, int _amode) );
_PROTOTYPE( unsigned int alarm, (unsigned int _seconds) );
_PROTOTYPE( int chdir, (const char *_path) );
_PROTOTYPE( int fchdir, (int fd) );
_PROTOTYPE( int chown, (const char *_path, _mnx_Uid_t _owner, _mnx_Gid_t _group) );
_PROTOTYPE( int close, (int _fd) );
_PROTOTYPE( char *ctermid, (char *_s) );

View file

@ -10,3 +10,13 @@ _CONST char *name;
_loadname(name, &m);
return(_syscall(FS, CHDIR, &m));
}
PUBLIC int fchdir(fd)
int fd;
{
message m;
m.m1_i1 = fd;
return(_syscall(FS, FCHDIR, &m));
}

View file

@ -7,18 +7,22 @@
.TH CHDIR 2 "August 26, 1985"
.UC 4
.SH NAME
chdir \- change current working directory
chdir, fchdir \- change current working directory
.SH SYNOPSIS
.nf
.ft B
#include <unistd.h>
int chdir(const char *\fIpath\fP)
int fchdir(int \fIfd\fP)
.ft R
.fi
.SH DESCRIPTION
.I Path
is the pathname of a directory.
.I Fd
is the file descriptor of a directory.
.B Chdir
causes this directory
to become the current working directory,

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];