-#define NCALLS 95 /* number of system calls allowed */
+#define NCALLS 97 /* number of system calls allowed */
#define EXIT 1
#define FORK 2
#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 */
/* 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) );
_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) );
_execv.c \
_execve.c \
_execvp.c \
+ _fchmod.c \
+ _fchown.c \
_fcntl.c \
_fork.c \
_fpathconf.c \
--- /dev/null
+#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));
+}
--- /dev/null
+#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));
+}
execv.s \
execve.s \
execvp.s \
+ fchown.s \
+ fchmod.s \
fcntl.s \
fork.s \
fpathconf.s \
--- /dev/null
+.sect .text
+.extern __fchmod
+.define _fchmod
+.align 2
+
+_fchmod:
+ jmp __fchmod
--- /dev/null
+.sect .text
+.extern __fchown
+.define _fchown
+.align 2
+
+_fchown:
+ jmp __fchown
.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
.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
.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.
* 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
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.
/* If error, return inode. */
if (r != OK) {
- put_inode(rip);
+ if(call_nr == CHMOD) put_inode(rip);
return(r);
}
rip->i_update |= CTIME;
rip->i_dirt = DIRTY;
- put_inode(rip);
+ if(call_nr == CHMOD) put_inode(rip);
return(OK);
}
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);
rip->i_dirt = DIRTY;
}
- put_inode(rip);
+ if(call_nr == CHOWN) put_inode(rip);
return(r);
}
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];
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];