tmount-BSD.c - plan9port - [fork] Plan 9 from user space
git clone git://src.adamsgaard.dk/plan9port
Log
Files
Refs
README
LICENSE
---
tmount-BSD.c (1685B)
---
     1 #include 
     2 #include 
     3 #include 
     4 #include 
     5 #include 
     6 #include 
     7 #include 
     8 #include 
     9 #include 
    10 #include 
    11 #include 
    12 #if defined(__FreeBSD_version) && __FreeBSD_version >= 800000
    13 #include 
    14 #include 
    15 # else
    16 #include 
    17 #include 
    18 #endif
    19 #if defined(__FreeBSD_version) && __FreeBSD_version >= 500000
    20 #        include 
    21 #        ifndef MNT_NODEV
    22 #                define MNT_NODEV 0
    23 #        endif
    24 #else
    25 #        include 
    26 #endif
    27 #ifdef __NetBSD__
    28 #        include 
    29 #endif
    30 #include 
    31 #include "mountnfs.h"
    32 #ifndef MNT_NOATIME
    33 #        define MNT_NOATIME 0
    34 #endif
    35 
    36 void
    37 mountnfs(int proto, struct sockaddr_in *sa,
    38         uchar *handle, int nhandle, char *mtpt)
    39 {
    40         int mflag;
    41         struct nfs_args na;
    42 
    43         memset(&na, 0, sizeof na);
    44         na.version = NFS_ARGSVERSION;
    45         na.addr = (struct sockaddr*)sa;
    46         na.addrlen = sizeof *sa;
    47         na.sotype = proto;
    48         na.proto = (proto == SOCK_STREAM) ? IPPROTO_TCP : IPPROTO_UDP;
    49         na.fh = handle;
    50         na.fhsize = nhandle;
    51         na.flags = NFSMNT_RESVPORT|NFSMNT_NFSV3|NFSMNT_INT;
    52         na.wsize = NFS_WSIZE;
    53         na.rsize = NFS_RSIZE;
    54         na.readdirsize = NFS_READDIRSIZE;
    55         na.timeo = 200;
    56         na.retrans = NFS_RETRANS;
    57         na.maxgrouplist = NFS_MAXGRPS;
    58         na.hostname = "backup";
    59 #if !defined(__NetBSD__) && !defined(__APPLE__)
    60         na.acregmin = 60;
    61         na.acregmax = 600;
    62         na.acdirmin = 60;
    63         na.acdirmax = 600;
    64 #endif
    65         mflag = MNT_RDONLY|MNT_NOSUID|MNT_NOATIME|MNT_NODEV;
    66 #ifdef __NetBSD__
    67         if(mount("nfs", mtpt, mflag, &na, sizeof(na)) < 0)
    68 #else
    69         if(mount("nfs", mtpt, mflag, &na) < 0)
    70 #endif
    71                 sysfatal("mount: %r");
    72 }