Whamcloud - gitweb
git://git.whamcloud.com
/
fs
/
lustre-release.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
b=20668
[fs/lustre-release.git]
/
libsysio
/
drivers
/
sockets
/
sockets.c
diff --git
a/libsysio/drivers/sockets/sockets.c
b/libsysio/drivers/sockets/sockets.c
index
b037e60
..
8dec0a7
100644
(file)
--- a/
libsysio/drivers/sockets/sockets.c
+++ b/
libsysio/drivers/sockets/sockets.c
@@
-53,18
+53,21
@@
#include <unistd.h>
#include <errno.h>
#include <assert.h>
#include <unistd.h>
#include <errno.h>
#include <assert.h>
-#include <syscall.h>
+#include <sys
/sys
call.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/fcntl.h>
#include <sys/syscall.h>
#include <sys/socket.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/fcntl.h>
#include <sys/syscall.h>
#include <sys/socket.h>
+#ifdef __linux__
#include <linux/net.h>
#include <linux/net.h>
+#endif
#include <sys/uio.h>
#include <sys/queue.h>
#include <sys/uio.h>
#include <sys/queue.h>
-#include "xtio.h"
#include "sysio.h"
#include "sysio.h"
+#include "xtio.h"
+#include "native.h"
#include "fs.h"
#include "inode.h"
#include "file.h"
#include "fs.h"
#include "inode.h"
#include "file.h"
@@
-116,7
+119,7
@@
struct filesys_ops sockets_filesys_ops = {
(void (*)(struct filesys *))sockets_illop
};
(void (*)(struct filesys *))sockets_illop
};
-static struct filesys *sockets_fs;
+static struct filesys *sockets_fs
= NULL
;
static struct inode_ops sockets_i_ops;
static struct inode_ops sockets_i_ops;
@@
-127,6
+130,8
@@
int
_sysio_sockets_init()
{
_sysio_sockets_init()
{
+ assert(!sockets_fs);
+
sockets_i_ops = _sysio_nodev_ops;
sockets_i_ops.inop_close = sockets_inop_close;
sockets_i_ops.inop_read = sockets_inop_read;
sockets_i_ops = _sysio_nodev_ops;
sockets_i_ops.inop_close = sockets_inop_close;
sockets_i_ops.inop_read = sockets_inop_read;
@@
-155,7
+160,7
@@
sockets_inop_close(struct inode *ino)
if (ski->ski_fd < 0)
return -EBADF;
if (ski->ski_fd < 0)
return -EBADF;
- err = syscall(SYS_close, ski->ski_fd);
+ err = syscall(SYS
IO_SYS
_close, ski->ski_fd);
if (err)
return -errno;
ski->ski_fd = -1;
if (err)
return -errno;
ski->ski_fd = -1;
@@
-206,7
+211,7
@@
static ssize_t
_readv(int fd, const struct iovec *vector, int count)
{
_readv(int fd, const struct iovec *vector, int count)
{
- return syscall(SYS_readv, fd, vector, count);
+ return syscall(SYS
IO_SYS
_readv, fd, vector, count);
}
static int
}
static int
@@
-224,7
+229,7
@@
static ssize_t
_writev(int fd, const struct iovec *vector, int count)
{
_writev(int fd, const struct iovec *vector, int count)
{
- return syscall(SYS_writev, fd, vector, count);
+ return syscall(SYS
IO_SYS
_writev, fd, vector, count);
}
static int
}
static int
@@
-265,7
+270,7
@@
sockets_inop_fcntl(struct inode *ino __IS_UNUSED,
case F_GETFD:
case F_GETFL:
case F_GETOWN:
case F_GETFD:
case F_GETFL:
case F_GETOWN:
- *rtn = syscall(SYS_fcntl, I2SKI(ino)->ski_fd, cmd);
+ *rtn = syscall(SYS
IO_SYS
_fcntl, I2SKI(ino)->ski_fd, cmd);
break;
case F_DUPFD:
case F_SETFD:
break;
case F_DUPFD:
case F_SETFD:
@@
-275,7
+280,7
@@
sockets_inop_fcntl(struct inode *ino __IS_UNUSED,
case F_SETLKW:
case F_SETOWN:
arg = va_arg(ap, long);
case F_SETLKW:
case F_SETOWN:
arg = va_arg(ap, long);
- *rtn = syscall(SYS_fcntl, I2SKI(ino)->ski_fd, cmd, arg);
+ *rtn = syscall(SYS
IO_SYS
_fcntl, I2SKI(ino)->ski_fd, cmd, arg);
break;
default:
*rtn = -1;
break;
default:
*rtn = -1;
@@
-290,7
+295,7
@@
sockets_inop_sync(struct inode *ino)
assert(I2SKI(ino)->ski_fd >= 0);
assert(I2SKI(ino)->ski_fd >= 0);
- return syscall(SYS_fsync, I2SKI(ino)->ski_fd);
+ return syscall(SYS
IO_SYS
_fsync, I2SKI(ino)->ski_fd);
}
static int
}
static int
@@
-299,7
+304,7
@@
sockets_inop_datasync(struct inode *ino)
assert(I2SKI(ino)->ski_fd >= 0);
assert(I2SKI(ino)->ski_fd >= 0);
- return syscall(SYS_fdatasync, I2SKI(ino)->ski_fd);
+ return syscall(SYS
IO_SYS
_fdatasync, I2SKI(ino)->ski_fd);
}
#ifdef HAVE_LUSTRE_HACK
}
#ifdef HAVE_LUSTRE_HACK
@@
-321,7
+326,7
@@
sockets_inop_ioctl(struct inode *ino,
arg3 = va_arg(ap, long);
arg4 = va_arg(ap, long);
arg3 = va_arg(ap, long);
arg4 = va_arg(ap, long);
- return syscall(SYS_ioctl, I2SKI(ino)->ski_fd, request,
+ return syscall(SYS
IO_SYS
_ioctl, I2SKI(ino)->ski_fd, request,
arg1, arg2, arg3, arg4);
}
#else
arg1, arg2, arg3, arg4);
}
#else
@@
-358,6
+363,7
@@
_sysio_sockets_inew()
static ino_t inum = 1;
struct socket_info *ski;
struct inode *ino;
static ino_t inum = 1;
struct socket_info *ski;
struct inode *ino;
+ static struct intnl_stat zero_stat;
ski = malloc(sizeof(struct socket_info));
if (!ski)
ski = malloc(sizeof(struct socket_info));
if (!ski)
@@
-370,8
+376,7
@@
_sysio_sockets_inew()
ino =
_sysio_i_new(sockets_fs,
&ski->ski_fileid,
ino =
_sysio_i_new(sockets_fs,
&ski->ski_fileid,
- 0,
- 0,
+ &zero_stat,
0,
&sockets_i_ops,
ski);
0,
&sockets_i_ops,
ski);
@@
-382,7
+387,7
@@
_sysio_sockets_inew()
}
int
}
int
-
socket
(int domain, int type, int protocol)
+
SYSIO_INTERFACE_NAME(socket)
(int domain, int type, int protocol)
{
int err;
struct inode *ino;
{
int err;
struct inode *ino;
@@
-399,12
+404,13
@@
socket(int domain, int type, int protocol)
}
ski = I2SKI(ino);
}
ski = I2SKI(ino);
-#ifndef SYS_socketcall
- ski->ski_fd = syscall(SYS_socket, domain, type, protocol);
+#ifndef SYS
IO_SYS
_socketcall
+ ski->ski_fd = syscall(SYS
IO_SYS
_socket, domain, type, protocol);
#else
{
unsigned long avec[3] = {domain, type, protocol};
#else
{
unsigned long avec[3] = {domain, type, protocol};
- ski->ski_fd = syscall(SYS_socketcall, SYS_SOCKET, avec);
+ ski->ski_fd =
+ syscall(SYSIO_SYS_socketcall, SYS_SOCKET, avec);
}
#endif
if (ski->ski_fd < 0) {
}
#endif
if (ski->ski_fd < 0) {
@@
-439,7
+445,7
@@
error:
}
int
}
int
-
accept
(int s, struct sockaddr *addr, socklen_t *addrlen)
+
SYSIO_INTERFACE_NAME(accept)
(int s, struct sockaddr *addr, socklen_t *addrlen)
{
int err;
struct inode *ino;
{
int err;
struct inode *ino;
@@
-469,16
+475,20
@@
accept(int s, struct sockaddr *addr, socklen_t *addrlen)
}
ski = I2SKI(ino);
}
ski = I2SKI(ino);
-#ifndef SYS_socketcall
- ski->ski_fd = syscall(SYS_accept, I2SKI(ofil->f_ino)->ski_fd,
- addr, addrlen);
+#ifndef SYSIO_SYS_socketcall
+ ski->ski_fd =
+ syscall(SYSIO_SYS_accept,
+ I2SKI(ofil->f_ino)->ski_fd,
+ addr,
+ addrlen);
#else
{
unsigned long avec[3] = {
(unsigned long) I2SKI(ofil->f_ino)->ski_fd,
(unsigned long) addr,
(unsigned long) addrlen};
#else
{
unsigned long avec[3] = {
(unsigned long) I2SKI(ofil->f_ino)->ski_fd,
(unsigned long) addr,
(unsigned long) addrlen};
- ski->ski_fd = syscall(SYS_socketcall, SYS_ACCEPT, avec);
+ ski->ski_fd =
+ syscall(SYSIO_SYS_socketcall, SYS_ACCEPT, avec);
}
#endif
if (ski->ski_fd < 0) {
}
#endif
if (ski->ski_fd < 0) {
@@
-507,11
+517,15
@@
error:
}
int
}
int
-bind(int sockfd, const struct sockaddr *my_addr, socklen_t addrlen)
+SYSIO_INTERFACE_NAME(bind)(int sockfd,
+ const struct sockaddr *my_addr,
+ socklen_t addrlen)
{
int err;
struct file *fil;
{
int err;
struct file *fil;
+#ifdef SYSIO_SYS_socketcall
unsigned long avec[3];
unsigned long avec[3];
+#endif
err = 0;
err = 0;
@@
-521,13
+535,16
@@
bind(int sockfd, const struct sockaddr *my_addr, socklen_t addrlen)
goto out;
}
goto out;
}
-#ifndef SYS_socketcall
- if (syscall(SYS_bind, I2SKI(fil->f_ino)->ski_fd, my_addr, addrlen)) {
+#ifndef SYSIO_SYS_socketcall
+ if (syscall(SYSIO_SYS_bind,
+ I2SKI(fil->f_ino)->ski_fd,
+ my_addr,
+ addrlen)) {
#else
avec[0] = I2SKI(fil->f_ino)->ski_fd;
avec[1] = (unsigned long )my_addr;
avec[2] = addrlen;
#else
avec[0] = I2SKI(fil->f_ino)->ski_fd;
avec[1] = (unsigned long )my_addr;
avec[2] = addrlen;
- if (syscall(SYS_socketcall, SYS_BIND, avec) != 0) {
+ if (syscall(SYS
IO_SYS
_socketcall, SYS_BIND, avec) != 0) {
#endif
err = -errno;
goto out;
#endif
err = -errno;
goto out;
@@
-540,11
+557,13
@@
out:
}
int
}
int
-
listen
(int s, int backlog)
+
SYSIO_INTERFACE_NAME(listen)
(int s, int backlog)
{
int err;
struct file *fil;
{
int err;
struct file *fil;
+#ifdef SYSIO_SYS_socketcall
unsigned long avec[2];
unsigned long avec[2];
+#endif
err = 0;
err = 0;
@@
-554,12
+573,14
@@
listen(int s, int backlog)
goto out;
}
goto out;
}
-#ifndef SYS_socketcall
- if (syscall(SYS_listen, I2SKI(fil->f_ino)->ski_fd, backlog) != 0) {
+#ifndef SYSIO_SYS_socketcall
+ if (syscall(SYSIO_SYS_listen,
+ I2SKI(fil->f_ino)->ski_fd,
+ backlog) != 0) {
#else
avec[0] = I2SKI(fil->f_ino)->ski_fd;
avec[1] = backlog;
#else
avec[0] = I2SKI(fil->f_ino)->ski_fd;
avec[1] = backlog;
- if (syscall(SYS_socketcall, SYS_LISTEN, avec) != 0) {
+ if (syscall(SYS
IO_SYS
_socketcall, SYS_LISTEN, avec) != 0) {
#endif
err = -errno;
goto out;
#endif
err = -errno;
goto out;
@@
-572,11
+593,15
@@
out:
}
int
}
int
-connect(int sockfd, const struct sockaddr *serv_addr, socklen_t addrlen)
+SYSIO_INTERFACE_NAME(connect)(int sockfd,
+ const struct sockaddr *serv_addr,
+ socklen_t addrlen)
{
int err;
struct file *fil;
{
int err;
struct file *fil;
+#ifdef SYSIO_SYS_socketcall
unsigned long avec[3];
unsigned long avec[3];
+#endif
err = 0;
err = 0;
@@
-586,14
+611,16
@@
connect(int sockfd, const struct sockaddr *serv_addr, socklen_t addrlen)
goto out;
}
goto out;
}
-#ifndef SYS_socketcall
- if (syscall(SYS_connect, I2SKI(fil->f_ino)->ski_fd,
- serv_addr, addrlen) != 0) {
+#ifndef SYSIO_SYS_socketcall
+ if (syscall(SYSIO_SYS_connect,
+ I2SKI(fil->f_ino)->ski_fd,
+ serv_addr,
+ addrlen) != 0) {
#else
avec[0] = I2SKI(fil->f_ino)->ski_fd;
avec[1] = (unsigned long )serv_addr;
avec[2] = addrlen;
#else
avec[0] = I2SKI(fil->f_ino)->ski_fd;
avec[1] = (unsigned long )serv_addr;
avec[2] = addrlen;
- if (syscall(SYS_socketcall, SYS_CONNECT, avec) != 0) {
+ if (syscall(SYS
IO_SYS
_socketcall, SYS_CONNECT, avec) != 0) {
#endif
err = -errno;
goto out;
#endif
err = -errno;
goto out;