Remove support for obsolete 3.2.1 ABI
Change-Id: I76b4960bda41f55d9c42f8c99c5beae3424ca851
This commit is contained in:
@@ -2,7 +2,6 @@
|
||||
#include "namespace.h"
|
||||
#include <lib.h>
|
||||
|
||||
#include <errno.h>
|
||||
#include <fcntl.h>
|
||||
#include <stdarg.h>
|
||||
|
||||
@@ -10,78 +9,12 @@
|
||||
__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.
|
||||
@@ -108,15 +41,5 @@ int fcntl(int fd, int cmd, ...)
|
||||
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));
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
#include <lib.h>
|
||||
|
||||
#include <minix/u64.h>
|
||||
#include <errno.h>
|
||||
#include <string.h>
|
||||
#include <unistd.h>
|
||||
|
||||
@@ -11,38 +10,13 @@
|
||||
__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));
|
||||
}
|
||||
|
||||
@@ -3,83 +3,15 @@
|
||||
#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)
|
||||
|
||||
@@ -3,52 +3,24 @@
|
||||
#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));
|
||||
}
|
||||
|
||||
@@ -7,45 +7,17 @@ __weak_alias(truncate, _truncate)
|
||||
#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));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user