1*0Sstevel@tonic-gate /* 2*0Sstevel@tonic-gate * CDDL HEADER START 3*0Sstevel@tonic-gate * 4*0Sstevel@tonic-gate * The contents of this file are subject to the terms of the 5*0Sstevel@tonic-gate * Common Development and Distribution License, Version 1.0 only 6*0Sstevel@tonic-gate * (the "License"). You may not use this file except in compliance 7*0Sstevel@tonic-gate * with the License. 8*0Sstevel@tonic-gate * 9*0Sstevel@tonic-gate * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10*0Sstevel@tonic-gate * or http://www.opensolaris.org/os/licensing. 11*0Sstevel@tonic-gate * See the License for the specific language governing permissions 12*0Sstevel@tonic-gate * and limitations under the License. 13*0Sstevel@tonic-gate * 14*0Sstevel@tonic-gate * When distributing Covered Code, include this CDDL HEADER in each 15*0Sstevel@tonic-gate * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16*0Sstevel@tonic-gate * If applicable, add the following below this CDDL HEADER, with the 17*0Sstevel@tonic-gate * fields enclosed by brackets "[]" replaced with your own identifying 18*0Sstevel@tonic-gate * information: Portions Copyright [yyyy] [name of copyright owner] 19*0Sstevel@tonic-gate * 20*0Sstevel@tonic-gate * CDDL HEADER END 21*0Sstevel@tonic-gate */ 22*0Sstevel@tonic-gate /* 23*0Sstevel@tonic-gate * Copyright 1996-1999, 2003 Sun Microsystems, Inc. All rights reserved. 24*0Sstevel@tonic-gate * Use is subject to license terms. 25*0Sstevel@tonic-gate */ 26*0Sstevel@tonic-gate 27*0Sstevel@tonic-gate %#pragma ident "%Z%%M% %I% %E% SMI" 28*0Sstevel@tonic-gate 29*0Sstevel@tonic-gate const WNL_PORT = 2049; 30*0Sstevel@tonic-gate const WNL_MAXDATA = 8192; 31*0Sstevel@tonic-gate const WNL_MAXNAMLEN = 255; 32*0Sstevel@tonic-gate const WNL_FHSIZE = 32; 33*0Sstevel@tonic-gate const WNL_FIFO_DEV = -1; /* size kludge for named pipes */ 34*0Sstevel@tonic-gate 35*0Sstevel@tonic-gate /* 36*0Sstevel@tonic-gate * Indicator for native path semantics. 37*0Sstevel@tonic-gate */ 38*0Sstevel@tonic-gate const WNL_NATIVEPATH = 0x80; 39*0Sstevel@tonic-gate 40*0Sstevel@tonic-gate /* 41*0Sstevel@tonic-gate * Indicator for security negotiation. 42*0Sstevel@tonic-gate */ 43*0Sstevel@tonic-gate const WNL_SEC_NEGO = 0x81; 44*0Sstevel@tonic-gate 45*0Sstevel@tonic-gate /* 46*0Sstevel@tonic-gate * File types 47*0Sstevel@tonic-gate */ 48*0Sstevel@tonic-gate const WNLMODE_FMT = 0170000; /* type of file */ 49*0Sstevel@tonic-gate const WNLMODE_DIR = 0040000; /* directory */ 50*0Sstevel@tonic-gate const WNLMODE_CHR = 0020000; /* character special */ 51*0Sstevel@tonic-gate const WNLMODE_BLK = 0060000; /* block special */ 52*0Sstevel@tonic-gate const WNLMODE_REG = 0100000; /* regular */ 53*0Sstevel@tonic-gate const WNLMODE_LNK = 0120000; /* symbolic link */ 54*0Sstevel@tonic-gate const WNLMODE_SOCK = 0140000; /* socket */ 55*0Sstevel@tonic-gate const WNLMODE_FIFO = 0010000; /* fifo */ 56*0Sstevel@tonic-gate 57*0Sstevel@tonic-gate /* 58*0Sstevel@tonic-gate * Error status 59*0Sstevel@tonic-gate */ 60*0Sstevel@tonic-gate enum wnl_stat { 61*0Sstevel@tonic-gate WNL_OK= 0, /* no error */ 62*0Sstevel@tonic-gate WNLERR_PERM=1, /* Not owner */ 63*0Sstevel@tonic-gate WNLERR_NOENT=2, /* No such file or directory */ 64*0Sstevel@tonic-gate WNLERR_IO=5, /* I/O error */ 65*0Sstevel@tonic-gate WNLERR_NXIO=6, /* No such device or address */ 66*0Sstevel@tonic-gate WNLERR_ACCES=13, /* Permission denied */ 67*0Sstevel@tonic-gate WNLERR_EXIST=17, /* File exists */ 68*0Sstevel@tonic-gate WNLERR_XDEV=18, /* Cross-device link */ 69*0Sstevel@tonic-gate WNLERR_NODEV=19, /* No such device */ 70*0Sstevel@tonic-gate WNLERR_NOTDIR=20, /* Not a directory*/ 71*0Sstevel@tonic-gate WNLERR_ISDIR=21, /* Is a directory */ 72*0Sstevel@tonic-gate WNLERR_INVAL=22, /* Invalid argument */ 73*0Sstevel@tonic-gate WNLERR_FBIG=27, /* File too large */ 74*0Sstevel@tonic-gate WNLERR_NOSPC=28, /* No space left on device */ 75*0Sstevel@tonic-gate WNLERR_ROFS=30, /* Read-only file system */ 76*0Sstevel@tonic-gate WNLERR_OPNOTSUPP=45, /* Operation not supported */ 77*0Sstevel@tonic-gate WNLERR_NAMETOOLONG=63, /* File name too long */ 78*0Sstevel@tonic-gate WNLERR_NOTEMPTY=66, /* Directory not empty */ 79*0Sstevel@tonic-gate WNLERR_DQUOT=69, /* Disc quota exceeded */ 80*0Sstevel@tonic-gate WNLERR_STALE=70, /* Stale WNL file handle */ 81*0Sstevel@tonic-gate WNLERR_REMOTE=71, /* Object is remote */ 82*0Sstevel@tonic-gate WNLERR_WFLUSH=72 /* write cache flushed */ 83*0Sstevel@tonic-gate }; 84*0Sstevel@tonic-gate 85*0Sstevel@tonic-gate /* 86*0Sstevel@tonic-gate * File types 87*0Sstevel@tonic-gate */ 88*0Sstevel@tonic-gate enum wnl_ftype { 89*0Sstevel@tonic-gate WNL_NON = 0, /* non-file */ 90*0Sstevel@tonic-gate WNL_REG = 1, /* regular file */ 91*0Sstevel@tonic-gate WNL_DIR = 2, /* directory */ 92*0Sstevel@tonic-gate WNL_BLK = 3, /* block special */ 93*0Sstevel@tonic-gate WNL_CHR = 4, /* character special */ 94*0Sstevel@tonic-gate WNL_LNK = 5, /* symbolic link */ 95*0Sstevel@tonic-gate WNL_SOCK = 6, /* unix domain sockets */ 96*0Sstevel@tonic-gate WNL_BAD = 7, /* unused */ 97*0Sstevel@tonic-gate WNL_FIFO = 8 /* named pipe */ 98*0Sstevel@tonic-gate }; 99*0Sstevel@tonic-gate 100*0Sstevel@tonic-gate /* 101*0Sstevel@tonic-gate * File access handle 102*0Sstevel@tonic-gate */ 103*0Sstevel@tonic-gate struct wnl_fh { 104*0Sstevel@tonic-gate opaque data[WNL_FHSIZE]; 105*0Sstevel@tonic-gate }; 106*0Sstevel@tonic-gate 107*0Sstevel@tonic-gate /* 108*0Sstevel@tonic-gate * Timeval 109*0Sstevel@tonic-gate */ 110*0Sstevel@tonic-gate struct wnl_time { 111*0Sstevel@tonic-gate unsigned seconds; 112*0Sstevel@tonic-gate unsigned useconds; 113*0Sstevel@tonic-gate }; 114*0Sstevel@tonic-gate 115*0Sstevel@tonic-gate 116*0Sstevel@tonic-gate /* 117*0Sstevel@tonic-gate * File attributes 118*0Sstevel@tonic-gate */ 119*0Sstevel@tonic-gate struct wnl_fattr { 120*0Sstevel@tonic-gate wnl_ftype type; /* file type */ 121*0Sstevel@tonic-gate unsigned mode; /* protection mode bits */ 122*0Sstevel@tonic-gate unsigned nlink; /* # hard links */ 123*0Sstevel@tonic-gate unsigned uid; /* owner user id */ 124*0Sstevel@tonic-gate unsigned gid; /* owner group id */ 125*0Sstevel@tonic-gate unsigned size; /* file size in bytes */ 126*0Sstevel@tonic-gate unsigned blocksize; /* prefered block size */ 127*0Sstevel@tonic-gate unsigned rdev; /* special device # */ 128*0Sstevel@tonic-gate unsigned blocks; /* Kb of disk used by file */ 129*0Sstevel@tonic-gate unsigned fsid; /* device # */ 130*0Sstevel@tonic-gate unsigned fileid; /* inode # */ 131*0Sstevel@tonic-gate wnl_time atime; /* time of last access */ 132*0Sstevel@tonic-gate wnl_time mtime; /* time of last modification */ 133*0Sstevel@tonic-gate wnl_time ctime; /* time of last change */ 134*0Sstevel@tonic-gate }; 135*0Sstevel@tonic-gate 136*0Sstevel@tonic-gate typedef string wnl_filename<WNL_MAXNAMLEN>; 137*0Sstevel@tonic-gate 138*0Sstevel@tonic-gate /* 139*0Sstevel@tonic-gate * Arguments for directory operations 140*0Sstevel@tonic-gate */ 141*0Sstevel@tonic-gate struct wnl_diropargs { 142*0Sstevel@tonic-gate wnl_fh dir; /* directory file handle */ 143*0Sstevel@tonic-gate wnl_filename name; /* name (up to WNL_MAXNAMLEN bytes) */ 144*0Sstevel@tonic-gate }; 145*0Sstevel@tonic-gate 146*0Sstevel@tonic-gate struct wnl_diropokres { 147*0Sstevel@tonic-gate wnl_fh file; 148*0Sstevel@tonic-gate wnl_fattr attributes; 149*0Sstevel@tonic-gate }; 150*0Sstevel@tonic-gate 151*0Sstevel@tonic-gate /* 152*0Sstevel@tonic-gate * Results from directory operation 153*0Sstevel@tonic-gate */ 154*0Sstevel@tonic-gate union wnl_diropres switch (wnl_stat status) { 155*0Sstevel@tonic-gate case WNL_OK: 156*0Sstevel@tonic-gate wnl_diropokres wnl_diropres; 157*0Sstevel@tonic-gate default: 158*0Sstevel@tonic-gate void; 159*0Sstevel@tonic-gate }; 160*0Sstevel@tonic-gate 161*0Sstevel@tonic-gate /* 162*0Sstevel@tonic-gate * Version 3 declarations and definitions. 163*0Sstevel@tonic-gate */ 164*0Sstevel@tonic-gate 165*0Sstevel@tonic-gate /* 166*0Sstevel@tonic-gate * Sizes 167*0Sstevel@tonic-gate */ 168*0Sstevel@tonic-gate const WNL3_FHSIZE = 64; 169*0Sstevel@tonic-gate 170*0Sstevel@tonic-gate /* 171*0Sstevel@tonic-gate * Basic data types 172*0Sstevel@tonic-gate */ 173*0Sstevel@tonic-gate typedef unsigned hyper wnl_uint64; 174*0Sstevel@tonic-gate typedef hyper wnl_int64; 175*0Sstevel@tonic-gate typedef unsigned int wnl_uint32; 176*0Sstevel@tonic-gate typedef string wnl_filename3<>; 177*0Sstevel@tonic-gate typedef wnl_uint64 wnl_fileid3; 178*0Sstevel@tonic-gate typedef wnl_uint32 wnl_uid3; 179*0Sstevel@tonic-gate typedef wnl_uint32 wnl_gid3; 180*0Sstevel@tonic-gate typedef wnl_uint64 wnl_size3; 181*0Sstevel@tonic-gate typedef wnl_uint32 wnl_mode3; 182*0Sstevel@tonic-gate 183*0Sstevel@tonic-gate /* 184*0Sstevel@tonic-gate * Error status 185*0Sstevel@tonic-gate */ 186*0Sstevel@tonic-gate enum wnl_stat3 { 187*0Sstevel@tonic-gate WNL3_OK = 0, 188*0Sstevel@tonic-gate WNL3ERR_PERM = 1, 189*0Sstevel@tonic-gate WNL3ERR_NOENT = 2, 190*0Sstevel@tonic-gate WNL3ERR_IO = 5, 191*0Sstevel@tonic-gate WNL3ERR_NXIO = 6, 192*0Sstevel@tonic-gate WNL3ERR_ACCES = 13, 193*0Sstevel@tonic-gate WNL3ERR_EXIST = 17, 194*0Sstevel@tonic-gate WNL3ERR_XDEV = 18, 195*0Sstevel@tonic-gate WNL3ERR_NODEV = 19, 196*0Sstevel@tonic-gate WNL3ERR_NOTDIR = 20, 197*0Sstevel@tonic-gate WNL3ERR_ISDIR = 21, 198*0Sstevel@tonic-gate WNL3ERR_INVAL = 22, 199*0Sstevel@tonic-gate WNL3ERR_FBIG = 27, 200*0Sstevel@tonic-gate WNL3ERR_NOSPC = 28, 201*0Sstevel@tonic-gate WNL3ERR_ROFS = 30, 202*0Sstevel@tonic-gate WNL3ERR_MLINK = 31, 203*0Sstevel@tonic-gate WNL3ERR_NAMETOOLONG = 63, 204*0Sstevel@tonic-gate WNL3ERR_NOTEMPTY = 66, 205*0Sstevel@tonic-gate WNL3ERR_DQUOT = 69, 206*0Sstevel@tonic-gate WNL3ERR_STALE = 70, 207*0Sstevel@tonic-gate WNL3ERR_REMOTE = 71, 208*0Sstevel@tonic-gate WNL3ERR_BADHANDLE = 10001, 209*0Sstevel@tonic-gate WNL3ERR_NOT_SYNC = 10002, 210*0Sstevel@tonic-gate WNL3ERR_BAD_COOKIE = 10003, 211*0Sstevel@tonic-gate WNL3ERR_NOTSUPP = 10004, 212*0Sstevel@tonic-gate WNL3ERR_TOOSMALL = 10005, 213*0Sstevel@tonic-gate WNL3ERR_SERVERFAULT = 10006, 214*0Sstevel@tonic-gate WNL3ERR_BADTYPE = 10007, 215*0Sstevel@tonic-gate WNL3ERR_JUKEBOX = 10008 216*0Sstevel@tonic-gate }; 217*0Sstevel@tonic-gate 218*0Sstevel@tonic-gate /* 219*0Sstevel@tonic-gate * File types 220*0Sstevel@tonic-gate */ 221*0Sstevel@tonic-gate enum wnl_ftype3 { 222*0Sstevel@tonic-gate WNL_3REG = 1, 223*0Sstevel@tonic-gate WNL_3DIR = 2, 224*0Sstevel@tonic-gate WNL_3BLK = 3, 225*0Sstevel@tonic-gate WNL_3CHR = 4, 226*0Sstevel@tonic-gate WNL_3LNK = 5, 227*0Sstevel@tonic-gate WNL_3SOCK = 6, 228*0Sstevel@tonic-gate WNL_3FIFO = 7 229*0Sstevel@tonic-gate }; 230*0Sstevel@tonic-gate 231*0Sstevel@tonic-gate struct wnl_specdata3 { 232*0Sstevel@tonic-gate wnl_uint32 specdata1; 233*0Sstevel@tonic-gate wnl_uint32 specdata2; 234*0Sstevel@tonic-gate }; 235*0Sstevel@tonic-gate 236*0Sstevel@tonic-gate /* 237*0Sstevel@tonic-gate * File access handle 238*0Sstevel@tonic-gate */ 239*0Sstevel@tonic-gate struct wnl_fh3 { 240*0Sstevel@tonic-gate opaque data<WNL3_FHSIZE>; 241*0Sstevel@tonic-gate }; 242*0Sstevel@tonic-gate 243*0Sstevel@tonic-gate /* 244*0Sstevel@tonic-gate * Timeval 245*0Sstevel@tonic-gate */ 246*0Sstevel@tonic-gate struct wnl_time3 { 247*0Sstevel@tonic-gate wnl_uint32 seconds; 248*0Sstevel@tonic-gate wnl_uint32 nseconds; 249*0Sstevel@tonic-gate }; 250*0Sstevel@tonic-gate 251*0Sstevel@tonic-gate /* 252*0Sstevel@tonic-gate * File attributes 253*0Sstevel@tonic-gate */ 254*0Sstevel@tonic-gate struct wnl_fattr3 { 255*0Sstevel@tonic-gate wnl_ftype3 type; 256*0Sstevel@tonic-gate wnl_mode3 mode; 257*0Sstevel@tonic-gate wnl_uint32 nlink; 258*0Sstevel@tonic-gate wnl_uid3 uid; 259*0Sstevel@tonic-gate wnl_gid3 gid; 260*0Sstevel@tonic-gate wnl_size3 size; 261*0Sstevel@tonic-gate wnl_size3 used; 262*0Sstevel@tonic-gate wnl_specdata3 rdev; 263*0Sstevel@tonic-gate wnl_uint64 fsid; 264*0Sstevel@tonic-gate wnl_fileid3 fileid; 265*0Sstevel@tonic-gate wnl_time3 atime; 266*0Sstevel@tonic-gate wnl_time3 mtime; 267*0Sstevel@tonic-gate wnl_time3 ctime; 268*0Sstevel@tonic-gate }; 269*0Sstevel@tonic-gate 270*0Sstevel@tonic-gate /* 271*0Sstevel@tonic-gate * File attributes 272*0Sstevel@tonic-gate */ 273*0Sstevel@tonic-gate union wnl_post_op_attr switch (bool attributes_follow) { 274*0Sstevel@tonic-gate case TRUE: 275*0Sstevel@tonic-gate wnl_fattr3 attributes; 276*0Sstevel@tonic-gate case FALSE: 277*0Sstevel@tonic-gate void; 278*0Sstevel@tonic-gate }; 279*0Sstevel@tonic-gate 280*0Sstevel@tonic-gate union wln_post_op_fh3 switch (bool handle_follows) { 281*0Sstevel@tonic-gate case TRUE: 282*0Sstevel@tonic-gate wnl_fh3 handle; 283*0Sstevel@tonic-gate case FALSE: 284*0Sstevel@tonic-gate void; 285*0Sstevel@tonic-gate }; 286*0Sstevel@tonic-gate 287*0Sstevel@tonic-gate struct wnl_diropargs3 { 288*0Sstevel@tonic-gate wnl_fh3 dir; 289*0Sstevel@tonic-gate wnl_filename3 name; 290*0Sstevel@tonic-gate }; 291*0Sstevel@tonic-gate 292*0Sstevel@tonic-gate /* 293*0Sstevel@tonic-gate * LOOKUP: Lookup wnl_filename 294*0Sstevel@tonic-gate */ 295*0Sstevel@tonic-gate struct WNL_LOOKUP3args { 296*0Sstevel@tonic-gate wnl_diropargs3 what; 297*0Sstevel@tonic-gate }; 298*0Sstevel@tonic-gate 299*0Sstevel@tonic-gate struct WNL_LOOKUP3resok { 300*0Sstevel@tonic-gate wnl_fh3 object; 301*0Sstevel@tonic-gate wnl_post_op_attr obj_attributes; 302*0Sstevel@tonic-gate wnl_post_op_attr dir_attributes; 303*0Sstevel@tonic-gate }; 304*0Sstevel@tonic-gate 305*0Sstevel@tonic-gate struct WNL_LOOKUP3resfail { 306*0Sstevel@tonic-gate wnl_post_op_attr dir_attributes; 307*0Sstevel@tonic-gate }; 308*0Sstevel@tonic-gate 309*0Sstevel@tonic-gate union WNL_LOOKUP3res switch (wnl_stat3 status) { 310*0Sstevel@tonic-gate case WNL3_OK: 311*0Sstevel@tonic-gate WNL_LOOKUP3resok res_ok; 312*0Sstevel@tonic-gate default: 313*0Sstevel@tonic-gate WNL_LOOKUP3resfail res_fail; 314*0Sstevel@tonic-gate }; 315*0Sstevel@tonic-gate 316*0Sstevel@tonic-gate const MAX_FLAVORS = 128; 317*0Sstevel@tonic-gate 318*0Sstevel@tonic-gate struct snego_t { 319*0Sstevel@tonic-gate int cnt; 320*0Sstevel@tonic-gate int array[MAX_FLAVORS]; 321*0Sstevel@tonic-gate }; 322*0Sstevel@tonic-gate 323*0Sstevel@tonic-gate enum snego_stat { 324*0Sstevel@tonic-gate /* default flavor invalid and a flavor has been negotiated */ 325*0Sstevel@tonic-gate SNEGO_SUCCESS = 0, 326*0Sstevel@tonic-gate 327*0Sstevel@tonic-gate /* default flavor valid, no need to negotiate flavors */ 328*0Sstevel@tonic-gate SNEGO_DEF_VALID = 1, 329*0Sstevel@tonic-gate 330*0Sstevel@tonic-gate /* array size too small */ 331*0Sstevel@tonic-gate SNEGO_ARRAY_TOO_SMALL = 2, 332*0Sstevel@tonic-gate 333*0Sstevel@tonic-gate SNEGO_FAILURE = 3 334*0Sstevel@tonic-gate }; 335*0Sstevel@tonic-gate 336*0Sstevel@tonic-gate /* 337*0Sstevel@tonic-gate * Remote file service routines 338*0Sstevel@tonic-gate */ 339*0Sstevel@tonic-gate program WNL_PROGRAM { 340*0Sstevel@tonic-gate version WNL_V2 { 341*0Sstevel@tonic-gate void 342*0Sstevel@tonic-gate WNLPROC_NULL(void) = 0; 343*0Sstevel@tonic-gate 344*0Sstevel@tonic-gate wnl_diropres 345*0Sstevel@tonic-gate WNLPROC_LOOKUP(wnl_diropargs) = 4; 346*0Sstevel@tonic-gate } = 2; 347*0Sstevel@tonic-gate 348*0Sstevel@tonic-gate version WNL_V3 { 349*0Sstevel@tonic-gate void 350*0Sstevel@tonic-gate WNLPROC3_NULL(void) = 0; 351*0Sstevel@tonic-gate 352*0Sstevel@tonic-gate WNL_LOOKUP3res 353*0Sstevel@tonic-gate WNLPROC3_LOOKUP(WNL_LOOKUP3args) = 3; 354*0Sstevel@tonic-gate } = 3; 355*0Sstevel@tonic-gate 356*0Sstevel@tonic-gate version WNL_V4 { 357*0Sstevel@tonic-gate void 358*0Sstevel@tonic-gate WNLPROC4_NULL(void) = 0; 359*0Sstevel@tonic-gate } = 4; 360*0Sstevel@tonic-gate 361*0Sstevel@tonic-gate } = 100003; 362