diff options
Diffstat (limited to 'usr/src')
| -rw-r--r-- | usr/src/boot/Makefile.version | 2 | ||||
| -rw-r--r-- | usr/src/boot/lib/libstand/bootp.c | 12 | ||||
| -rw-r--r-- | usr/src/boot/lib/libstand/bootp.h | 8 | ||||
| -rw-r--r-- | usr/src/boot/lib/libstand/nfs.c | 675 | ||||
| -rw-r--r-- | usr/src/boot/lib/libstand/nfsv2.h | 43 | ||||
| -rw-r--r-- | usr/src/boot/sys/boot/common/part.c | 94 | ||||
| -rw-r--r-- | usr/src/boot/sys/boot/i386/libi386/pxe.c | 82 | ||||
| -rw-r--r-- | usr/src/cmd/vi/port/ex_temp.c | 24 |
8 files changed, 100 insertions, 840 deletions
diff --git a/usr/src/boot/Makefile.version b/usr/src/boot/Makefile.version index 0a3c013869..60ad7be601 100644 --- a/usr/src/boot/Makefile.version +++ b/usr/src/boot/Makefile.version @@ -33,4 +33,4 @@ LOADER_VERSION = 1.1 # Use date like formatting here, YYYY.MM.DD.XX, without leading zeroes. # The version is processed from left to right, the version number can only # be increased. -BOOT_VERSION = $(LOADER_VERSION)-2017.3.26.1 +BOOT_VERSION = $(LOADER_VERSION)-2017.3.29.1 diff --git a/usr/src/boot/lib/libstand/bootp.c b/usr/src/boot/lib/libstand/bootp.c index d1d4378bab..effe074dce 100644 --- a/usr/src/boot/lib/libstand/bootp.c +++ b/usr/src/boot/lib/libstand/bootp.c @@ -36,7 +36,6 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); #include <sys/types.h> #include <sys/limits.h> @@ -336,6 +335,17 @@ bad: return (-1); } +int +dhcp_try_rfc1048(uint8_t *cp, size_t len) +{ + + expected_dhcpmsgtype = DHCPACK; + if (bcmp(vm_rfc1048, cp, sizeof (vm_rfc1048)) == 0) { + return (vend_rfc1048(cp, len)); + } + return (-1); +} + static int vend_rfc1048(u_char *cp, u_int len) { diff --git a/usr/src/boot/lib/libstand/bootp.h b/usr/src/boot/lib/libstand/bootp.h index bdafefd8d2..6ed7032c0e 100644 --- a/usr/src/boot/lib/libstand/bootp.h +++ b/usr/src/boot/lib/libstand/bootp.h @@ -18,10 +18,10 @@ * University. Carnegie Mellon makes no representations about the * suitability of this software for any purpose. It is provided "as is" * without express or implied warranty. - * - * $FreeBSD$ */ +#ifndef _BOOTP_H_ +#define _BOOTP_H_ struct bootp { unsigned char bp_op; /* packet opcode type */ @@ -145,3 +145,7 @@ struct cmu_vend { /* v_flags values */ #define VF_SMASK 1 /* Subnet mask field contains valid data */ + +int dhcp_try_rfc1048(uint8_t *cp, size_t len); + +#endif /* _BOOTP_H_ */ diff --git a/usr/src/boot/lib/libstand/nfs.c b/usr/src/boot/lib/libstand/nfs.c index d6b129adf2..e97449183c 100644 --- a/usr/src/boot/lib/libstand/nfs.c +++ b/usr/src/boot/lib/libstand/nfs.c @@ -53,73 +53,6 @@ #define NFSREAD_MIN_SIZE 1024 #define NFSREAD_MAX_SIZE 4096 -/* Define our own NFS attributes without NQNFS stuff. */ -#ifdef OLD_NFSV2 -struct nfsv2_fattrs { - n_long fa_type; - n_long fa_mode; - n_long fa_nlink; - n_long fa_uid; - n_long fa_gid; - n_long fa_size; - n_long fa_blocksize; - n_long fa_rdev; - n_long fa_blocks; - n_long fa_fsid; - n_long fa_fileid; - struct nfsv2_time fa_atime; - struct nfsv2_time fa_mtime; - struct nfsv2_time fa_ctime; -}; - -struct nfs_read_args { - u_char fh[NFS_FHSIZE]; - n_long off; - n_long len; - n_long xxx; /* XXX what's this for? */ -}; - -/* Data part of nfs rpc reply (also the largest thing we receive) */ -struct nfs_read_repl { - n_long errno; - struct nfsv2_fattrs fa; - n_long count; - u_char data[NFSREAD_MAX_SIZE]; -}; - -#ifndef NFS_NOSYMLINK -struct nfs_readlnk_repl { - n_long errno; - n_long len; - char path[NFS_MAXPATHLEN]; -}; -#endif - -struct nfs_readdir_args { - u_char fh[NFS_FHSIZE]; - n_long cookie; - n_long count; -}; - -struct nfs_readdir_data { - n_long fileid; - n_long len; - char name[0]; -}; - -struct nfs_readdir_off { - n_long cookie; - n_long follows; -}; - -struct nfs_iodesc { - struct iodesc *iodesc; - off_t off; - u_char fh[NFS_FHSIZE]; - struct nfsv2_fattrs fa; /* all in network order */ -}; -#else /* !OLD_NFSV2 */ - /* NFSv3 definitions */ #define NFS_V3MAXFHSIZE 64 #define NFS_VER3 3 @@ -184,7 +117,6 @@ struct nfs_iodesc { struct nfsv3_fattrs fa; /* all in network order */ uint64_t cookie; }; -#endif /* OLD_NFSV2 */ /* * XXX interactions with tftp? See nfswrapper.c for a confusing @@ -245,612 +177,6 @@ set_nfs_read_size(void) setenv("nfs.read_size", buf, 1); } -#ifdef OLD_NFSV2 -/* - * Fetch the root file handle (call mount daemon) - * Return zero or error number. - */ -int -nfs_getrootfh(struct iodesc *d, char *path, u_char *fhp) -{ - int len; - struct args { - n_long len; - char path[FNAME_SIZE]; - } *args; - struct repl { - n_long errno; - u_char fh[NFS_FHSIZE]; - } *repl; - struct { - n_long h[RPC_HEADER_WORDS]; - struct args d; - } sdata; - struct { - n_long h[RPC_HEADER_WORDS]; - struct repl d; - } rdata; - size_t cc; - -#ifdef NFS_DEBUG - if (debug) - printf("nfs_getrootfh: %s\n", path); -#endif - - args = &sdata.d; - repl = &rdata.d; - - bzero(args, sizeof(*args)); - len = strlen(path); - if (len > sizeof(args->path)) - len = sizeof(args->path); - args->len = htonl(len); - bcopy(path, args->path, len); - len = 4 + roundup(len, 4); - - cc = rpc_call(d, RPCPROG_MNT, RPCMNT_VER1, RPCMNT_MOUNT, - args, len, repl, sizeof(*repl)); - if (cc == -1) { - /* errno was set by rpc_call */ - return (errno); - } - if (cc < 4) - return (EBADRPC); - if (repl->errno) - return (ntohl(repl->errno)); - bcopy(repl->fh, fhp, sizeof(repl->fh)); - - set_nfs_read_size(); - return (0); -} - -/* - * Lookup a file. Store handle and attributes. - * Return zero or error number. - */ -int -nfs_lookupfh(struct nfs_iodesc *d, const char *name, struct nfs_iodesc *newfd) -{ - int len, rlen; - struct args { - u_char fh[NFS_FHSIZE]; - n_long len; - char name[FNAME_SIZE]; - } *args; - struct repl { - n_long errno; - u_char fh[NFS_FHSIZE]; - struct nfsv2_fattrs fa; - } *repl; - struct { - n_long h[RPC_HEADER_WORDS]; - struct args d; - } sdata; - struct { - n_long h[RPC_HEADER_WORDS]; - struct repl d; - } rdata; - ssize_t cc; - -#ifdef NFS_DEBUG - if (debug) - printf("lookupfh: called\n"); -#endif - - args = &sdata.d; - repl = &rdata.d; - - bzero(args, sizeof(*args)); - bcopy(d->fh, args->fh, sizeof(args->fh)); - len = strlen(name); - if (len > sizeof(args->name)) - len = sizeof(args->name); - bcopy(name, args->name, len); - args->len = htonl(len); - len = 4 + roundup(len, 4); - len += NFS_FHSIZE; - - rlen = sizeof(*repl); - - cc = rpc_call(d->iodesc, NFS_PROG, NFS_VER2, NFSPROC_LOOKUP, - args, len, repl, rlen); - if (cc == -1) - return (errno); /* XXX - from rpc_call */ - if (cc < 4) - return (EIO); - if (repl->errno) { - /* saerrno.h now matches NFS error numbers. */ - return (ntohl(repl->errno)); - } - bcopy( repl->fh, &newfd->fh, sizeof(newfd->fh)); - bcopy(&repl->fa, &newfd->fa, sizeof(newfd->fa)); - return (0); -} - -#ifndef NFS_NOSYMLINK -/* - * Get the destination of a symbolic link. - */ -int -nfs_readlink(struct nfs_iodesc *d, char *buf) -{ - struct { - n_long h[RPC_HEADER_WORDS]; - u_char fh[NFS_FHSIZE]; - } sdata; - struct { - n_long h[RPC_HEADER_WORDS]; - struct nfs_readlnk_repl d; - } rdata; - ssize_t cc; - -#ifdef NFS_DEBUG - if (debug) - printf("readlink: called\n"); -#endif - - bcopy(d->fh, sdata.fh, NFS_FHSIZE); - cc = rpc_call(d->iodesc, NFS_PROG, NFS_VER2, NFSPROC_READLINK, - sdata.fh, NFS_FHSIZE, - &rdata.d, sizeof(rdata.d)); - if (cc == -1) - return (errno); - - if (cc < 4) - return (EIO); - - if (rdata.d.errno) - return (ntohl(rdata.d.errno)); - - rdata.d.len = ntohl(rdata.d.len); - if (rdata.d.len > NFS_MAXPATHLEN) - return (ENAMETOOLONG); - - bcopy(rdata.d.path, buf, rdata.d.len); - buf[rdata.d.len] = 0; - return (0); -} -#endif - -/* - * Read data from a file. - * Return transfer count or -1 (and set errno) - */ -ssize_t -nfs_readdata(struct nfs_iodesc *d, off_t off, void *addr, size_t len) -{ - struct nfs_read_args *args; - struct nfs_read_repl *repl; - struct { - n_long h[RPC_HEADER_WORDS]; - struct nfs_read_args d; - } sdata; - struct { - n_long h[RPC_HEADER_WORDS]; - struct nfs_read_repl d; - } rdata; - size_t cc; - long x; - int hlen, rlen; - - args = &sdata.d; - repl = &rdata.d; - - bcopy(d->fh, args->fh, NFS_FHSIZE); - args->off = htonl((n_long)off); - if (len > nfs_read_size) - len = nfs_read_size; - args->len = htonl((n_long)len); - args->xxx = htonl((n_long)0); - hlen = offsetof(struct nfs_read_rpl, data[0]); - - cc = rpc_call(d->iodesc, NFS_PROG, NFS_VER2, NFSPROC_READ, - args, sizeof(*args), - repl, sizeof(*repl)); - if (cc == -1) { - /* errno was already set by rpc_call */ - return (-1); - } - if (cc < hlen) { - errno = EBADRPC; - return (-1); - } - if (repl->errno) { - errno = ntohl(repl->errno); - return (-1); - } - rlen = cc - hlen; - x = ntohl(repl->count); - if (rlen < x) { - printf("nfsread: short packet, %d < %ld\n", rlen, x); - errno = EBADRPC; - return(-1); - } - bcopy(repl->data, addr, x); - return (x); -} - -/* - * Open a file. - * return zero or error number - */ -int -nfs_open(const char *upath, struct open_file *f) -{ - struct iodesc *desc; - struct nfs_iodesc *currfd; - char buf[2 * NFS_FHSIZE + 3]; - u_char *fh; - char *cp; - int i; -#ifndef NFS_NOSYMLINK - struct nfs_iodesc *newfd; - struct nfsv2_fattrs *fa; - char *ncp; - int c; - char namebuf[NFS_MAXPATHLEN + 1]; - char linkbuf[NFS_MAXPATHLEN + 1]; - int nlinks = 0; -#endif - int error; - char *path; - - if (netproto != NET_NFS) - return (EINVAL); - -#ifdef NFS_DEBUG - if (debug) - printf("nfs_open: %s (rootpath=%s)\n", upath, rootpath); -#endif - if (!rootpath[0]) { - printf("no rootpath, no nfs\n"); - return (ENXIO); - } - - /* - * This is silly - we should look at dv_type but that value is - * arch dependant and we can't use it here. - */ -#ifndef __i386__ - if (strcmp(f->f_dev->dv_name, "net") != 0) - return(EINVAL); -#else - if (strcmp(f->f_dev->dv_name, "pxe") != 0) - return(EINVAL); -#endif - - if (!(desc = socktodesc(*(int *)(f->f_devdata)))) - return(EINVAL); - - /* Bind to a reserved port. */ - desc->myport = htons(--rpc_port); - desc->destip = rootip; - if ((error = nfs_getrootfh(desc, rootpath, nfs_root_node.fh))) - return (error); - nfs_root_node.fa.fa_type = htonl(NFDIR); - nfs_root_node.fa.fa_mode = htonl(0755); - nfs_root_node.fa.fa_nlink = htonl(2); - nfs_root_node.iodesc = desc; - - fh = &nfs_root_node.fh[0]; - buf[0] = 'X'; - cp = &buf[1]; - for (i = 0; i < NFS_FHSIZE; i++, cp += 2) - sprintf(cp, "%02x", fh[i]); - sprintf(cp, "X"); - setenv("boot.nfsroot.server", inet_ntoa(rootip), 1); - setenv("boot.nfsroot.path", rootpath, 1); - setenv("boot.nfsroot.nfshandle", buf, 1); - - /* Allocate file system specific data structure */ - currfd = malloc(sizeof(*newfd)); - if (currfd == NULL) { - error = ENOMEM; - goto out; - } - -#ifndef NFS_NOSYMLINK - bcopy(&nfs_root_node, currfd, sizeof(*currfd)); - newfd = NULL; - - cp = path = strdup(upath); - if (path == NULL) { - error = ENOMEM; - goto out; - } - while (*cp) { - /* - * Remove extra separators - */ - while (*cp == '/') - cp++; - - if (*cp == '\0') - break; - /* - * Check that current node is a directory. - */ - if (currfd->fa.fa_type != htonl(NFDIR)) { - error = ENOTDIR; - goto out; - } - - /* allocate file system specific data structure */ - newfd = malloc(sizeof(*newfd)); - newfd->iodesc = currfd->iodesc; - - /* - * Get next component of path name. - */ - { - int len = 0; - - ncp = cp; - while ((c = *cp) != '\0' && c != '/') { - if (++len > NFS_MAXNAMLEN) { - error = ENOENT; - goto out; - } - cp++; - } - *cp = '\0'; - } - - /* lookup a file handle */ - error = nfs_lookupfh(currfd, ncp, newfd); - *cp = c; - if (error) - goto out; - - /* - * Check for symbolic link - */ - if (newfd->fa.fa_type == htonl(NFLNK)) { - int link_len, len; - - error = nfs_readlink(newfd, linkbuf); - if (error) - goto out; - - link_len = strlen(linkbuf); - len = strlen(cp); - - if (link_len + len > MAXPATHLEN - || ++nlinks > MAXSYMLINKS) { - error = ENOENT; - goto out; - } - - bcopy(cp, &namebuf[link_len], len + 1); - bcopy(linkbuf, namebuf, link_len); - - /* - * If absolute pathname, restart at root. - * If relative pathname, restart at parent directory. - */ - cp = namebuf; - if (*cp == '/') - bcopy(&nfs_root_node, currfd, sizeof(*currfd)); - - free(newfd); - newfd = NULL; - - continue; - } - - free(currfd); - currfd = newfd; - newfd = NULL; - } - - error = 0; - -out: - free(newfd); - free(path); -#else - currfd->iodesc = desc; - - error = nfs_lookupfh(&nfs_root_node, upath, currfd); -#endif - if (!error) { - currfd->off = 0; - f->f_fsdata = (void *)currfd; - return (0); - } - -#ifdef NFS_DEBUG - if (debug) - printf("nfs_open: %s lookupfh failed: %s\n", - path, strerror(error)); -#endif - free(currfd); - - return (error); -} - -int -nfs_close(struct open_file *f) -{ - struct nfs_iodesc *fp = (struct nfs_iodesc *)f->f_fsdata; - -#ifdef NFS_DEBUG - if (debug) - printf("nfs_close: fp=0x%lx\n", (u_long)fp); -#endif - - if (fp) - free(fp); - f->f_fsdata = (void *)0; - - return (0); -} - -/* - * read a portion of a file - */ -int -nfs_read(struct open_file *f, void *buf, size_t size, size_t *resid) -{ - struct nfs_iodesc *fp = (struct nfs_iodesc *)f->f_fsdata; - ssize_t cc; - char *addr = buf; - -#ifdef NFS_DEBUG - if (debug) - printf("nfs_read: size=%lu off=%d\n", (u_long)size, - (int)fp->off); -#endif - while ((int)size > 0) { - twiddle(16); - cc = nfs_readdata(fp, fp->off, (void *)addr, size); - /* XXX maybe should retry on certain errors */ - if (cc == -1) { -#ifdef NFS_DEBUG - if (debug) - printf("nfs_read: read: %s", strerror(errno)); -#endif - return (errno); /* XXX - from nfs_readdata */ - } - if (cc == 0) { -#ifdef NFS_DEBUG - if (debug) - printf("nfs_read: hit EOF unexpectantly"); -#endif - goto ret; - } - fp->off += cc; - addr += cc; - size -= cc; - } -ret: - if (resid) - *resid = size; - - return (0); -} - -/* - * Not implemented. - */ -int -nfs_write(struct open_file *f, void *buf, size_t size, size_t *resid) -{ - return (EROFS); -} - -off_t -nfs_seek(struct open_file *f, off_t offset, int where) -{ - struct nfs_iodesc *d = (struct nfs_iodesc *)f->f_fsdata; - n_long size = ntohl(d->fa.fa_size); - - switch (where) { - case SEEK_SET: - d->off = offset; - break; - case SEEK_CUR: - d->off += offset; - break; - case SEEK_END: - d->off = size - offset; - break; - default: - errno = EINVAL; - return (-1); - } - - return (d->off); -} - -/* NFNON=0, NFREG=1, NFDIR=2, NFBLK=3, NFCHR=4, NFLNK=5 */ -int nfs_stat_types[8] = { - 0, S_IFREG, S_IFDIR, S_IFBLK, S_IFCHR, S_IFLNK, 0 }; - -int -nfs_stat(struct open_file *f, struct stat *sb) -{ - struct nfs_iodesc *fp = (struct nfs_iodesc *)f->f_fsdata; - n_long ftype, mode; - - ftype = ntohl(fp->fa.fa_type); - mode = ntohl(fp->fa.fa_mode); - mode |= nfs_stat_types[ftype & 7]; - - sb->st_mode = mode; - sb->st_nlink = ntohl(fp->fa.fa_nlink); - sb->st_uid = ntohl(fp->fa.fa_uid); - sb->st_gid = ntohl(fp->fa.fa_gid); - sb->st_size = ntohl(fp->fa.fa_size); - - return (0); -} - -static int -nfs_readdir(struct open_file *f, struct dirent *d) -{ - struct nfs_iodesc *fp = (struct nfs_iodesc *)f->f_fsdata; - struct nfs_readdir_args *args; - struct nfs_readdir_data *rd; - struct nfs_readdir_off *roff = NULL; - static char *buf; - static struct nfs_iodesc *pfp = NULL; - static n_long cookie = 0; - size_t cc; - n_long eof; - - struct { - n_long h[RPC_HEADER_WORDS]; - struct nfs_readdir_args d; - } sdata; - static struct { - n_long h[RPC_HEADER_WORDS]; - u_char d[NFS_READDIRSIZE]; - } rdata; - - if (fp != pfp || fp->off != cookie) { - pfp = NULL; - refill: - args = &sdata.d; - bzero(args, sizeof(*args)); - - bcopy(fp->fh, args->fh, NFS_FHSIZE); - args->cookie = htonl(fp->off); - args->count = htonl(NFS_READDIRSIZE); - - cc = rpc_call(fp->iodesc, NFS_PROG, NFS_VER2, NFSPROC_READDIR, - args, sizeof(*args), - rdata.d, sizeof(rdata.d)); - buf = rdata.d; - roff = (struct nfs_readdir_off *)buf; - if (ntohl(roff->cookie) != 0) - return EIO; - pfp = fp; - cookie = fp->off; - } - roff = (struct nfs_readdir_off *)buf; - - if (ntohl(roff->follows) == 0) { - eof = ntohl((roff+1)->cookie); - if (eof) { - cookie = 0; - return ENOENT; - } - goto refill; - } - - buf += sizeof(struct nfs_readdir_off); - rd = (struct nfs_readdir_data *)buf; - d->d_namlen = ntohl(rd->len); - bcopy(rd->name, d->d_name, d->d_namlen); - d->d_name[d->d_namlen] = '\0'; - - buf += (sizeof(struct nfs_readdir_data) + roundup(htonl(rd->len),4)); - roff = (struct nfs_readdir_off *)buf; - fp->off = cookie = ntohl(roff->cookie); - return 0; -} -#else /* !OLD_NFSV2 */ /* * Fetch the root file handle (call mount daemon) * Return zero or error number. @@ -1516,4 +842,3 @@ nfs_readdir(struct open_file *f, struct dirent *d) buf = (u_char *)&rent->nameplus[pos]; return (0); } -#endif /* OLD_NFSV2 */ diff --git a/usr/src/boot/lib/libstand/nfsv2.h b/usr/src/boot/lib/libstand/nfsv2.h index a6f1c4f770..184a47bd04 100644 --- a/usr/src/boot/lib/libstand/nfsv2.h +++ b/usr/src/boot/lib/libstand/nfsv2.h @@ -119,46 +119,3 @@ typedef enum { NFCHR=4, NFLNK=5 } nfstype; - -/* Structs for common parts of the rpc's */ -struct nfsv2_time { - n_long nfs_sec; - n_long nfs_usec; -}; - -/* - * File attributes and setable attributes. - */ -struct nfsv2_fattr { - n_long fa_type; - n_long fa_mode; - n_long fa_nlink; - n_long fa_uid; - n_long fa_gid; - n_long fa_size; - n_long fa_blocksize; - n_long fa_rdev; - n_long fa_blocks; - n_long fa_fsid; - n_long fa_fileid; - struct nfsv2_time fa_atime; - struct nfsv2_time fa_mtime; - struct nfsv2_time fa_ctime; -}; - -struct nfsv2_sattr { - n_long sa_mode; - n_long sa_uid; - n_long sa_gid; - n_long sa_size; - struct nfsv2_time sa_atime; - struct nfsv2_time sa_mtime; -}; - -struct nfsv2_statfs { - n_long sf_tsize; - n_long sf_bsize; - n_long sf_blocks; - n_long sf_bfree; - n_long sf_bavail; -}; diff --git a/usr/src/boot/sys/boot/common/part.c b/usr/src/boot/sys/boot/common/part.c index 5f79473b0c..8366c88234 100644 --- a/usr/src/boot/sys/boot/common/part.c +++ b/usr/src/boot/sys/boot/common/part.c @@ -1,4 +1,4 @@ -/*- +/* * Copyright (c) 2012 Andrey V. Elsukov <ae@FreeBSD.org> * All rights reserved. * @@ -25,7 +25,6 @@ */ #include <sys/cdefs.h> -__FBSDID("$FreeBSD$"); #include <stand.h> #include <sys/param.h> @@ -42,7 +41,7 @@ __FBSDID("$FreeBSD$"); #include <uuid.h> #ifdef PART_DEBUG -#define DEBUG(fmt, args...) printf("%s: " fmt "\n" , __func__ , ## args) +#define DEBUG(fmt, args...) printf("%s: " fmt "\n", __func__, ## args) #else #define DEBUG(fmt, args...) #endif @@ -169,13 +168,13 @@ gpt_parttype(uuid_t type) return (PART_UNKNOWN); } -static struct gpt_hdr* +static struct gpt_hdr * gpt_checkhdr(struct gpt_hdr *hdr, uint64_t lba_self, uint64_t lba_last __attribute((unused)), uint16_t sectorsize) { uint32_t sz, crc; - if (memcmp(hdr->hdr_sig, GPT_HDR_SIG, sizeof(hdr->hdr_sig)) != 0) { + if (memcmp(hdr->hdr_sig, GPT_HDR_SIG, sizeof (hdr->hdr_sig)) != 0) { DEBUG("no GPT signature"); return (NULL); } @@ -209,7 +208,7 @@ gpt_checkhdr(struct gpt_hdr *hdr, uint64_t lba_self, hdr->hdr_entries = le32toh(hdr->hdr_entries); hdr->hdr_entsz = le32toh(hdr->hdr_entsz); if (hdr->hdr_entries == 0 || - hdr->hdr_entsz < sizeof(struct gpt_ent) || + hdr->hdr_entsz < sizeof (struct gpt_ent) || sectorsize % hdr->hdr_entsz != 0) { DEBUG("invalid entry size or number of entries"); return (NULL); @@ -223,7 +222,7 @@ gpt_checkhdr(struct gpt_hdr *hdr, uint64_t lba_self, } static int -gpt_checktbl(const struct gpt_hdr *hdr, u_char *tbl, size_t size, +gpt_checktbl(const struct gpt_hdr *hdr, uint8_t *tbl, size_t size, uint64_t lba_last __attribute((unused))) { struct gpt_ent *ent; @@ -250,13 +249,13 @@ gpt_checktbl(const struct gpt_hdr *hdr, u_char *tbl, size_t size, return (0); } -static struct ptable* +static struct ptable * ptable_gptread(struct ptable *table, void *dev, diskread_t dread) { struct pentry *entry; struct gpt_hdr *phdr, hdr; struct gpt_ent *ent; - u_char *buf, *tbl; + uint8_t *buf, *tbl; uint64_t offset; int pri, sec; size_t size, i; @@ -286,7 +285,7 @@ ptable_gptread(struct ptable *table, void *dev, diskread_t dread) if (dread(dev, tbl, size, phdr->hdr_lba_table) == 0 && gpt_checktbl(phdr, tbl, size * table->sectorsize, table->sectors - 1) == 0) { - memcpy(&hdr, phdr, sizeof(hdr)); + memcpy(&hdr, phdr, sizeof (hdr)); pri = 1; } } @@ -320,7 +319,7 @@ ptable_gptread(struct ptable *table, void *dev, diskread_t dread) if (dread(dev, tbl, size, phdr->hdr_lba_table) == 0 && gpt_checktbl(phdr, tbl, size * table->sectorsize, table->sectors - 1) == 0) { - memcpy(&hdr, phdr, sizeof(hdr)); + memcpy(&hdr, phdr, sizeof (hdr)); sec = 1; } } @@ -357,7 +356,7 @@ ptable_gptread(struct ptable *table, void *dev, diskread_t dread) ent->ent_lba_start > ent->ent_lba_end) continue; - entry = malloc(sizeof(*entry)); + entry = malloc(sizeof (*entry)); if (entry == NULL) break; entry->part.start = ent->ent_lba_start; @@ -365,7 +364,7 @@ ptable_gptread(struct ptable *table, void *dev, diskread_t dread) entry->part.index = i + 1; entry->part.type = gpt_parttype(ent->ent_type); entry->flags = le64toh(ent->ent_attr); - memcpy(&entry->type.gpt, &ent->ent_type, sizeof(uuid_t)); + memcpy(&entry->type.gpt, &ent->ent_type, sizeof (uuid_t)); STAILQ_INSERT_TAIL(&table->entries, entry, entry); DEBUG("new GPT partition added"); } @@ -404,13 +403,13 @@ mbr_parttype(uint8_t type) return (PART_UNKNOWN); } -static struct ptable* +static struct ptable * ptable_ebrread(struct ptable *table, void *dev, diskread_t dread) { struct dos_partition *dp; struct pentry *e1, *entry; uint32_t start, end, offset; - u_char *buf; + uint8_t *buf; int i, idx; STAILQ_FOREACH(e1, &table->entries, entry) { @@ -443,7 +442,7 @@ ptable_ebrread(struct ptable *table, void *dev, diskread_t dread) continue; } end = le32toh(dp[0].dp_size); - entry = malloc(sizeof(*entry)); + entry = malloc(sizeof (*entry)); if (entry == NULL) break; entry->part.start = offset + start; @@ -482,17 +481,17 @@ bsd_parttype(uint8_t type) return (PART_UNKNOWN); } -static struct ptable* +static struct ptable * ptable_bsdread(struct ptable *table, void *dev, diskread_t dread) { struct disklabel *dl; struct partition *part; struct pentry *entry; - u_char *buf; + uint8_t *buf; uint32_t raw_offset; int i; - if (table->sectorsize < sizeof(struct disklabel)) { + if (table->sectorsize < sizeof (struct disklabel)) { DEBUG("Too small sectorsize"); return (table); } @@ -526,7 +525,7 @@ ptable_bsdread(struct ptable *table, void *dev, diskread_t dread) continue; if (part->p_size == 0) continue; - entry = malloc(sizeof(*entry)); + entry = malloc(sizeof (*entry)); if (entry == NULL) break; entry->part.start = le32toh(part->p_offset) - raw_offset; @@ -564,16 +563,16 @@ vtoc8_parttype(uint16_t type) return (PART_UNKNOWN); } -static struct ptable* +static struct ptable * ptable_vtoc8read(struct ptable *table, void *dev, diskread_t dread) { struct pentry *entry; struct vtoc8 *dl; - u_char *buf; + uint8_t *buf; uint16_t sum, heads, sectors; int i; - if (table->sectorsize != sizeof(struct vtoc8)) + if (table->sectorsize != sizeof (struct vtoc8)) return (table); buf = malloc(table->sectorsize); if (buf == NULL) @@ -586,7 +585,7 @@ ptable_vtoc8read(struct ptable *table, void *dev, diskread_t dread) } dl = (struct vtoc8 *)buf; /* Check the sum */ - for (i = sum = 0; i < sizeof(struct vtoc8); i += sizeof(sum)) + for (i = sum = 0; i < sizeof (struct vtoc8); i += sizeof (sum)) sum ^= be16dec(buf + i); if (sum != 0) { DEBUG("incorrect checksum"); @@ -608,7 +607,7 @@ ptable_vtoc8read(struct ptable *table, void *dev, diskread_t dread) if (i == VTOC_RAW_PART || dl->part[i].tag == VTOC_TAG_UNASSIGNED) continue; - entry = malloc(sizeof(*entry)); + entry = malloc(sizeof (*entry)); if (entry == NULL) break; entry->part.start = be32toh(dl->map[i].cyl) * heads * sectors; @@ -652,16 +651,16 @@ vtoc_parttype(uint16_t type) return (PART_UNKNOWN); } -static struct ptable* +static struct ptable * ptable_dklabelread(struct ptable *table, void *dev, diskread_t dread) { struct pentry *entry; struct dk_label *dl; struct dk_vtoc *dv; - u_char *buf; + uint8_t *buf; int i; - if (table->sectorsize < sizeof(struct dk_label)) { + if (table->sectorsize < sizeof (struct dk_label)) { DEBUG("Too small sectorsize"); return (table); } @@ -694,7 +693,7 @@ ptable_dklabelread(struct ptable *table, void *dev, diskread_t dread) if (i == VTOC_RAW_PART || /* skip slice 2 and empty */ dv->v_part[i].p_size == 0) continue; - entry = malloc(sizeof(*entry)); + entry = malloc(sizeof (*entry)); if (entry == NULL) break; entry->part.start = dv->v_part[i].p_start; @@ -712,12 +711,12 @@ out: return (table); } -struct ptable* +struct ptable * ptable_open(void *dev, uint64_t sectors, uint16_t sectorsize, diskread_t *dread) { struct dos_partition *dp; struct ptable *table; - u_char *buf; + uint8_t *buf; int i, count; #ifdef LOADER_MBR_SUPPORT struct pentry *entry; @@ -734,7 +733,7 @@ ptable_open(void *dev, uint64_t sectors, uint16_t sectorsize, diskread_t *dread) goto out; } - table = malloc(sizeof(*table)); + table = malloc(sizeof (*table)); if (table == NULL) goto out; table->sectors = sectors; @@ -798,8 +797,9 @@ ptable_open(void *dev, uint64_t sectors, uint16_t sectorsize, diskread_t *dread) if (dp[1].dp_typ != DOSPTYP_HFS) { table->type = PTABLE_NONE; DEBUG("Incorrect PMBR, ignore it"); - } else + } else { DEBUG("Bootcamp detected"); + } } #ifdef LOADER_GPT_SUPPORT if (table->type == PTABLE_GPT) { @@ -825,7 +825,7 @@ ptable_open(void *dev, uint64_t sectors, uint16_t sectorsize, diskread_t *dread) if (dp[i].dp_typ == DOSPTYP_EXT || dp[i].dp_typ == DOSPTYP_EXTLBA) has_ext = 1; - entry = malloc(sizeof(*entry)); + entry = malloc(sizeof (*entry)); if (entry == NULL) break; entry->part.start = start; @@ -892,7 +892,7 @@ ptable_getpart(const struct ptable *table, struct ptable_entry *part, int idx) STAILQ_FOREACH(entry, &table->entries, entry) { if (entry->part.index != idx) continue; - memcpy(part, &entry->part, sizeof(*part)); + memcpy(part, &entry->part, sizeof (*part)); return (0); } return (ENOENT); @@ -908,14 +908,14 @@ ptable_getpart(const struct ptable *table, struct ptable_entry *part, int idx) * 5: Active FAT/FAT32 slice * 6: non-active FAT/FAT32 slice */ -#define PREF_RAWDISK 0 -#define PREF_ILLUMOS_ACT 1 -#define PREF_ILLUMOS 2 -#define PREF_LINUX_ACT 3 -#define PREF_LINUX 4 -#define PREF_DOS_ACT 5 -#define PREF_DOS 6 -#define PREF_NONE 7 +#define PREF_RAWDISK 0 +#define PREF_ILLUMOS_ACT 1 +#define PREF_ILLUMOS 2 +#define PREF_LINUX_ACT 3 +#define PREF_LINUX 4 +#define PREF_DOS_ACT 5 +#define PREF_DOS 6 +#define PREF_NONE 7 int ptable_getbestpart(const struct ptable *table, struct ptable_entry *part) { @@ -969,7 +969,7 @@ ptable_getbestpart(const struct ptable *table, struct ptable_entry *part) } } if (best != NULL) { - memcpy(part, &best->part, sizeof(*part)); + memcpy(part, &best->part, sizeof (*part)); return (0); } return (ENOENT); @@ -999,16 +999,16 @@ ptable_iterate(const struct ptable *table, void *arg, ptable_iterate_t *iter) #endif #ifdef LOADER_VTOC8_SUPPORT if (table->type == PTABLE_VTOC8) - sprintf(name, "%c", (u_char) 'a' + + sprintf(name, "%c", (uint8_t)'a' + entry->part.index); else #endif if (table->type == PTABLE_VTOC) - sprintf(name, "%c", (u_char) 'a' + + sprintf(name, "%c", (uint8_t)'a' + entry->part.index); else if (table->type == PTABLE_BSD) - sprintf(name, "%c", (u_char) 'a' + + sprintf(name, "%c", (uint8_t)'a' + entry->part.index); ret = iter(arg, name, &entry->part); if (ret != 0) diff --git a/usr/src/boot/sys/boot/i386/libi386/pxe.c b/usr/src/boot/sys/boot/i386/libi386/pxe.c index 0d579f658d..59d0cb5b30 100644 --- a/usr/src/boot/sys/boot/i386/libi386/pxe.c +++ b/usr/src/boot/sys/boot/i386/libi386/pxe.c @@ -87,11 +87,7 @@ static int pxe_netif_get(struct iodesc *desc, void *pkt, size_t len, static int pxe_netif_put(struct iodesc *desc, void *pkt, size_t len); static void pxe_netif_end(struct netif *nif); -#ifdef OLD_NFSV2 -int nfs_getrootfh(struct iodesc*, char*, u_char*); -#else int nfs_getrootfh(struct iodesc*, char*, uint32_t*, u_char*); -#endif extern struct netif_stats pxe_st[]; extern u_int16_t __bangpxeseg; @@ -100,6 +96,7 @@ extern void __bangpxeentry(void); extern u_int16_t __pxenvseg; extern u_int16_t __pxenvoff; extern void __pxenventry(void); +extern struct in_addr servip; struct netif_dif pxe_ifs[] = { /* dif_unit dif_nsel dif_stats dif_private */ @@ -260,7 +257,7 @@ pxe_open(struct open_file *f, ...) char temp[FNAME_SIZE]; int error = 0; int i; - + va_start(args, f); devname = va_arg(args, char*); va_end(args); @@ -276,17 +273,35 @@ pxe_open(struct open_file *f, ...) } if (pxe_debug) printf("pxe_open: netif_open() succeeded\n"); + if (socktodesc(pxe_sock) == NULL) { + printf("pxe_open: bad socket %d\n", pxe_sock); + return (ENXIO); + } } if (rootip.s_addr == 0) { /* - * Do a bootp/dhcp request to find out where our + * Try to extract the RFC1048 data from PXE. + * Otherwise do a bootp/dhcp request to find out where our * NFS/TFTP server is. Even if we dont get back * the proper information, fall back to the server * which brought us to life and a default rootpath. */ - bootp(pxe_sock, BOOTP_PXE); + if (dhcp_try_rfc1048(bootplayer.vendor.d, BOOTP_DHCPVEND) < 0) { + if (pxe_debug) + printf("pxe_open: no RFC1048 data in PXE Cache\n"); + bootp(pxe_sock, BOOTP_PXE); + } else if (pxe_debug) { + printf("pxe_open: loaded RFC1048 data from PXE Cache\n"); + } + if (rootip.s_addr == 0) rootip.s_addr = bootplayer.sip; + if (gateip.s_addr == 0) + gateip.s_addr = bootplayer.gip; + if (myip.s_addr == 0) + myip.s_addr = bootplayer.yip; + if (servip.s_addr == 0) + servip = rootip; netproto = NET_NFS; if (tftpip.s_addr != 0) { @@ -324,6 +339,9 @@ pxe_open(struct open_file *f, ...) printf("pxe_open: server addr: %s\n", inet_ntoa(rootip)); printf("pxe_open: server path: %s\n", rootpath); printf("pxe_open: gateway ip: %s\n", inet_ntoa(gateip)); + printf("pxe_open: my ip: %s\n", inet_ntoa(myip)); + printf("pxe_open: netmask: %s\n", intoa(netmask)); + printf("pxe_open: servip: %s\n", inet_ntoa(servip)); if (netproto == NET_TFTP) { setenv("boot.tftproot.server", inet_ntoa(rootip), 1); @@ -437,55 +455,6 @@ pxe_perror(int err) * Reach inside the libstand NFS code and dig out an NFS handle * for the root filesystem. */ -#ifdef OLD_NFSV2 -struct nfs_iodesc { - struct iodesc *iodesc; - off_t off; - u_char fh[NFS_FHSIZE]; - /* structure truncated here */ -}; -extern struct nfs_iodesc nfs_root_node; -extern int rpc_port; - -static void -pxe_rpcmountcall() -{ - struct iodesc *d; - int error; - - if (!(d = socktodesc(pxe_sock))) - return; - d->myport = htons(--rpc_port); - d->destip = rootip; - if ((error = nfs_getrootfh(d, rootpath, nfs_root_node.fh)) != 0) - printf("NFS MOUNT RPC error: %d\n", error); - nfs_root_node.iodesc = d; -} - -static void -pxe_setnfshandle(char *rootpath) -{ - int i; - u_char *fh; - char buf[2 * NFS_FHSIZE + 3], *cp; - - /* - * If NFS files were never opened, we need to do mount call - * ourselves. Use nfs_root_node.iodesc as flag indicating - * previous NFS usage. - */ - if (nfs_root_node.iodesc == NULL) - pxe_rpcmountcall(); - - fh = &nfs_root_node.fh[0]; - buf[0] = 'X'; - cp = &buf[1]; - for (i = 0; i < NFS_FHSIZE; i++, cp += 2) - sprintf(cp, "%02x", fh[i]); - sprintf(cp, "X"); - setenv("boot.nfsroot.nfshandle", buf, 1); -} -#else /* !OLD_NFSV2 */ #define NFS_V3MAXFHSIZE 64 @@ -542,7 +511,6 @@ pxe_setnfshandle(char *rootpath) sprintf(buf, "%d", nfs_root_node.fhsize); setenv("boot.nfsroot.nfshandlelen", buf, 1); } -#endif /* OLD_NFSV2 */ void pxenv_call(int func) diff --git a/usr/src/cmd/vi/port/ex_temp.c b/usr/src/cmd/vi/port/ex_temp.c index fd061b83e3..95fcdbf2b6 100644 --- a/usr/src/cmd/vi/port/ex_temp.c +++ b/usr/src/cmd/vi/port/ex_temp.c @@ -209,9 +209,7 @@ int read(); int write(); unsigned char * -getblock(atl, iof) - line atl; - int iof; +getblock(line atl, int iof) { int bno, off; unsigned char *p1, *p2; @@ -250,10 +248,12 @@ getblock(atl, iof) if (iof == READ) { if (hitin2 == 0) { if (ichang2) { - if (xtflag) + if (xtflag) { if (run_crypt(0L, ibuff2, - CRSIZE, tperm) == -1) + CRSIZE, tperm) == -1) { filioerr(tfname); + } + } blkio(iblock2, ibuff2, write); } ichang2 = 0; @@ -395,8 +395,8 @@ synctmp(void) n = CRSIZE; while (n--) *p2++ = *p1++; - if (run_crypt(0L, crbuf, CRSIZE, tperm) == -1) - filioerr(tfname); + if (run_crypt(0L, crbuf, CRSIZE, tperm) == -1) + filioerr(tfname); blkio(oblock, crbuf, write); } else blkio(oblock, obuff, write); @@ -531,9 +531,8 @@ REGblk(void) return (0); } -struct strreg * -mapreg(c) - int c; +struct strreg * +mapreg(int c) { if (isupper(c)) @@ -753,10 +752,7 @@ rbflush(void) /* Register c to char buffer buf of size buflen */ void -regbuf(c, buf, buflen) -unsigned char c; -unsigned char *buf; -int buflen; +regbuf(unsigned char c, unsigned char *buf, int buflen) { unsigned char *p, *lp; |
