Changeset View
Changeset View
Standalone View
Standalone View
head/lib/libstand/nfs.c
Show First 20 Lines • Show All 208 Lines • ▼ Show 20 Lines | struct fs_ops nfs_fsops = { | ||||
nfs_write, | nfs_write, | ||||
nfs_seek, | nfs_seek, | ||||
nfs_stat, | nfs_stat, | ||||
nfs_readdir | nfs_readdir | ||||
}; | }; | ||||
static int nfs_read_size = NFSREAD_MIN_SIZE; | static int nfs_read_size = NFSREAD_MIN_SIZE; | ||||
/* | |||||
* Improve boot performance over NFS | |||||
*/ | |||||
static void | |||||
set_nfs_read_size(void) | |||||
{ | |||||
char *env, *end; | |||||
char buf[10]; | |||||
if ((env = getenv("nfs.read_size")) != NULL) { | |||||
errno = 0; | |||||
nfs_read_size = (int)strtol(env, &end, 0); | |||||
if (errno != 0 || *env == '\0' || *end != '\0') { | |||||
printf("%s: bad value: \"%s\", defaulting to %d\n", | |||||
"nfs.read_size", env, NFSREAD_MIN_SIZE); | |||||
nfs_read_size = NFSREAD_MIN_SIZE; | |||||
} | |||||
} | |||||
if (nfs_read_size < NFSREAD_MIN_SIZE) { | |||||
printf("%s: bad value: \"%d\", defaulting to %d\n", | |||||
"nfs.read_size", nfs_read_size, NFSREAD_MIN_SIZE); | |||||
nfs_read_size = NFSREAD_MIN_SIZE; | |||||
} | |||||
if (nfs_read_size > NFSREAD_MAX_SIZE) { | |||||
printf("%s: bad value: \"%d\", defaulting to %d\n", | |||||
"nfs.read_size", nfs_read_size, NFSREAD_MIN_SIZE); | |||||
nfs_read_size = NFSREAD_MAX_SIZE; | |||||
} | |||||
snprintf(buf, sizeof (buf), "%d", nfs_read_size); | |||||
setenv("nfs.read_size", buf, 1); | |||||
} | |||||
#ifdef OLD_NFSV2 | #ifdef OLD_NFSV2 | ||||
/* | /* | ||||
* Fetch the root file handle (call mount daemon) | * Fetch the root file handle (call mount daemon) | ||||
* Return zero or error number. | * Return zero or error number. | ||||
*/ | */ | ||||
int | int | ||||
nfs_getrootfh(struct iodesc *d, char *path, u_char *fhp) | nfs_getrootfh(struct iodesc *d, char *path, u_char *fhp) | ||||
{ | { | ||||
Show All 39 Lines | if (cc == -1) { | ||||
return (errno); | return (errno); | ||||
} | } | ||||
if (cc < 4) | if (cc < 4) | ||||
return (EBADRPC); | return (EBADRPC); | ||||
if (repl->errno) | if (repl->errno) | ||||
return (ntohl(repl->errno)); | return (ntohl(repl->errno)); | ||||
bcopy(repl->fh, fhp, sizeof(repl->fh)); | bcopy(repl->fh, fhp, sizeof(repl->fh)); | ||||
/* | set_nfs_read_size(); | ||||
* Improve boot performance over NFS | |||||
*/ | |||||
if (getenv("nfs.read_size") != NULL) | |||||
nfs_read_size = strtol(getenv("nfs.read_size"), NULL, 0); | |||||
if (nfs_read_size < NFSREAD_MIN_SIZE) | |||||
nfs_read_size = NFSREAD_MIN_SIZE; | |||||
if (nfs_read_size > NFSREAD_MAX_SIZE) | |||||
nfs_read_size = NFSREAD_MAX_SIZE; | |||||
return (0); | return (0); | ||||
} | } | ||||
/* | /* | ||||
* Lookup a file. Store handle and attributes. | * Lookup a file. Store handle and attributes. | ||||
* Return zero or error number. | * Return zero or error number. | ||||
*/ | */ | ||||
int | int | ||||
▲ Show 20 Lines • Show All 590 Lines • ▼ Show 20 Lines | if (cc == -1) | ||||
/* errno was set by rpc_call */ | /* errno was set by rpc_call */ | ||||
return (errno); | return (errno); | ||||
if (cc < 2 * sizeof (uint32_t)) | if (cc < 2 * sizeof (uint32_t)) | ||||
return (EBADRPC); | return (EBADRPC); | ||||
if (repl->errno != 0) | if (repl->errno != 0) | ||||
return (ntohl(repl->errno)); | return (ntohl(repl->errno)); | ||||
*fhlenp = ntohl(repl->fhsize); | *fhlenp = ntohl(repl->fhsize); | ||||
bcopy(repl->fh, fhp, *fhlenp); | bcopy(repl->fh, fhp, *fhlenp); | ||||
set_nfs_read_size(); | |||||
return (0); | return (0); | ||||
} | } | ||||
/* | /* | ||||
* Lookup a file. Store handle and attributes. | * Lookup a file. Store handle and attributes. | ||||
* Return zero or error number. | * Return zero or error number. | ||||
*/ | */ | ||||
int | int | ||||
▲ Show 20 Lines • Show All 600 Lines • Show Last 20 Lines |