#define CHMOD 15
#define CHOWN 16
#define BRK 17
-#define LSEEK_321 19
#define MINIX_GETPID 20
#define MOUNT 21
#define UMOUNT 22
#define FSTAT 52
#define LSTAT 53
#define IOCTL 54
-#define FCNTL_321 55
#define FS_READY 57
#define PIPE2 58
#define EXEC 59
#define REBOOT 76
#define SVRCTL 77
#define SYSUNAME 78
-#define GETDENTS_321 80 /* to VFS */
#define LLSEEK 81 /* to VFS */
#define GETVFSSTAT 82 /* to VFS */
#define STATVFS1 83 /* to VFS */
#define GETTIMEOFDAY 90 /* to PM */
#define SETEUID 91 /* to PM */
#define SETEGID 92 /* to PM */
-#define TRUNCATE_321 93 /* to VFS */
-#define FTRUNCATE_321 94 /* to VFS */
#define FCHMOD 95 /* to VFS */
#define FCHOWN 96 /* to VFS */
#define LSEEK 97
#include "namespace.h"
#include <lib.h>
-#include <errno.h>
#include <fcntl.h>
#include <stdarg.h>
__weak_alias(fcntl, _fcntl)
#endif
-static int __fcntl_321(int fd, int cmd, va_list argp);
-
-int __fcntl_321(int fd, int cmd, va_list argp)
-{
- message m;
- struct flock_321 f_321;
- struct flock *flock;
- int r;
-
- /* Set up for the sensible case where there is no variable parameter. This
- * covers F_GETFD, F_GETFL and invalid commands.
- */
- m.m1_i3 = 0;
- m.m1_p1 = NULL;
-
- /* Adjust for the stupid cases. */
- switch(cmd) {
- case F_DUPFD:
- case F_SETFD:
- case F_SETFL:
- m.m1_i3 = va_arg(argp, int);
- break;
- case F_GETLK:
- case F_SETLK:
- case F_SETLKW:
- case F_FREESP:
- /* VFS expects old format, so translate */
- flock = (struct flock *) va_arg(argp, struct flock *);
- f_321.l_type = flock->l_type;
- f_321.l_whence = flock->l_whence;
- f_321.l_start = flock->l_start;
- f_321.l_len = flock->l_len;
- f_321.l_pid = flock->l_pid;
- m.m1_p1 = (char *) &f_321;
- break;
- }
-
- /* Clean up and make the system call. */
- m.m1_i1 = fd;
- m.m1_i2 = cmd;
-
- r = _syscall(VFS_PROC_NR, FCNTL_321, &m);
-
- if (r == 0) {
- /* Maybe we need to convert back */
-
- switch(cmd) {
- case F_GETLK:
- case F_SETLK:
- case F_SETLKW:
- case F_FREESP:
- /* VFS expected old format but libc new format, so translate */
- flock->l_type = f_321.l_type;
- flock->l_whence = f_321.l_whence;
- flock->l_start = f_321.l_start;
- flock->l_len = f_321.l_len;
- flock->l_pid = f_321.l_pid;
- break;
- }
- }
-
- return r;
-}
-
int fcntl(int fd, int cmd, ...)
{
- va_list argp, argp_321;
+ va_list argp;
message m;
- int r, org_errno;
va_start(argp, cmd);
- va_start(argp_321, cmd);
/* Set up for the sensible case where there is no variable parameter. This
* covers F_GETFD, F_GETFL and invalid commands.
va_end(argp);
m.m1_i1 = fd;
m.m1_i2 = cmd;
- org_errno = errno;
- r = _syscall(VFS_PROC_NR, FCNTL, &m);
-
- if (r == -1 && errno == ENOSYS) {
- errno = org_errno;
- r = __fcntl_321(fd, cmd, argp_321);
- }
-
- va_end(argp_321);
-
- return r;
+ return(_syscall(VFS_PROC_NR, FCNTL, &m));
}
#include <lib.h>
#include <minix/u64.h>
-#include <errno.h>
#include <string.h>
#include <unistd.h>
__weak_alias(ftruncate, _ftruncate)
#endif
-static int __ftruncate_321(int _fd, int _length);
-
-static int __ftruncate_321(int _fd, int _length)
-{
- message m;
- m.m2_l1 = _length;
- m.m2_i1 = _fd;
-
- return(_syscall(VFS_PROC_NR, FTRUNCATE_321, &m));
-}
-
int ftruncate(int _fd, off_t _length)
{
message m;
- int orig_errno, r;
m.m2_l1 = ex64lo(_length);
m.m2_l2 = ex64hi(_length);
m.m2_i1 = _fd;
- orig_errno = errno;
- r = _syscall(VFS_PROC_NR, FTRUNCATE, &m);
- if (r == -1 && errno == ENOSYS) {
- /* Old VFS, no support for new ftruncate */
- if (_length >= INT_MIN && _length <= INT_MAX) {
- errno = orig_errno;
- return __ftruncate_321(_fd, (int) _length);
- }
-
- /* Not going to fit */
- errno = EOVERFLOW;
- }
-
- return r;
+ return(_syscall(VFS_PROC_NR, FTRUNCATE, &m));
}
#include <lib.h>
#include <dirent.h>
-#include <errno.h>
-#include <stddef.h>
-#include <stdlib.h>
-#include <string.h>
-
-static ssize_t __getdents321(int fd, char *buffer, size_t nbytes);
ssize_t getdents(int fd, char *buffer, size_t nbytes)
{
message m;
- int r, orig_errno;
- orig_errno = errno;
m.m1_i1 = fd;
m.m1_i2 = nbytes;
m.m1_p1 = (char *) buffer;
- r = _syscall(VFS_PROC_NR, GETDENTS, &m);
- if (r == -1 && errno == ENOSYS) {
- errno = orig_errno;/* Restore old value so world is still as expected*/
- r = __getdents321(fd, buffer, nbytes);
- }
-
- return r;
-}
-
-ssize_t __getdents321(int fd, char *buffer, size_t nbytes)
-{
- message m;
- int r, consumed = 0, newconsumed = 0;
- char *intermediate = NULL;
- struct dirent *dent;
- struct dirent_321 *dent_321;
-#define DWORD_ALIGN(d) if((d) % sizeof(long)) (d)+=sizeof(long)-(d)%sizeof(long)
-
- intermediate = malloc(nbytes);
- if (intermediate == NULL) return EINVAL;
-
- m.m1_i1 = fd;
- /* Pretend the buffer is smaller so we know the converted/expanded version
- * will fit.
- */
- nbytes = nbytes / 2;
- if (nbytes < (sizeof(struct dirent) + NAME_MAX + 1)) {
- free(intermediate);
- return EINVAL; /* This might not fit. Sorry */
- }
-
- m.m1_i2 = nbytes;
- m.m1_p1 = (char *) intermediate;
- r = _syscall(VFS_PROC_NR, GETDENTS_321, &m);
-
- if (r <= 0) {
- free(intermediate);
- return r;
- }
-
- /* Provided format is struct dirent_321 and has to be translated to
- * struct dirent */
- dent_321 = (struct dirent_321 *) intermediate;
- dent = (struct dirent *) buffer;
-
- while (consumed < r && dent_321->d_reclen > 0) {
- dent->d_ino = (ino_t) dent_321->d_ino;
- dent->d_off = (off_t) dent_321->d_off;
- dent->d_reclen = offsetof(struct dirent, d_name) +
- strlen(dent_321->d_name) + 1;
- DWORD_ALIGN(dent->d_reclen);
- strcpy(dent->d_name, dent_321->d_name);
- consumed += dent_321->d_reclen;
- newconsumed += dent->d_reclen;
- dent_321 = (struct dirent_321 *) &intermediate[consumed];
- dent = (struct dirent *) &buffer[newconsumed];
- }
-
- free(intermediate);
-
- return newconsumed;
+ return _syscall(VFS_PROC_NR, GETDENTS, &m);
}
#if defined(__minix) && defined(__weak_alias)
#include <lib.h>
#include <minix/u64.h>
-#include <errno.h>
#include <unistd.h>
#ifdef __weak_alias
__weak_alias(lseek, _lseek)
#endif
-i32_t __lseek_321(int fd, i32_t offset, int whence);
-
-i32_t __lseek_321(int fd, i32_t offset, int whence)
-{
- message m;
-
- m.m2_i1 = fd;
- m.m2_l1 = offset;
- m.m2_i2 = whence;
- if (_syscall(VFS_PROC_NR, LSEEK_321, &m) < 0) return(-1);
- return( (i32_t) m.m2_l1);
-}
-
off_t
lseek(int fd, off_t offset, int whence)
{
message m;
- int orig_errno;
m.m2_i1 = fd;
m.m2_l1 = ex64lo(offset);
m.m2_l2 = ex64hi(offset);
m.m2_i2 = whence;
- orig_errno = errno;
- if (_syscall(VFS_PROC_NR, LSEEK, &m) < 0) {
- if (errno == ENOSYS) {
- /* Old VFS, no support for new lseek */
- if (offset >= INT_MIN && offset <= INT_MAX) {
- /* offset fits in old range, retry */
- errno = orig_errno;
- return (off_t) __lseek_321(fd, (i32_t) offset, whence);
- }
-
- /* Not going to fit */
- errno = EOVERFLOW;
- }
-
+ if (_syscall(VFS_PROC_NR, LSEEK, &m) < 0)
return( (off_t) -1);
- }
+
return( (off_t) make64(m.m2_l1, m.m2_l2));
}
#endif
#include <minix/u64.h>
-#include <errno.h>
#include <string.h>
#include <unistd.h>
-static int __truncate_321(const char *_path, int _length);
-
-static int __truncate_321(const char *_path, int _length)
-{
- message m;
- m.m2_p1 = (char *) __UNCONST(_path);
- m.m2_i1 = strlen(_path)+1;
- m.m2_l1 = _length;
-
- return(_syscall(VFS_PROC_NR, TRUNCATE_321, &m));
-}
-
int truncate(const char *_path, off_t _length)
{
message m;
- int orig_errno, r;
m.m2_p1 = (char *) __UNCONST(_path);
m.m2_i1 = strlen(_path)+1;
m.m2_l1 = ex64lo(_length);
m.m2_l2 = ex64hi(_length);
- orig_errno = errno;
- r = _syscall(VFS_PROC_NR, TRUNCATE, &m);
-
- if (r == -1 && errno == ENOSYS) {
- /* Old VFS, no support for new truncate */
- if (_length >= INT_MIN && _length <= INT_MAX) {
- errno = orig_errno;
- return __truncate_321(_path, (int) _length);
- }
-
- /* Not going to fit */
- errno = EOVERFLOW;
- }
-
- return r;
+ return(_syscall(VFS_PROC_NR, TRUNCATE, &m));
}
#include <string.h>
#include <minix/com.h>
#include <minix/callnr.h>
-#include <minix/config.h> /* Remove with version check in do_truncate */
#include <minix/vfsif.h>
#include <dirent.h>
#include <assert.h>
resolve.l_vmnt_lock = VMNT_READ;
resolve.l_vnode_lock = VNODE_WRITE;
- if (job_call_nr == TRUNCATE_321) {
- length = (off_t) job_m_in.m2_l1;
- if ((int) job_m_in.flength < 0) return(EINVAL);
- } else {
- length = (off_t) make64(job_m_in.m2_l1, job_m_in.m2_l2);
- if (length < 0) return(EINVAL);
- }
+ length = (off_t) make64(job_m_in.m2_l1, job_m_in.m2_l2);
+ if (length < 0) return(EINVAL);
/* Temporarily open file */
if (fetch_name(vname, vname_length, fullpath) != OK) return(err_code);
scratch(fp).file.fd_nr = job_m_in.fd;
- if (job_call_nr == FTRUNCATE_321) {
- length = (off_t) job_m_in.m2_l1;
- if ((int) job_m_in.flength < 0) return(EINVAL);
- } else {
- length = (off_t) make64(job_m_in.m2_l1, job_m_in.m2_l2);
- if (length < 0) return(EINVAL);
- }
-
+ length = (off_t) make64(job_m_in.m2_l1, job_m_in.m2_l2);
+ if (length < 0) return(EINVAL);
/* File is already opened; get a vnode pointer from filp */
if ((rfilp = get_filp(scratch(fp).file.fd_nr, VNODE_WRITE)) == NULL)
*/
#include "fs.h"
-#include <minix/callnr.h>
#include <minix/com.h>
#include <minix/u64.h>
#include <fcntl.h>
mode_t mo;
off_t first, last;
struct flock flock;
- struct flock_321 fa_321;
struct file_lock *flp, *flp2, *empty;
/* Fetch the flock structure from user space. */
- if (job_call_nr == FCNTL_321) {
- r = sys_datacopy(who_e, (vir_bytes) scratch(fp).io.io_buffer,
- VFS_PROC_NR, (vir_bytes) &fa_321, sizeof(fa_321));
-
- /* Convert old values to new structure */
- if (r == OK) {
- flock.l_type = fa_321.l_type;
- flock.l_whence = fa_321.l_whence;
- flock.l_start = (off_t) fa_321.l_start;
- flock.l_len = (off_t) fa_321.l_len;
- flock.l_pid = fa_321.l_pid;
- }
- } else {
- r = sys_datacopy(who_e, (vir_bytes) scratch(fp).io.io_buffer,
- VFS_PROC_NR, (vir_bytes) &flock, sizeof(flock));
- }
+ r = sys_datacopy(who_e, (vir_bytes) scratch(fp).io.io_buffer, VFS_PROC_NR,
+ (vir_bytes) &flock, sizeof(flock));
if (r != OK) return(EINVAL);
/* Make some error checks. */
}
/* Copy the flock structure back to the caller. */
- if (job_call_nr == FCNTL_321) {
- /* Convert new values to old structure */
- if (r == OK) {
- fa_321.l_type = flock.l_type;
- fa_321.l_whence = flock.l_whence;
- fa_321.l_start = (i32_t) flock.l_start;
- fa_321.l_len = (i32_t) flock.l_len;
- fa_321.l_pid = flock.l_pid;
- }
- r = sys_datacopy(VFS_PROC_NR, (vir_bytes) &fa_321,
- who_e, (vir_bytes) scratch(fp).io.io_buffer,
- sizeof(fa_321));
- } else {
- r = sys_datacopy(VFS_PROC_NR, (vir_bytes) &flock,
- who_e, (vir_bytes) scratch(fp).io.io_buffer,
- sizeof(flock));
- }
+ r = sys_datacopy(VFS_PROC_NR, (vir_bytes) &flock, who_e,
+ (vir_bytes) scratch(fp).io.io_buffer, sizeof(flock));
return(r);
}
else if (!(f->filp_mode & W_BIT)) r = EBADF;
else {
/* Copy flock data from userspace. */
- if (job_call_nr == FCNTL_321) {
- struct flock_321 fa_321;
- r = sys_datacopy(who_e,
- (vir_bytes) scratch(fp).io.io_buffer, SELF,
- (vir_bytes) &fa_321, sizeof(fa_321));
- /* Let's convert the values to the new structure */
- if (r == OK) {
- flock_arg.l_type = fa_321.l_type;
- flock_arg.l_whence = fa_321.l_whence;
- flock_arg.l_start = (off_t) fa_321.l_start;
- flock_arg.l_len = (off_t) fa_321.l_len;
- flock_arg.l_pid = fa_321.l_pid;
- }
- } else {
- r = sys_datacopy(who_e,
- (vir_bytes) scratch(fp).io.io_buffer, SELF,
- (vir_bytes) &flock_arg, sizeof(flock_arg));
- }
+ r = sys_datacopy(who_e, (vir_bytes) scratch(fp).io.io_buffer,
+ SELF, (vir_bytes) &flock_arg, sizeof(flock_arg));
}
if (r != OK) break;
* do_mkdir: perform the MKDIR system call
* do_close: perform the CLOSE system call
* do_lseek: perform the LSEEK system call
- * do_llseek: perform the LLSEEK system call
*/
#include "fs.h"
return(r);
}
-/*===========================================================================*
- * do_lseek_321 *
- *===========================================================================*/
-int do_lseek_321(message *m_out)
-{
- int r;
-
- r = actual_llseek(fp, m_out, job_m_in.ls_fd, job_m_in.whence,
- make64(job_m_in.offset_lo, 0));
-
- /* check value is 32bit */
- if (m_out->reply_l2 != 0) {
- r = EOVERFLOW;
- }
-
- return r;
-}
-
/*===========================================================================*
* do_lseek *
*===========================================================================*/
make64(job_m_in.offset_lo, job_m_in.offset_high));
}
-/*===========================================================================*
- * do_llseek *
- *===========================================================================*/
-int do_llseek(message *m_out)
-{
- return actual_llseek(fp, m_out, job_m_in.ls_fd, job_m_in.whence,
- make64(job_m_in.offset_lo, job_m_in.offset_high));
-}
-
/*===========================================================================*
* do_close *
*===========================================================================*/
int common_open(char path[PATH_MAX], int oflags, mode_t omode);
int do_creat(void);
int do_lseek(message *m_out);
-int do_lseek_321(message *m_out);
-int do_llseek(message *m_out);
int do_mknod(message *m_out);
int do_mkdir(message *m_out);
int do_open(message *m_out);
int do_slink(message *m_out);
-int actual_lseek(message *m_out, int seekfd, int seekwhence, off_t offset);
int actual_llseek(struct fproc *rfp, message *m_out, int seekfd,
int seekwhence, off_t offset);
int do_vm_open(void);
do_chown, /* 16 = chown */
no_sys, /* 17 = break */
no_sys, /* 18 = unused (was old stat)*/
- no_sys, /* 19 = unused (was lseek_321)*/
+ no_sys, /* 19 = unused */
no_sys, /* 20 = getpid */
do_mount, /* 21 = mount */
do_umount, /* 22 = umount */
do_svrctl, /* 77 = svrctl */
no_sys, /* 78 = (sysuname) */
no_sys, /* 79 = unused */
- do_getdents, /* 80 = getdents_321 (to be phased out) */
+ no_sys, /* 80 = unused */
do_lseek, /* 81 = llseek */
do_getvfsstat, /* 82 = getvfsstat */
do_statvfs, /* 83 = fstatvfs */
no_sys, /* 90 = (gettimeofday) */
no_sys, /* 91 = (seteuid) */
no_sys, /* 92 = (setegid) */
- do_truncate, /* 93 = truncate_321 (to be phased out) */
- do_ftruncate, /* 94 = ftruncate_321 (to be phased out) */
+ no_sys, /* 93 = unused */
+ no_sys, /* 94 = unused */
do_chmod, /* 95 = fchmod */
do_chown, /* 96 = fchown */
do_lseek, /* 97 = lseek */
char d_name[1]; /* Null terminated name */
};
-struct dirent_321 { /* Largest entry (8 slots) */
- u32_t d_ino; /* I-node number */
- i32_t d_off; /* Offset in directory */
- unsigned short d_reclen; /* Length of this record */
- char d_name[1]; /* Null terminated name */
-};
-
#if defined(_NETBSD_SOURCE)
#define MAXNAMLEN 511
#define d_fileno d_ino
pid_t l_pid; /* process id of the locks' owner */
};
-struct flock_321 {
- short l_type; /* type: F_RDLCK, F_WRLCK, or F_UNLCK */
- short l_whence; /* flag for starting offset */
- i32_t l_start; /* relative offset in bytes */
- i32_t l_len; /* size; if 0, then until EOF */
- pid_t l_pid; /* process id of the locks' owner */
-};
-
#if defined(_NETBSD_SOURCE)
/* lock operations for flock(2) */
#define LOCK_SH F_RDLCK /* Shared lock */