Added fchmod() and fchown()
This commit is contained in:
parent
b1e5779b1c
commit
461a4fafb1
|
@ -1,4 +1,4 @@
|
|||
#define NCALLS 95 /* number of system calls allowed */
|
||||
#define NCALLS 97 /* number of system calls allowed */
|
||||
|
||||
#define EXIT 1
|
||||
#define FORK 2
|
||||
|
@ -86,3 +86,5 @@
|
|||
#define SETEGID 92 /* to PM */
|
||||
#define TRUNCATE 93 /* to FS */
|
||||
#define FTRUNCATE 94 /* to FS */
|
||||
#define FCHMOD 95 /* to FS */
|
||||
#define FCHOWN 96 /* to FS */
|
||||
|
|
|
@ -68,6 +68,7 @@ struct stat {
|
|||
|
||||
/* Function Prototypes. */
|
||||
_PROTOTYPE( int chmod, (const char *_path, _mnx_Mode_t _mode) );
|
||||
_PROTOTYPE( int fchmod, (int fd, _mnx_Mode_t _mode) );
|
||||
_PROTOTYPE( int fstat, (int _fildes, struct stat *_buf) );
|
||||
_PROTOTYPE( int mkdir, (const char *_path, _mnx_Mode_t _mode) );
|
||||
_PROTOTYPE( int mkfifo, (const char *_path, _mnx_Mode_t _mode) );
|
||||
|
|
|
@ -96,6 +96,7 @@ _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 fchown, (int fd, _mnx_Uid_t _owner, _mnx_Gid_t _group) );
|
||||
_PROTOTYPE( int close, (int _fd) );
|
||||
_PROTOTYPE( char *ctermid, (char *_s) );
|
||||
_PROTOTYPE( char *cuserid, (char *_s) );
|
||||
|
|
|
@ -27,6 +27,8 @@ libc_FILES=" \
|
|||
_execv.c \
|
||||
_execve.c \
|
||||
_execvp.c \
|
||||
_fchmod.c \
|
||||
_fchown.c \
|
||||
_fcntl.c \
|
||||
_fork.c \
|
||||
_fpathconf.c \
|
||||
|
|
14
lib/posix/_fchmod.c
Executable file
14
lib/posix/_fchmod.c
Executable file
|
@ -0,0 +1,14 @@
|
|||
#include <lib.h>
|
||||
#define fchmod _fchmod
|
||||
#include <sys/stat.h>
|
||||
|
||||
PUBLIC int fchmod(fd, mode)
|
||||
int fd;
|
||||
_mnx_Mode_t mode;
|
||||
{
|
||||
message m;
|
||||
|
||||
m.m3_i1 = fd;
|
||||
m.m3_i2 = mode;
|
||||
return(_syscall(FS, FCHMOD, &m));
|
||||
}
|
17
lib/posix/_fchown.c
Executable file
17
lib/posix/_fchown.c
Executable file
|
@ -0,0 +1,17 @@
|
|||
#include <lib.h>
|
||||
#define fchown _fchown
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
PUBLIC int fchown(fd, owner, grp)
|
||||
int fd;
|
||||
_mnx_Uid_t owner;
|
||||
_mnx_Gid_t grp;
|
||||
{
|
||||
message m;
|
||||
|
||||
m.m1_i1 = fd;
|
||||
m.m1_i2 = owner;
|
||||
m.m1_i3 = grp;
|
||||
return(_syscall(FS, FCHOWN, &m));
|
||||
}
|
|
@ -29,6 +29,8 @@ libc_FILES=" \
|
|||
execv.s \
|
||||
execve.s \
|
||||
execvp.s \
|
||||
fchown.s \
|
||||
fchmod.s \
|
||||
fcntl.s \
|
||||
fork.s \
|
||||
fpathconf.s \
|
||||
|
|
7
lib/syscall/fchmod.s
Executable file
7
lib/syscall/fchmod.s
Executable file
|
@ -0,0 +1,7 @@
|
|||
.sect .text
|
||||
.extern __fchmod
|
||||
.define _fchmod
|
||||
.align 2
|
||||
|
||||
_fchmod:
|
||||
jmp __fchmod
|
7
lib/syscall/fchown.s
Executable file
7
lib/syscall/fchown.s
Executable file
|
@ -0,0 +1,7 @@
|
|||
.sect .text
|
||||
.extern __fchown
|
||||
.define _fchown
|
||||
.align 2
|
||||
|
||||
_fchown:
|
||||
jmp __fchown
|
|
@ -7,7 +7,7 @@
|
|||
.TH CHMOD 2 "May 13, 1986"
|
||||
.UC 4
|
||||
.SH NAME
|
||||
chmod \- change mode of file
|
||||
chmod, fchmod \- change mode of file
|
||||
.SH SYNOPSIS
|
||||
.nf
|
||||
.ft B
|
||||
|
|
|
@ -7,7 +7,7 @@
|
|||
.TH CHOWN 2 "May 22, 1986"
|
||||
.UC 4
|
||||
.SH NAME
|
||||
chown \- change owner and group of a file
|
||||
chown, fchown \- change owner and group of a file
|
||||
.SH SYNOPSIS
|
||||
.nf
|
||||
.ft B
|
||||
|
@ -64,7 +64,6 @@ Search permission is denied for a component of the path prefix.
|
|||
.TP 15
|
||||
[ELOOP]
|
||||
Too many symbolic links were encountered in translating the pathname.
|
||||
(Minix-vmd)
|
||||
.TP 15
|
||||
[EPERM]
|
||||
The effective user ID is not the super-user.
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
* for four system calls that relate to protection.
|
||||
*
|
||||
* The entry points into this file are
|
||||
* do_chmod: perform the CHMOD system call
|
||||
* do_chown: perform the CHOWN system call
|
||||
* do_chmod: perform the CHMOD and FCHMOD system calls
|
||||
* do_chown: perform the CHOWN and FCHOWN system calls
|
||||
* do_umask: perform the UMASK system call
|
||||
* do_access: perform the ACCESS system call
|
||||
* forbidden: check to see if a given access is allowed on a given inode
|
||||
|
@ -29,9 +29,15 @@ PUBLIC int do_chmod()
|
|||
register struct inode *rip;
|
||||
register int r;
|
||||
|
||||
/* Temporarily open the file. */
|
||||
if (fetch_name(m_in.name, m_in.name_length, M3) != OK) return(err_code);
|
||||
if ( (rip = eat_path(user_path)) == NIL_INODE) return(err_code);
|
||||
if(call_nr == CHMOD) {
|
||||
/* Temporarily open the file. */
|
||||
if (fetch_name(m_in.name, m_in.name_length, M3) != OK) return(err_code);
|
||||
if ( (rip = eat_path(user_path)) == NIL_INODE) return(err_code);
|
||||
} else if(call_nr == FCHMOD) {
|
||||
struct filp *filp;
|
||||
if(!(filp = get_filp(m_in.m3_i1))) return(err_code);
|
||||
rip = filp->filp_ino;
|
||||
} else panic(__FILE__, "do_chmod called with strange call_nr", call_nr);
|
||||
|
||||
/* Only the owner or the super_user may change the mode of a file.
|
||||
* No one may change the mode of a file on a read-only file system.
|
||||
|
@ -43,7 +49,7 @@ PUBLIC int do_chmod()
|
|||
|
||||
/* If error, return inode. */
|
||||
if (r != OK) {
|
||||
put_inode(rip);
|
||||
if(call_nr == CHMOD) put_inode(rip);
|
||||
return(r);
|
||||
}
|
||||
|
||||
|
@ -53,7 +59,7 @@ PUBLIC int do_chmod()
|
|||
rip->i_update |= CTIME;
|
||||
rip->i_dirt = DIRTY;
|
||||
|
||||
put_inode(rip);
|
||||
if(call_nr == CHMOD) put_inode(rip);
|
||||
return(OK);
|
||||
}
|
||||
|
||||
|
@ -67,9 +73,15 @@ PUBLIC int do_chown()
|
|||
register struct inode *rip;
|
||||
register int r;
|
||||
|
||||
/* Temporarily open the file. */
|
||||
if (fetch_name(m_in.name1, m_in.name1_length, M1) != OK) return(err_code);
|
||||
if ( (rip = eat_path(user_path)) == NIL_INODE) return(err_code);
|
||||
if(call_nr == CHOWN) {
|
||||
/* Temporarily open the file. */
|
||||
if (fetch_name(m_in.name1, m_in.name1_length, M1) != OK) return(err_code);
|
||||
if ( (rip = eat_path(user_path)) == NIL_INODE) return(err_code);
|
||||
} else if(call_nr == FCHOWN) {
|
||||
struct filp *filp;
|
||||
if(!(filp = get_filp(m_in.m1_i1))) return(err_code);
|
||||
rip = filp->filp_ino;
|
||||
} else panic(__FILE__, "do_chown called with strange call_nr", call_nr);
|
||||
|
||||
/* Not permitted to change the owner of a file on a read-only file sys. */
|
||||
r = read_only(rip);
|
||||
|
@ -92,7 +104,7 @@ PUBLIC int do_chown()
|
|||
rip->i_dirt = DIRTY;
|
||||
}
|
||||
|
||||
put_inode(rip);
|
||||
if(call_nr == CHOWN) put_inode(rip);
|
||||
return(r);
|
||||
}
|
||||
|
||||
|
|
|
@ -112,6 +112,8 @@ PUBLIC _PROTOTYPE (int (*call_vec[]), (void) ) = {
|
|||
no_sys, /* 92 = setegid */
|
||||
do_truncate, /* 93 = truncate */
|
||||
do_ftruncate, /* 94 = truncate */
|
||||
do_chmod, /* 95 = fchmod */
|
||||
do_chown, /* 96 = fchown */
|
||||
};
|
||||
/* This should not fail with "array size is negative": */
|
||||
extern int dummy[sizeof(call_vec) == NCALLS * sizeof(call_vec[0]) ? 1 : -1];
|
||||
|
|
|
@ -110,6 +110,8 @@ _PROTOTYPE (int (*call_vec[NCALLS]), (void) ) = {
|
|||
do_getset, /* 92 = setegid */
|
||||
no_sys, /* 93 = truncate */
|
||||
no_sys, /* 94 = ftruncate */
|
||||
no_sys, /* 95 = fchmod */
|
||||
no_sys, /* 96 = fchown */
|
||||
};
|
||||
/* This should not fail with "array size is negative": */
|
||||
extern int dummy[sizeof(call_vec) == NCALLS * sizeof(call_vec[0]) ? 1 : -1];
|
||||
|
|
Loading…
Reference in a new issue