This is syscalls.c in view mode; [Download] [Up]
/* * Name: syscalls.c * Description: This module contains wrappers for system calls that are * different on various systems All system dependent C-code should go * here. The interface of this module is defined in "syshdr.h". * Author: Christian Starkjohann <cs@hal.kph.tuwien.ac.at> * Date: 1996-12-14 * Copyright: GNU-GPL * Tabsize: 4 */ #define NFSCLIENT #include "syshdr.h" #include <rpc/rpc.h> #include "nfs_prot.h" #include <netdb.h> #include <arpa/inet.h> #include "my_defines.h" /* ------------------------------------------------------------------------- */ #ifdef NeXT # include <nfs/nfs_mount.h> int syscall_mount(char *dir, void *root_fh, int sock_fd, struct sockaddr_in *socket) { struct nfs_args nfs_args; bzero(&nfs_args, sizeof(nfs_args)); nfs_args.wsize = 8192; nfs_args.rsize = 8192; nfs_args.retrans = 0; nfs_args.timeo = 100; /* 10s timeout */ nfs_args.addr = socket; nfs_args.flags = NFSMNT_SOFT | NFSMNT_HOSTNAME | NFSMNT_RETRANS | NFSMNT_TIMEO | NFSMNT_WSIZE | NFSMNT_RSIZE; nfs_args.fh = (char *)root_fh; nfs_args.hostname = "rumba"; nfs_args.netname = "net"; return mount(MOUNT_NFS, dir, 0, (caddr_t)&nfs_args); } #endif /* ------------------------------------------------------------------------- */ #ifdef linux # include <linux/nfs_mount.h> int syscall_mount(char *dir, void *root_fh, int sock_fd, struct sockaddr_in *sockaddr) { struct nfs_mount_data nfs_args; int ksock, kport; struct sockaddr_in kaddr; /* * We have to do the connect for the kernel before we can call mount(). */ ksock = socket(AF_INET, SOCK_DGRAM, IPPROTO_UDP); if(ksock < 0){ eprintf("syscall_mount: socket: [%d] %s\n", errno, strerror(errno)); exit(1); } kaddr.sin_family = AF_INET; kaddr.sin_addr.s_addr = inet_addr("127.0.0.1"); for(kport = IPPORT_RESERVED - 1; kport > IPPORT_RESERVED/2; kport--){ kaddr.sin_port = htons(kport); if(bind(ksock, (struct sockaddr *)&kaddr, sizeof(kaddr)) >= 0) break; } if (kport <= IPPORT_RESERVED/2){ eprintf("syscall_mount: bind to reserved port: [%d] %s\n", errno, strerror(errno)); exit(1); } bzero(&nfs_args, sizeof(nfs_args)); nfs_args.version = NFS_MOUNT_VERSION; nfs_args.fd = ksock; nfs_args.flags = NFS_MOUNT_SOFT; nfs_args.wsize = 8192; nfs_args.rsize = 8192; nfs_args.retrans = 0; nfs_args.timeo = 100; /* 10s timeout */ nfs_args.acregmin = 3; /* 3s */ nfs_args.acregmax = 10; /* 10s */ nfs_args.acdirmin = 10; /* 10s */ nfs_args.acdirmax = 10; /* 10s */ nfs_args.addr = *sockaddr; nfs_args.root = *(nfs_fh *)root_fh; strcpy(nfs_args.hostname, "rumba"); if(connect(ksock, (struct sockaddr *)&nfs_args.addr, sizeof(nfs_args.addr)) < 0){ eprintf("syscall_mount: connect: [%d] %s\n", errno, strerror(errno)); exit(1); } return mount("rumba:/", dir, "nfs", 0xc0ed0000, &nfs_args); } #endif /* ------------------------------------------------------------------------- */
These are the contents of the former NiCE NeXT User Group NeXTSTEP/OpenStep software archive, currently hosted by Netfuture.ch.