diff options
53 files changed, 1070 insertions, 2226 deletions
diff --git a/usr/src/cmd/Makefile.cmd b/usr/src/cmd/Makefile.cmd index b616d6a7ac..d346b79b74 100644 --- a/usr/src/cmd/Makefile.cmd +++ b/usr/src/cmd/Makefile.cmd @@ -162,6 +162,7 @@ ROOTPROG32= $(PROG:%=$(ROOTBIN32)/%) ROOTCMD64= $(PROG:%=$(ROOTCMDDIR64)/%) ROOTUSRSBINPROG32= $(PROG:%=$(ROOTUSRSBIN32)/%) ROOTUSRSBINPROG64= $(PROG:%=$(ROOTUSRSBIN64)/%) +ROOTLIBSVCBINPROG= $(PROG:%=$(ROOTLIBSVCBIN)/%) # Symlink rules for /usr/ccs/bin commands. Note, those commands under # the rule of the linker area, are controlled by a different set of diff --git a/usr/src/cmd/boot/scripts/boot-archive-update.ksh b/usr/src/cmd/boot/scripts/boot-archive-update.ksh index deae20e814..24810a22db 100644 --- a/usr/src/cmd/boot/scripts/boot-archive-update.ksh +++ b/usr/src/cmd/boot/scripts/boot-archive-update.ksh @@ -23,6 +23,7 @@ # Copyright 2010 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. # Copyright 2018 OmniOS Community Edition (OmniOSce) Association. +# Copyright 2021 Oxide Computer Company # . /lib/svc/share/smf_include.sh @@ -30,7 +31,14 @@ UPDATEFILE=/etc/svc/volatile/boot_archive_safefile_update -smf_is_globalzone || exit $SMF_EXIT_OK +if smf_is_nonglobalzone || smf_root_is_ramdisk; then + # + # Boot archives only exist in the global zone of persistent root + # systems, but this is either a non-global zone or a system booted from + # a ramdisk image. + # + exit $SMF_EXIT_OK +fi if [ `uname -p` = "i386" ]; then # on x86 get rid of transient reboot entry in the GRUB menu diff --git a/usr/src/cmd/fs.d/autofs/autod_main.c b/usr/src/cmd/fs.d/autofs/autod_main.c index 0c0d4f418d..c4f0f3cbb5 100644 --- a/usr/src/cmd/fs.d/autofs/autod_main.c +++ b/usr/src/cmd/fs.d/autofs/autod_main.c @@ -104,6 +104,7 @@ time_t timenow; int verbose = 0; int trace = 0; int automountd_nobrowse = 0; +int did_fork_exec; int main(argc, argv) diff --git a/usr/src/cmd/fs.d/autofs/automount.h b/usr/src/cmd/fs.d/autofs/automount.h index 3c981f3642..a749f93c94 100644 --- a/usr/src/cmd/fs.d/autofs/automount.h +++ b/usr/src/cmd/fs.d/autofs/automount.h @@ -116,7 +116,7 @@ struct mapline { */ struct mapfs { struct mapfs *mfs_next; /* next in entry */ - int mfs_ignore; /* ignore this entry */ + int mfs_ignore; /* ignore this entry */ char *mfs_host; /* host name */ char *mfs_dir; /* dir to mount */ int mfs_penalty; /* mount penalty for this host */ @@ -162,8 +162,8 @@ struct autodir { char *dir_name; /* mount point */ char *dir_map; /* name of map for dir */ char *dir_opts; /* default mount options */ - int dir_direct; /* direct mountpoint ? */ - int dir_remount; /* a remount */ + int dir_direct; /* direct mountpoint ? */ + int dir_remount; /* a remount */ struct autodir *dir_next; /* next entry */ struct autodir *dir_prev; /* prev entry */ }; @@ -244,8 +244,8 @@ typedef struct command { /* * globally visible door_server file descriptor */ -int did_exec_map; -int did_fork_exec; +extern int did_exec_map; +extern int did_fork_exec; extern time_t timenow; /* set at start of processing of each RPC call */ extern char self[]; diff --git a/usr/src/cmd/fs.d/autofs/ns_files.c b/usr/src/cmd/fs.d/autofs/ns_files.c index 9507fc0fc7..e4af4d550f 100644 --- a/usr/src/cmd/fs.d/autofs/ns_files.c +++ b/usr/src/cmd/fs.d/autofs/ns_files.c @@ -46,6 +46,7 @@ #include <strings.h> #include "automount.h" +int did_exec_map; static int read_execout(char *, char **, char *, char *, int); static int call_read_execout(char *, char *, char *, int); static FILE *file_open(char *, char *, char **, char ***); @@ -349,7 +350,7 @@ loadmaster_files(char *mastermap, char *defopts, char **stack, char ***stkptr) /* * Check for no embedded blanks. */ - if (strcspn(opts, " ") == strlen(opts)) { + if (strcspn(opts, " \t") == strlen(opts)) { dir++; (void) loadmaster_map(dir, opts, stack, stkptr); } else { @@ -377,7 +378,7 @@ pr_msg("Warning: invalid entry for %s in %s ignored.\n", dir, fname); /* * Check for no embedded blanks. */ - if (strcspn(opts, " ") == strlen(opts)) { + if (strcspn(opts, " \t") == strlen(opts)) { dirinit(dir, map, opts, 0, stack, stkptr); } else { pr_msg("Warning: invalid entry for %s in %s ignored.\n", dir, fname); diff --git a/usr/src/cmd/fs.d/udfs/fsck/fsck.h b/usr/src/cmd/fs.d/udfs/fsck/fsck.h index 4014f4b2fb..e6da638381 100644 --- a/usr/src/cmd/fs.d/udfs/fsck/fsck.h +++ b/usr/src/cmd/fs.d/udfs/fsck/fsck.h @@ -1,5 +1,5 @@ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ -/* All Rights Reserved */ +/* All Rights Reserved */ /* * Copyright (c) 1980, 1986, 1990 The Regents of the University of California. @@ -28,8 +28,6 @@ #ifndef _FSCK_H #define _FSCK_H -#pragma ident "%Z%%M% %I% %E% SMI" - #ifdef __cplusplus extern "C" { #endif @@ -99,22 +97,10 @@ struct bufarea { #define B_INUSE 1 #define MINBUFS 5 /* minimum number of buffers required */ -struct bufarea bufhead; /* head of list of other blks in filesys */ -struct bufarea *pbp; /* pointer to inode data in buffer pool */ -struct bufarea *pdirbp; /* pointer to directory data in buffer pool */ - -struct pri_vol_desc *pvolp; -struct vdp_desc *volp; -struct iuvd_desc *iudp; -struct part_desc *partp; -struct phdr_desc *pheadp; -struct log_vol_desc *logvp; -struct unall_desc *unallp; -struct log_vol_int_desc *lvintp; -struct lvid_iu *lviup; -struct anch_vol_desc_ptr *avdp; -struct file_set_desc *fileset; -struct space_bmap_desc *spacep; + +extern struct log_vol_int_desc *lvintp; +extern struct lvid_iu *lviup; +extern struct space_bmap_desc *spacep; #define dirty(bp) (bp)->b_dirty = isdirty = 1 #define initbarea(bp) \ @@ -122,11 +108,6 @@ struct space_bmap_desc *spacep; (bp)->b_bno = (daddr_t)-1; \ (bp)->b_flags = 0; -#define sbdirty() sblk.b_dirty = isdirty = 1 -#define cgdirty() cgblk.b_dirty = isdirty = 1 -#define sblock (*sblk.b_un.b_fs) -#define cgrp (*cgblk.b_un.b_cg) - enum fixstate {DONTKNOW, NOFIX, FIX}; struct inodesc { @@ -150,7 +131,7 @@ struct inodesc { /* * File entry cache structures. */ -struct fileinfo { +typedef struct fileinfo { struct fileinfo *fe_nexthash; /* next entry in hash chain */ uint32_t fe_block; /* location of this file entry */ uint16_t fe_len; /* size of file entry */ @@ -158,56 +139,48 @@ struct fileinfo { uint16_t fe_lcount; /* count from the file entry */ uint8_t fe_type; /* type of file entry */ uint8_t fe_state; /* flag bits */ -} *inphead, **inphash, *inpnext, *inplast; -long numdirs, numfiles, listmax; +} fileinfo_t; +extern fileinfo_t *inphead, **inphash, *inpnext, *inplast; +extern long listmax; #define FEGROW 512 -char *devname; /* name of device being checked */ -long secsize; /* actual disk sector size */ -long fsbsize; /* file system block size (same as secsize) */ -char nflag; /* assume a no response */ -char yflag; /* assume a yes response */ -int debug; /* output debugging info */ -int rflag; /* check raw file systems */ -int wflag; /* check only writable filesystems */ -int fflag; /* check regardless of clean flag (force) */ -int sflag; /* print status flag */ -char preen; /* just fix normal inconsistencies */ -char mountedfs; /* checking mounted device */ -int exitstat; /* exit status (set to 8 if 'No' response) */ -char hotroot; /* checking root device */ -char havesb; /* superblock has been read */ -int fsmodified; /* 1 => write done to file system */ -int fsreadfd; /* file descriptor for reading file system */ -int fswritefd; /* file descriptor for writing file system */ - -int iscorrupt; /* known to be corrupt/inconsistent */ -int isdirty; /* 1 => write pending to file system */ - -int mountfd; /* fd of mount point */ -char mountpoint[100]; /* string set to contain mount point */ - -char *busymap; /* ptr to primary blk busy map */ -char *freemap; /* ptr to copy of disk map */ - -uint32_t part_start; -uint32_t part_len; -uint32_t part_bmp_bytes; -uint32_t part_bmp_sectors; -uint32_t part_bmp_loc; -uint32_t filesetblock; -uint32_t filesetlen; -uint32_t rootblock; -uint32_t rootlen; -uint32_t lvintblock; -uint32_t lvintlen; -uint32_t disk_size; - -daddr_t n_blks; /* number of blocks in use */ -daddr_t n_files; /* number of files in use */ -daddr_t n_dirs; /* number of dirs in use */ -uint64_t maxuniqid; /* maximum unique id on medium */ +extern char *devname; /* name of device being checked */ +extern long secsize; /* actual disk sector size */ +extern long fsbsize; /* file system block size (same as secsize) */ +extern char nflag; /* assume a no response */ +extern char yflag; /* assume a yes response */ +extern int debug; /* output debugging info */ +extern int rflag; /* check raw file systems */ +extern int fflag; /* check regardless of clean flag (force) */ +extern char preen; /* just fix normal inconsistencies */ +extern char mountedfs; /* checking mounted device */ +extern int exitstat; /* exit status (set to 8 if 'No' response) */ +extern int fsmodified; /* 1 => write done to file system */ +extern int fsreadfd; /* file descriptor for reading file system */ +extern int fswritefd; /* file descriptor for writing file system */ + +extern int iscorrupt; /* known to be corrupt/inconsistent */ +extern int isdirty; /* 1 => write pending to file system */ + +extern char mountpoint[100]; /* string set to contain mount point */ + +extern char *busymap; /* ptr to primary blk busy map */ +extern char *freemap; /* ptr to copy of disk map */ + +extern uint32_t part_start; +extern uint32_t part_len; +extern uint32_t part_bmp_bytes; +extern uint32_t part_bmp_sectors; +extern uint32_t part_bmp_loc; +extern uint32_t rootblock; +extern uint32_t rootlen; +extern uint32_t lvintblock; +extern uint32_t lvintlen; + +extern daddr_t n_blks; /* number of blocks in use */ +extern daddr_t n_files; /* number of files in use */ +extern daddr_t n_dirs; /* number of dirs in use */ /* * bit map related macros diff --git a/usr/src/cmd/fs.d/udfs/fsck/main.c b/usr/src/cmd/fs.d/udfs/fsck/main.c index c8a6791bfc..32f322f361 100644 --- a/usr/src/cmd/fs.d/udfs/fsck/main.c +++ b/usr/src/cmd/fs.d/udfs/fsck/main.c @@ -4,7 +4,7 @@ */ /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ -/* All Rights Reserved */ +/* All Rights Reserved */ /* * Copyright (c) 1980, 1986, 1990 The Regents of the University of California. @@ -25,8 +25,6 @@ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include <stdio.h> #include <string.h> #include <ctype.h> /* use isdigit macro rather than 4.1 libc routine */ @@ -49,6 +47,27 @@ #include "fsck.h" #include <locale.h> +int debug; +char nflag; +char yflag; +int rflag; +static int wflag; /* check only writable filesystems */ +int fflag; +static int sflag; /* print status flag */ +int isdirty; +int fsmodified; +int iscorrupt; +int exitstat; +uint32_t part_len; +daddr_t n_blks; +daddr_t n_files; +daddr_t n_dirs; +char preen; +char mountpoint[100]; +char mountedfs; +char *devname; +struct log_vol_int_desc *lvintp; + extern int32_t writable(char *); extern void pfatal(char *, ...); extern void printfree(); @@ -207,7 +226,6 @@ checkfilesys(char *filesys) { char *devstr; - mountfd = -1; mountedfs = 0; iscorrupt = 1; diff --git a/usr/src/cmd/fs.d/udfs/fsck/pass1.c b/usr/src/cmd/fs.d/udfs/fsck/pass1.c index fad597b719..e0c736ec2f 100644 --- a/usr/src/cmd/fs.d/udfs/fsck/pass1.c +++ b/usr/src/cmd/fs.d/udfs/fsck/pass1.c @@ -4,7 +4,7 @@ */ /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ -/* All Rights Reserved */ +/* All Rights Reserved */ /* * Copyright (c) 1980, 1986, 1990 The Regents of the University of California. @@ -40,6 +40,8 @@ #include "udfs.h" #include <locale.h> +uint64_t maxuniqid; /* maximum unique id on medium */ + /* * for each large file ( size > MAXOFF_T) this global counter * gets incremented here. diff --git a/usr/src/cmd/fs.d/udfs/fsck/setup.c b/usr/src/cmd/fs.d/udfs/fsck/setup.c index 01df08456e..7ddad34e22 100644 --- a/usr/src/cmd/fs.d/udfs/fsck/setup.c +++ b/usr/src/cmd/fs.d/udfs/fsck/setup.c @@ -71,7 +71,33 @@ extern char *tagerrs[]; #define POWEROF2(num) (((num) & ((num) - 1)) == 0) extern int mflag; -extern char hotroot; +long fsbsize; +static char hotroot; /* checking root device */ +char *freemap; +char *busymap; +uint32_t part_start; +uint32_t lvintlen; +uint32_t lvintblock; +uint32_t rootblock; +uint32_t rootlen; +uint32_t part_bmp_bytes; +uint32_t part_bmp_sectors; +uint32_t part_bmp_loc; +int fsreadfd; +int fswritefd; +long secsize; +long numdirs, numfiles, listmax; +struct fileinfo *inphead, **inphash, *inpnext, *inplast; +struct space_bmap_desc *spacep; +static struct unall_desc *unallp; +static struct pri_vol_desc *pvolp; +static struct part_desc *partp; +static struct phdr_desc *pheadp; +static struct log_vol_desc *logvp; +struct lvid_iu *lviup; +static struct vdp_desc *volp; +static struct anch_vol_desc_ptr *avdp; +static struct iuvd_desc *iudp; char avdbuf[MAXBSIZE]; /* buffer for anchor volume descriptor */ char *main_vdbuf; /* buffer for entire main volume sequence */ @@ -87,7 +113,6 @@ setup(char *dev) char *raw, *rawname(), *unrawname(); struct ustat ustatb; - havesb = 0; if (stat("/", &statb) < 0) errexit(gettext("Can't stat root\n")); rootdev = statb.st_dev; @@ -354,10 +379,12 @@ readvolseq(int32_t listerr) int err; long freelen; daddr_t avdp; + struct file_set_desc *fileset; + uint32_t filesetblock; + uint32_t filesetlen; - disk_size = get_last_block(); if (debug) - (void) printf("Disk partition size: %x\n", disk_size); + (void) printf("Disk partition size: %x\n", get_last_block()); /* LINTED */ avp = (struct anch_vol_desc_ptr *)avdbuf; @@ -587,7 +614,6 @@ done: if (debug) (void) printf("Root at %x for %d bytes\n", rootblock, rootlen); - havesb = 1; return (1); } diff --git a/usr/src/cmd/fs.d/udfs/fsck/utilities.c b/usr/src/cmd/fs.d/udfs/fsck/utilities.c index 257dad8c96..4823b6eab3 100644 --- a/usr/src/cmd/fs.d/udfs/fsck/utilities.c +++ b/usr/src/cmd/fs.d/udfs/fsck/utilities.c @@ -51,6 +51,8 @@ #include <sys/lockfs.h> #include <locale.h> +static struct bufarea bufhead; + extern int32_t verifytag(struct tag *, uint32_t, struct tag *, int); extern char *tagerrs[]; extern void maketag(struct tag *, struct tag *); @@ -278,7 +280,6 @@ bufinit() initbarea(bp); } bufhead.b_size = i; /* save number of buffers */ - pbp = pdirbp = NULL; } /* @@ -364,7 +365,6 @@ ckfini() free(bp->b_un.b_buf); free((char *)bp); } - pbp = pdirbp = NULL; if (bufhead.b_size != cnt) errexit(gettext("Panic: lost %d buffers\n"), bufhead.b_size - cnt); diff --git a/usr/src/cmd/fs.d/ufs/fsck/fsck.h b/usr/src/cmd/fs.d/ufs/fsck/fsck.h index cba2c45625..d0d73fcb26 100644 --- a/usr/src/cmd/fs.d/ufs/fsck/fsck.h +++ b/usr/src/cmd/fs.d/ufs/fsck/fsck.h @@ -1,5 +1,5 @@ /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */ -/* All Rights Reserved */ +/* All Rights Reserved */ /* * Copyright (c) 1980, 1986, 1990 The Regents of the University of California. @@ -28,8 +28,6 @@ #ifndef _FSCK_FSCK_H #define _FSCK_FSCK_H -#pragma ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.3 */ - #ifdef __cplusplus extern "C" { #endif @@ -83,11 +81,11 @@ extern "C" { /* * These tests depend on the state/type defines above not overlapping bits. * - * DUNFOUND === (state == DSTATE || state == DZLINK) + * DUNFOUND === (state == DSTATE || state == DZLINK) * INCLEAR is irrelevant to the determination of * connectedness, so it's not included in this test. * - * DVALID === (state == DSTATE || state == DZLINK || state == DFOUND) + * DVALID === (state == DSTATE || state == DZLINK || state == DFOUND) */ #define S_IS_DUNFOUND(state) (((state) & (DSTATE | INZLINK)) \ == (state)) @@ -121,12 +119,10 @@ struct bufarea { #define B_INUSE 1 #define MINBUFS 5 /* minimum number of buffers required */ -struct bufarea bufhead; /* head of list of other blks in filesys */ -struct bufarea sblk; /* file system superblock */ -struct bufarea asblk; /* alternate superblock */ -struct bufarea cgblk; /* cylinder group blocks */ -struct bufarea *pbp; /* pointer to inode data in buffer pool */ -struct bufarea *pdirbp; /* pointer to directory data in buffer pool */ +extern struct bufarea sblk; /* file system superblock */ +extern struct bufarea cgblk; /* cylinder group blocks */ +extern struct bufarea *pbp; /* pointer to inode data in buffer pool */ +extern struct bufarea *pdirbp; /* pointer to directory data in buffer pool */ #define sbdirty() dirty(&sblk) #define cgdirty() dirty(&cgblk) @@ -243,14 +239,14 @@ struct inoinfo { /* * Inode cache */ -struct inoinfo **inphead, **inpsort; -int64_t numdirs, listmax, inplast; +extern struct inoinfo **inphead, **inpsort; +extern int64_t numdirs, listmax, inplast; /* * ACL cache */ -struct inoinfo **aclphead, **aclpsort; -int64_t numacls, aclmax, aclplast; +extern struct inoinfo **aclphead, **aclpsort; +extern int64_t numacls, aclmax, aclplast; /* * Tree of directories we haven't reconnected or cleared. Any @@ -261,13 +257,13 @@ int64_t numacls, aclmax, aclplast; * * Elements are fsck_ino_t instances (not pointers). */ -void *limbo_dirs; +extern void *limbo_dirs; /* * Number of directories we actually found in the filesystem, * as opposed to how many the superblock claims there are. */ -fsck_ino_t countdirs; +extern fsck_ino_t countdirs; /* * shadowclients and shadowclientinfo are structures for keeping track of @@ -287,8 +283,8 @@ struct shadowclientinfo { struct shadowclientinfo *next; /* link to the next shadow inode */ }; /* global pointer to this shadow/client information */ -struct shadowclientinfo *shadowclientinfo; -struct shadowclientinfo *attrclientinfo; +extern struct shadowclientinfo *shadowclientinfo; +extern struct shadowclientinfo *attrclientinfo; /* * In ufs_inode.h ifdef _KERNEL, this is defined as `/@/'. However, @@ -312,64 +308,62 @@ extern caddr_t lfname; /* * Unitialized globals. */ -char *devname; /* name of device being checked */ -size_t dev_bsize; /* computed value of DEV_BSIZE */ -int secsize; /* actual disk sector size */ -char nflag; /* assume a no response */ -char yflag; /* assume a yes response */ -daddr32_t bflag; /* location of alternate super block */ -int debug; /* output debugging info */ -int rflag; /* check raw file systems */ -int roflag; /* do normal checks but don't update disk */ -int fflag; /* check regardless of clean flag (force) */ -int mflag; /* sanity check only */ -int verbose; /* be chatty */ -char preen; /* just fix normal inconsistencies */ -char mountedfs; /* checking mounted device */ -int exitstat; /* exit status (see EX* defines below) */ -char hotroot; /* checking root device */ -char rerun; /* rerun fsck. Only used in non-preen mode */ -int interrupted; /* 1 => exit EXSIGNAL on exit */ -char havesb; /* superblock has been read */ -int fsmodified; /* 1 => write done to file system */ -int fsreadfd; /* file descriptor for reading file system */ -int fswritefd; /* file descriptor for writing file system */ -int iscorrupt; /* known to be corrupt/inconsistent */ +extern char *devname; /* name of device being checked */ +extern size_t dev_bsize; /* computed value of DEV_BSIZE */ +extern int secsize; /* actual disk sector size */ +extern char nflag; /* assume a no response */ +extern char yflag; /* assume a yes response */ +extern daddr32_t bflag; /* location of alternate super block */ +extern int debug; /* output debugging info */ +extern int rflag; /* check raw file systems */ +extern int fflag; /* check regardless of clean flag (force) */ +extern int mflag; /* sanity check only */ +extern int verbose; /* be chatty */ +extern char preen; /* just fix normal inconsistencies */ +extern char mountedfs; /* checking mounted device */ +extern int exitstat; /* exit status (see EX* defines below) */ +extern char hotroot; /* checking root device */ +extern char rerun; /* rerun fsck. Only used in non-preen mode */ +extern int interrupted; /* 1 => exit EXSIGNAL on exit */ +extern char havesb; /* superblock has been read */ +extern int fsmodified; /* 1 => write done to file system */ +extern int fsreadfd; /* file descriptor for reading file system */ +extern int fswritefd; /* file descriptor for writing file system */ +extern int iscorrupt; /* known to be corrupt/inconsistent */ /* -1 means mark clean so user can mount+fix */ -int isdirty; /* 1 => write pending to file system */ +extern int isdirty; /* 1 => write pending to file system */ -int islog; /* logging file system */ -int islogok; /* log is okay */ +extern int islog; /* logging file system */ +extern int islogok; /* log is okay */ -int errorlocked; /* set => mounted fs has been error-locked */ +extern int errorlocked; /* set => mounted fs has been error-locked */ /* implies fflag "force check flag" */ -char *elock_combuf; /* error lock comment buffer */ -char *elock_mountp; /* mount point; used to unlock error-lock */ -int pid; /* fsck's process id (put in lockfs comment) */ -int mountfd; /* fd of mount point */ -struct lockfs *lfp; /* current lockfs status */ - -daddr32_t maxfsblock; /* number of blocks in the file system */ -uint_t largefile_count; /* global largefile counter */ -char *mount_point; /* if mounted, this is where */ -char *blockmap; /* ptr to primary blk allocation map */ -fsck_ino_t maxino; /* number of inodes in file system */ -fsck_ino_t lastino; /* last inode in use */ -ushort_t *statemap; /* ptr to inode state table */ -short *lncntp; /* ptr to link count table */ - -fsck_ino_t lfdir; /* lost & found directory inode number */ -int overflowed_lf; /* tried to wrap lost & found's link count */ -int reattached_dir; /* reconnected at least one directory */ -int broke_dir_link; /* broke at least one directory hardlink */ - -daddr32_t n_blks; /* number of blocks in use */ -fsck_ino_t n_files; /* number of files in use */ +extern char *elock_combuf; /* error lock comment buffer */ +extern char *elock_mountp; /* mount point; used to unlock error-lock */ +extern int pid; /* fsck's process id (put in lockfs comment) */ +extern int mountfd; /* fd of mount point */ + +extern daddr32_t maxfsblock; /* number of blocks in the file system */ +extern uint_t largefile_count; /* global largefile counter */ +extern char *mount_point; /* if mounted, this is where */ +extern char *blockmap; /* ptr to primary blk allocation map */ +extern fsck_ino_t maxino; /* number of inodes in file system */ +extern fsck_ino_t lastino; /* last inode in use */ +extern ushort_t *statemap; /* ptr to inode state table */ +extern short *lncntp; /* ptr to link count table */ + +extern fsck_ino_t lfdir; /* lost & found directory inode number */ +extern int overflowed_lf; /* tried to wrap lost & found's link count */ +extern int reattached_dir; /* reconnected at least one directory */ +extern int broke_dir_link; /* broke at least one directory hardlink */ + +extern daddr32_t n_blks; /* number of blocks in use */ +extern fsck_ino_t n_files; /* number of files in use */ #define clearinode(dp) { \ *(dp) = zino; \ } -struct dinode zino; +extern struct dinode zino; #define testbmap(blkno) isset(blockmap, blkno) #define setbmap(blkno) setbit(blockmap, blkno) diff --git a/usr/src/cmd/fs.d/ufs/fsck/inode.c b/usr/src/cmd/fs.d/ufs/fsck/inode.c index e615617ee1..d5ba38d358 100644 --- a/usr/src/cmd/fs.d/ufs/fsck/inode.c +++ b/usr/src/cmd/fs.d/ufs/fsck/inode.c @@ -3,7 +3,7 @@ */ /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ -/* All Rights Reserved */ +/* All Rights Reserved */ /* * Copyright (c) 1980, 1986, 1990 The Regents of the University of California. @@ -44,6 +44,12 @@ #include <pwd.h> #include "fsck.h" +uint_t largefile_count = 0; +fsck_ino_t lastino; +struct bufarea cgblk; +struct inoinfo **aclphead, **aclpsort; +struct dinode zino; + static int get_indir_offsets(int, daddr_t, int *, int *); static int clearanentry(struct inodesc *); static void pdinode(struct dinode *); @@ -508,7 +514,7 @@ iblock(struct inodesc *idesc, int ilevel, u_offset_t iblks, nif = 0; /* * first pass: all "free" retrieval pointers (from [nif] thru - * the end of the indirect block) should be zero. (This + * the end of the indirect block) should be zero. (This * assertion does not hold for directories, which may be * truncated without releasing their allocated space) */ diff --git a/usr/src/cmd/fs.d/ufs/fsck/main.c b/usr/src/cmd/fs.d/ufs/fsck/main.c index 95a1c4308e..26fc50e653 100644 --- a/usr/src/cmd/fs.d/ufs/fsck/main.c +++ b/usr/src/cmd/fs.d/ufs/fsck/main.c @@ -175,6 +175,41 @@ char *magic_fs[] = { NULL /* MAGIC_LIMIT */ }; +daddr32_t bflag; +daddr32_t n_blks; +daddr32_t maxfsblock; +int debug; +int errorlocked; +int exitstat; +int fflag; +int fsmodified; +int fswritefd; +int iscorrupt; +int islog; +int islogok; +int interrupted; +int mflag; +int mountfd; +int overflowed_lf; +int rflag; +int reattached_dir; +int broke_dir_link; +int verbose; +char hotroot; +char mountedfs; +char nflag; +char preen; +char rerun; +char *blockmap; +char *devname; +char yflag; +short *lncntp; +ushort_t *statemap; +fsck_ino_t maxino; +fsck_ino_t countdirs; +fsck_ino_t n_files; +void *limbo_dirs; + int main(int argc, char *argv[]) { diff --git a/usr/src/cmd/fs.d/ufs/fsck/setup.c b/usr/src/cmd/fs.d/ufs/fsck/setup.c index e95eae6aa0..b128533412 100644 --- a/usr/src/cmd/fs.d/ufs/fsck/setup.c +++ b/usr/src/cmd/fs.d/ufs/fsck/setup.c @@ -4,7 +4,7 @@ */ /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ -/* All Rights Reserved */ +/* All Rights Reserved */ /* * Copyright (c) 1980, 1986, 1990 The Regents of the University of California. @@ -83,6 +83,18 @@ static caddr_t calcsb_names[] = { "<UNKNOWN>", "MKFS", "NEWFS", "<OUT OF RANGE>" }; +fsck_ino_t lfdir; +int64_t numacls, aclmax, aclplast; +int64_t numdirs, listmax, inplast; +char havesb; +int fsreadfd; +int isdirty; +int pid; +int secsize; +size_t dev_bsize; +struct bufarea sblk; +static struct bufarea asblk; /* alternate superblock */ +struct inoinfo **inphead, **inpsort; struct shadowclientinfo *shadowclientinfo = NULL; struct shadowclientinfo *attrclientinfo = NULL; int maxshadowclients = 1024; /* allocation size, not limit */ @@ -498,7 +510,7 @@ open_and_intro(caddr_t devstr, int corefs) fflag = 1; } pid = getpid(); - if (nflag || roflag || (fswritefd = open64(devstr, O_WRONLY)) < 0) { + if (nflag || (fswritefd = open64(devstr, O_WRONLY)) < 0) { fswritefd = -1; if (preen && !debug) pfatal("(NO WRITE ACCESS)\n"); diff --git a/usr/src/cmd/fs.d/ufs/fsck/utilities.c b/usr/src/cmd/fs.d/ufs/fsck/utilities.c index 051979c81e..afdb34c9f2 100644 --- a/usr/src/cmd/fs.d/ufs/fsck/utilities.c +++ b/usr/src/cmd/fs.d/ufs/fsck/utilities.c @@ -4,7 +4,7 @@ */ /* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */ -/* All Rights Reserved */ +/* All Rights Reserved */ /* * Copyright (c) 1980, 1986, 1990 The Regents of the University of California. @@ -61,7 +61,13 @@ #include <inttypes.h> #include "fsck.h" +struct bufarea *pbp; +struct bufarea *pdirbp; caddr_t mount_point = NULL; +static struct bufarea bufhead; /* head of list of other blks in filesys */ +char *elock_combuf; +char *elock_mountp; +static struct lockfs *lfp; /* current lockfs status */ static int64_t diskreads, totalreads; /* Disk cache statistics */ @@ -1064,7 +1070,7 @@ mounted(caddr_t name, caddr_t devstr, size_t str_size) if (hasmntopt(mntent, MNTOPT_RO) != 0) found = M_RO; /* mounted as RO */ else - found = M_RW; /* mounted as R/W */ + found = M_RW; /* mounted as R/W */ if (mount_point == NULL) { mount_point = strdup(mntent->mnt_mountp); @@ -2498,7 +2504,7 @@ brute_force_get_device_size(int fd) diskaddr_t min_fail = 0; diskaddr_t max_succeed = 0; diskaddr_t cur_db_off; - char buf[DEV_BSIZE]; + char buf[DEV_BSIZE]; /* * First, see if we can read the device at all, just to diff --git a/usr/src/cmd/ipf/lib/common/printhash_live.c b/usr/src/cmd/ipf/lib/common/printhash_live.c index 082ee74bb4..f0b46f444f 100755 --- a/usr/src/cmd/ipf/lib/common/printhash_live.c +++ b/usr/src/cmd/ipf/lib/common/printhash_live.c @@ -7,8 +7,6 @@ * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include <sys/ioctl.h> #include "ipf.h" #include "netinet/ipl.h" @@ -25,7 +23,7 @@ int opts; { iphtent_t entry, *top, *node; ipflookupiter_t iter; - int i, printed, last; + int i, printed = 0, last; ipfobj_t obj; if ((name != NULL) && strncmp(name, hp->iph_name, FR_GROUPLEN)) diff --git a/usr/src/cmd/ipf/lib/common/printpool_live.c b/usr/src/cmd/ipf/lib/common/printpool_live.c index 77f95d84de..ad9c84413d 100644 --- a/usr/src/cmd/ipf/lib/common/printpool_live.c +++ b/usr/src/cmd/ipf/lib/common/printpool_live.c @@ -7,8 +7,6 @@ * Use is subject to license terms. */ -#pragma ident "%Z%%M% %I% %E% SMI" - #include <sys/ioctl.h> #include "ipf.h" #include "netinet/ipl.h" @@ -25,7 +23,7 @@ int opts; { ip_pool_node_t entry, *top, *node; ipflookupiter_t iter; - int i, printed, last; + int i, printed = 0, last; ipfobj_t obj; if ((name != NULL) && strncmp(name, pool->ipo_name, FR_GROUPLEN)) diff --git a/usr/src/cmd/ipf/tools/ipfstat.c b/usr/src/cmd/ipf/tools/ipfstat.c index caa9ff7468..52c4421404 100644 --- a/usr/src/cmd/ipf/tools/ipfstat.c +++ b/usr/src/cmd/ipf/tools/ipfstat.c @@ -819,6 +819,7 @@ char *group, *comment; int n; ipfruleiter_t rule; ipfobj_t obj; + u_long array[1000]; fb.fr_next = fp; n = 0; @@ -842,8 +843,6 @@ char *group, *comment; obj.ipfo_ptr = &rule; do { - u_long array[1000]; - memset(array, 0xff, sizeof(array)); fp = (frentry_t *)array; rule.iri_rule = fp; diff --git a/usr/src/cmd/logadm/conf.c b/usr/src/cmd/logadm/conf.c index 93837fbebf..38be82ec64 100644 --- a/usr/src/cmd/logadm/conf.c +++ b/usr/src/cmd/logadm/conf.c @@ -441,7 +441,7 @@ conf_open(const char *cfname, const char *tfname, struct opts *cliopts) /* * possible future enhancement: go through and mark any entries: - * logfile -P <date> + * logfile -P <date> * as DELETED if the logfile doesn't exist */ @@ -685,6 +685,8 @@ conf_print(FILE *cstream, FILE *tstream) #ifdef TESTMODULE +int Debug; + /* * test main for conf module, usage: a.out conffile */ @@ -702,7 +704,7 @@ main(int argc, char *argv[]) if (argc != 2) err(EF_RAW, "usage: %s conffile\n", argv[0]); - conf_open(argv[1], argv[1], opts); + (void) conf_open(argv[1], argv[1], opts); printf("conffile <%s>:\n", argv[1]); conf_print(stdout, NULL); diff --git a/usr/src/cmd/mdb/Makefile.kmdb.files b/usr/src/cmd/mdb/Makefile.kmdb.files index ca10ca72a1..caf3050fee 100644 --- a/usr/src/cmd/mdb/Makefile.kmdb.files +++ b/usr/src/cmd/mdb/Makefile.kmdb.files @@ -25,7 +25,7 @@ # # Copyright (c) 2012 by Delphix. All rights reserved. -# Copyright (c) 2018 Joyent, Inc. All rights reserved. +# Copyright 2021 Joyent, Inc. # KMDBSRCS += \ @@ -60,6 +60,7 @@ KMDBSRCS += \ kmdb_kdi.c \ kmdb_kvm.c \ mdb_logio.c \ + mdb_linkerset.c \ mdb_list.c \ mdb_macalias.c \ kmdb_main.c \ @@ -88,6 +89,7 @@ KMDBSRCS += \ kmdb_umemglue.c \ mdb_value.c \ mdb_vcb.c \ + mdb_walkers.c \ mdb_wcb.c \ mdb_whatis.c \ kmdb_wr.c @@ -96,7 +98,7 @@ KMDBML += KMDBOBJS = $(KMDBSRCS:%.c=%.o) $(KMDBML:%.s=%.o) -PROMSRCS += +PROMSRCS += PROMOBJS = $(PROMSRCS:%.c=%.o) @@ -109,7 +111,7 @@ KCTLSRCS += \ kctl_string.c \ kctl_wr.c -KCTLML += +KCTLML += KCTLOBJS = $(KCTLSRCS:%.c=%.o) $(KCTLML:%.s=%.o) diff --git a/usr/src/cmd/mdb/Makefile.mdb b/usr/src/cmd/mdb/Makefile.mdb index 5eb6f4e977..5772bed1fd 100644 --- a/usr/src/cmd/mdb/Makefile.mdb +++ b/usr/src/cmd/mdb/Makefile.mdb @@ -26,7 +26,7 @@ # # Copyright 2011 Nexenta Systems, Inc. All rights reserved. # Copyright (c) 2012 by Delphix. All rights reserved. -# Copyright 2019 Joyent, Inc. +# Copyright 2021 Joyent, Inc. # Copyright 2018 Jason King # @@ -61,6 +61,7 @@ SRCS += \ mdb_kb_kvm.c \ mdb_kproc.c \ mdb_kvm.c \ + mdb_linkerset.c \ mdb_logio.c \ mdb_list.c \ mdb_macalias.c \ @@ -90,6 +91,7 @@ SRCS += \ mdb_umem.c \ mdb_value.c \ mdb_vcb.c \ + mdb_walkers.c \ mdb_wcb.c \ mdb_whatis.c diff --git a/usr/src/cmd/mdb/common/mdb/mdb.c b/usr/src/cmd/mdb/common/mdb/mdb.c index eb6b46083f..aafca64f3a 100644 --- a/usr/src/cmd/mdb/common/mdb/mdb.c +++ b/usr/src/cmd/mdb/common/mdb/mdb.c @@ -24,7 +24,7 @@ */ /* * Copyright (c) 2012 by Delphix. All rights reserved. - * Copyright (c) 2018, Joyent, Inc. + * Copyright 2021 Joyent, Inc. */ /* @@ -83,6 +83,7 @@ #define DCMD_ABORTED(x) ((x) == DCMD_USAGE || (x) == DCMD_ABORT) extern const mdb_dcmd_t mdb_dcmd_builtins[]; +extern const mdb_walker_t mdb_walker_builtins[]; extern mdb_dis_ctor_f *const mdb_dis_builtins[]; /* @@ -461,6 +462,7 @@ mdb_create(const char *execname, const char *arg0) static char rootdir[MAXPATHLEN]; const mdb_dcmd_t *dcp; + const mdb_walker_t *wcp; int i; bzero(&mdb, sizeof (mdb_t)); @@ -503,7 +505,7 @@ mdb_create(const char *execname, const char *arg0) mdb.m_rminfo.mi_dvers = MDB_API_VERSION; mdb.m_rminfo.mi_dcmds = mdb_dcmd_builtins; - mdb.m_rminfo.mi_walkers = NULL; + mdb.m_rminfo.mi_walkers = mdb_walker_builtins; (void) mdb_nv_create(&mdb.m_rmod.mod_walkers, UM_SLEEP); (void) mdb_nv_create(&mdb.m_rmod.mod_dcmds, UM_SLEEP); @@ -545,6 +547,9 @@ mdb_create(const char *execname, const char *arg0) for (dcp = &mdb_dcmd_builtins[0]; dcp->dc_name != NULL; dcp++) (void) mdb_module_add_dcmd(&mdb.m_rmod, dcp, 0); + for (wcp = &mdb_walker_builtins[0]; wcp->walk_name != NULL; wcp++) + (void) mdb_module_add_walker(&mdb.m_rmod, wcp, 0); + for (i = 0; mdb_dis_builtins[i] != NULL; i++) (void) mdb_dis_create(mdb_dis_builtins[i]); diff --git a/usr/src/cmd/mdb/common/mdb/mdb_cmds.c b/usr/src/cmd/mdb/common/mdb/mdb_cmds.c index 9943773424..ecdf2957bf 100644 --- a/usr/src/cmd/mdb/common/mdb/mdb_cmds.c +++ b/usr/src/cmd/mdb/common/mdb/mdb_cmds.c @@ -26,7 +26,7 @@ /* * Copyright (c) 2012 by Delphix. All rights reserved. - * Copyright 2019 Joyent, Inc. + * Copyright 2021 Joyent, Inc. * Copyright (c) 2013 Josef 'Jeff' Sipek <jeffpc@josefsipek.net> * Copyright (c) 2015, 2017 by Delphix. All rights reserved. * Copyright 2018 OmniOS Community Edition (OmniOSce) Association. @@ -71,6 +71,7 @@ #include <mdb/mdb_macalias.h> #include <mdb/mdb_tab.h> #include <mdb/mdb_typedef.h> +#include <mdb/mdb_linkerset.h> #ifdef _KMDB #include <kmdb/kmdb_kdi.h> #endif @@ -3171,6 +3172,8 @@ const mdb_dcmd_t mdb_dcmd_builtins[] = { head_help }, { "help", "[cmd]", "list commands/command help", cmd_help, NULL, cmd_help_tab }, + { "linkerset", "[name]", "display linkersets", cmd_linkerset, + linkerset_help, cmd_linkerset_tab }, { "list", "?type member [variable]", "walk list using member as link pointer", cmd_list, NULL, mdb_tab_complete_mt }, diff --git a/usr/src/cmd/mdb/common/mdb/mdb_linkerset.c b/usr/src/cmd/mdb/common/mdb/mdb_linkerset.c new file mode 100644 index 0000000000..771f8f1b95 --- /dev/null +++ b/usr/src/cmd/mdb/common/mdb/mdb_linkerset.c @@ -0,0 +1,500 @@ +/* + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + */ + +/* + * Copyright 2021 Joyent, Inc. + */ + +#include <mdb/mdb_debug.h> +#include <mdb/mdb_errno.h> +#include <mdb/mdb_modapi.h> +#include <mdb/mdb_err.h> +#include <mdb/mdb_ctf.h> +#include <mdb/mdb_ctf_impl.h> +#include <mdb/mdb_target_impl.h> +#include <mdb/mdb.h> +#include <sys/errno.h> +#include <string.h> + +/* + * A linker set is an array of pointers. The start of the set will have a + * weak symbol of the form START_PREFIX + name that will have the address + * of the first element (pointer) and another weak symbol that points just + * past the end of the final element. E.g. for a linker set 'foo', the + * first element will have a symbol __start_set_foo, and all __stop_set_foo + * will have the address just after the last element (e.g. &(last_element + 1)) + */ +#define START_PREFIX "__start_set_" +#define STOP_PREFIX "__stop_set_" + +/* + * The pointers that comprise the linker set have names that follow + * the pattern __set_<setname>_sym_<objname>. + */ +#define SYM_PREFIX "__set_" +#define SYM_DELIM "_sym_" + +typedef struct ldset_info { + char ldsi_name[MDB_SYM_NAMLEN]; + uintptr_t ldsi_addr; + uintptr_t ldsi_endaddr; + size_t ldsi_ptrsize; + size_t ldsi_nelem; + ssize_t ldsi_elsize; +} ldset_info_t; + +/* + * Similar to ldset_name_from_start(), except that it uses a linker set item + * name (e.g. '__set_foo_set_sym_foo_item') and writes the set name ('foo_set') + * into buf. + */ +static int +ldset_name_from_item(const char *item_name, char *buf, size_t buflen) +{ + const char *startp; + const char *endp; + size_t setname_len; + + /* The item name must start with '__sym_' */ + if (strncmp(item_name, SYM_PREFIX, sizeof (SYM_PREFIX) - 1) != 0) { + return (set_errno(EINVAL)); + } + startp = item_name + sizeof (SYM_PREFIX) - 1; + + /* The item name must have stuff after '__sym_' */ + if (*startp == '\0') { + return (set_errno(EINVAL)); + } + + /* Find the start of '_sym_' after the prefix */ + endp = strstr(startp, SYM_DELIM); + if (endp == NULL) { + /* '_sym_' not in the name, not a valid item name */ + return (set_errno(EINVAL)); + } + + setname_len = (size_t)(endp - startp); + if (setname_len + 1 > buflen) { + return (set_errno(ENAMETOOLONG)); + } + + /* + * We've verified buf has enough room for the linker set name + NUL. + * For sanity, we guarantee any trailing bytes in buf are zero, and + * use strncpy() so we copy only the bytes from item_name that are + * a part of the linker set name. The result should always be NUL + * terminated as a result. + */ + (void) memset(buf, '\0', buflen); + (void) strncpy(buf, item_name + sizeof (SYM_PREFIX) - 1, setname_len); + + return (0); +} + +static int +ldset_get_sym(const char *prefix, const char *name, GElf_Sym *sym) +{ + char symname[MDB_SYM_NAMLEN] = { 0 }; + + if (mdb_snprintf(symname, sizeof (symname), "%s%s", prefix, name) > + sizeof (symname) - 1) { + return (set_errno(ENAMETOOLONG)); + } + + return (mdb_tgt_lookup_by_name(mdb.m_target, MDB_TGT_OBJ_EVERY, symname, + sym, NULL)); +} + +/* + * Given the address of a pointer in a linker set, return the address of the + * item in the set in *addrp. + */ +static int +ldset_get_entry(uintptr_t addr, uintptr_t *addrp, size_t ptrsize) +{ + union { + uint64_t u64; + uint32_t u32; + } val; + ssize_t n; + + switch (ptrsize) { + case sizeof (uint32_t): + n = mdb_vread(&val.u32, sizeof (uint32_t), addr); + *addrp = (uintptr_t)val.u32; + break; + case sizeof (uint64_t): + n = mdb_vread(&val.u64, sizeof (uint64_t), addr); + *addrp = (uintptr_t)val.u64; + break; + default: + return (set_errno(ENOTSUP)); + } + + if (n != ptrsize) { + /* XXX: Better error value? */ + return (set_errno(ENODATA)); + } + + return (0); +} + +static ssize_t +ldset_item_size(uintptr_t addr) +{ + mdb_ctf_id_t id; + int ret; + + ret = mdb_ctf_lookup_by_addr(addr, &id); + if (ret != 0) { + return ((ssize_t)ret); + } + + return (mdb_ctf_type_size(id)); +} + +static int +ldset_get_info(uintptr_t addr, ldset_info_t *ldsi) +{ + GElf_Sym start_sym = { 0 }; + GElf_Sym stop_sym = { 0 }; + char name[MDB_SYM_NAMLEN] = { 0 }; + uintptr_t item_addr; + int ret; + + switch (mdb_tgt_dmodel(mdb.m_target)) { + case MDB_TGT_MODEL_LP64: + ldsi->ldsi_ptrsize = sizeof (uint64_t); + break; + case MDB_TGT_MODEL_ILP32: + ldsi->ldsi_ptrsize = sizeof (uint32_t); + break; + default: + return (set_errno(ENOTSUP)); + } + + ret = mdb_tgt_lookup_by_addr(mdb.m_target, addr, MDB_TGT_SYM_EXACT, + name, sizeof (name), &start_sym, NULL); + if (ret != 0) { + return (ret); + } + + if (ldset_name_from_item(name, ldsi->ldsi_name, + sizeof (ldsi->ldsi_name)) != 0) { + return (-1); + } + + ret = ldset_get_sym(STOP_PREFIX, ldsi->ldsi_name, &stop_sym); + if (ret != 0) { + return (-1); + } + + if (stop_sym.st_value < addr) { + return (set_errno(EINVAL)); + } + + if (ldset_get_entry(addr, &item_addr, ldsi->ldsi_ptrsize) != 0) { + return (-1); + } + + ldsi->ldsi_addr = addr; + ldsi->ldsi_endaddr = stop_sym.st_value; + ldsi->ldsi_nelem = (stop_sym.st_value - addr) / ldsi->ldsi_ptrsize; + ldsi->ldsi_elsize = ldset_item_size(item_addr); + + return (0); +} + +static int +ldsets_init_cb(void *data, const GElf_Sym *sym, const char *name, + const mdb_syminfo_t *sip, const char *obj) +{ + mdb_nv_t *nv = data; + const char *ldset_name; + GElf_Sym stop_sym = { 0 }; + int ret; + + if (strncmp(name, START_PREFIX, sizeof (START_PREFIX) - 1) != 0) { + return (0); + } + + /* + * The name of the linker set should follow START_PREFIX. If there's + * nothing there, then it's not a linker set, so skip this symbol. + */ + ldset_name = name + sizeof (START_PREFIX) - 1; + if (*ldset_name == '\0') { + return (0); + } + + ret = ldset_get_sym(STOP_PREFIX, ldset_name, &stop_sym); + if (ret != 0) { + /* If there's no stop symbol, we just ignore */ + if (errno == ENOENT) { + errno = 0; + return (0); + } + return (-1); + } + + /* + * The stop symbol should be at the same or higher address than + * the start symbol. If not, we ignore. + */ + if (stop_sym.st_value < sym->st_value) { + return (0); + } + + if (mdb_nv_insert(nv, ldset_name, NULL, sym->st_value, + MDB_NV_RDONLY) == NULL) { + return (-1); + } + + return (0); +} + +/* + * Initialize an mdb_nv_t with the name/addr of all the linkersets found in + * the target. + */ +static int +ldsets_nv_init(mdb_nv_t *nv, uint_t flags) +{ + if (mdb_nv_create(nv, flags) == NULL) + return (-1); + + return (mdb_tgt_symbol_iter(mdb.m_target, MDB_TGT_OBJ_EVERY, + MDB_TGT_SYMTAB, MDB_TGT_BIND_ANY | MDB_TGT_TYPE_NOTYPE, + ldsets_init_cb, nv)); +} + +int +ldsets_walk_init(mdb_walk_state_t *wsp) +{ + mdb_nv_t *nv; + int ret; + + nv = mdb_zalloc(sizeof (*nv), UM_SLEEP | UM_GC); + ret = ldsets_nv_init(nv, UM_SLEEP | UM_GC); + if (ret != 0) { + return (ret); + } + + mdb_nv_rewind(nv); + wsp->walk_data = nv; + return (WALK_NEXT); +} + +int +ldsets_walk_step(mdb_walk_state_t *wsp) +{ + mdb_nv_t *nv = wsp->walk_data; + mdb_var_t *v = mdb_nv_advance(nv); + int status; + + if (v == NULL) { + return (WALK_DONE); + } + + wsp->walk_addr = mdb_nv_get_value(v); + status = wsp->walk_callback(wsp->walk_addr, NULL, wsp->walk_cbdata); + return (status); +} + +int +ldset_walk_init(mdb_walk_state_t *wsp) +{ + ldset_info_t *ldsi; + int ret; + + ldsi = mdb_zalloc(sizeof (*ldsi), UM_SLEEP | UM_GC); + + ret = ldset_get_info(wsp->walk_addr, ldsi); + if (ret != 0) + return (WALK_ERR); + + wsp->walk_data = ldsi; + return (WALK_NEXT); +} + +int +ldset_walk_step(mdb_walk_state_t *wsp) +{ + ldset_info_t *ldsi = wsp->walk_data; + uintptr_t addr; + int ret; + + if (wsp->walk_addr >= ldsi->ldsi_endaddr) { + return (WALK_DONE); + } + + ret = ldset_get_entry(wsp->walk_addr, &addr, ldsi->ldsi_ptrsize); + if (ret != 0) { + return (WALK_ERR); + } + + ret = wsp->walk_callback(addr, NULL, wsp->walk_cbdata); + + wsp->walk_addr += ldsi->ldsi_ptrsize; + return (ret); +} + +static int +linkerset_walk_cb(uintptr_t addr, const void *data, void *cbarg) +{ + mdb_printf("%lr\n", addr); + return (0); +} + +static int +linkersets_walk_cb(uintptr_t addr, const void *data, void *cbarg) +{ + ldset_info_t info = { 0 }; + int ret; + char buf[64]; /* big enough for element size in any radix */ + + ret = ldset_get_info(addr, &info); + if (ret != 0) + return (WALK_ERR); + + if (info.ldsi_elsize > 0) { + (void) mdb_snprintf(buf, sizeof (buf), "%#r", + info.ldsi_elsize); + } else { + (void) strlcpy(buf, "?", sizeof (buf)); + } + + mdb_printf("%-20s %8s %9u\n", info.ldsi_name, buf, info.ldsi_nelem); + return (WALK_NEXT); +} + +int +cmd_linkerset(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv) +{ + int ret; + + if (argc > 1) { + return (DCMD_USAGE); + } + + /* Walk a linkerset given by the first argument */ + if (argc == 1) { + const char *setname = argv->a_un.a_str; + GElf_Sym start_sym = { 0 }; + ldset_info_t info = { 0 }; + + if (argv->a_type != MDB_TYPE_STRING) { + return (DCMD_USAGE); + } + + ret = ldset_get_sym(START_PREFIX, setname, &start_sym); + if (ret != 0) { + mdb_warn("Failed to get address of linkerset"); + return (-1); + } + + ret = ldset_get_info((uintptr_t)start_sym.st_value, &info); + if (ret != 0) { + mdb_warn("Failed to get information on linkerset"); + return (-1); + } + + return (mdb_pwalk("linkerset", linkerset_walk_cb, NULL, + info.ldsi_addr)); + } + + /* Display all the known linkersets */ + if (DCMD_HDRSPEC(flags)) { + mdb_printf("%<b>%<u>%-20s %-8s %-9s%</u>%</b>\n", + "NAME", "ITEMSIZE", "ITEMCOUNT"); + } + + return (mdb_walk("linkersets", linkersets_walk_cb, NULL)); +} + +static int +ldset_complete(mdb_var_t *v, void *arg) +{ + mdb_tab_cookie_t *mcp = arg; + + mdb_tab_insert(mcp, mdb_nv_get_name(v)); + return (0); +} + +static int +ldset_tab_complete(mdb_tab_cookie_t *mcp, const char *ldset) +{ + mdb_nv_t nv = { 0 }; + int ret; + + ret = ldsets_nv_init(&nv, UM_GC | UM_SLEEP); + if (ret != 0) { + return (ret); + } + + if (ldset != NULL) { + mdb_tab_setmbase(mcp, ldset); + } + + mdb_nv_sort_iter(&nv, ldset_complete, mcp, UM_GC | UM_SLEEP); + return (1); +} + +int +cmd_linkerset_tab(mdb_tab_cookie_t *mcp, uint_t flags, int argc, + const mdb_arg_t *argv) +{ + if (argc > 1) + return (1); + + if (argc == 1) { + ASSERT(argv[0].a_type == MDB_TYPE_STRING); + return (ldset_tab_complete(mcp, argv[0].a_un.a_str)); + } + + if (argc == 0 && (flags & DCMD_TAB_SPACE) != 0) { + return (ldset_tab_complete(mcp, NULL)); + } + + return (1); +} + +void +linkerset_help(void) +{ + static const char ldset_desc[] = +"A linker set is an array of pointers to objects in a target that have been\n" +"collected by the linker. The start and end location of each linker set\n" +"is designated by weak symbols with well known strings prefixed to the\n" +"name of the linker set.\n" +"\n" +"When invoked without any arguments, the ::linkerset command will attempt to\n" +"enumerate all linker sets present in the target. For each linker set, the \n" +"name, number of objects in the set, as well as the size of each object (when\n" +"known) is displayed. The ::linkerset command uses the CTF information to\n" +"determine the size of each object. If the CTF data is unavailable for a\n" +"given linkerset, '?' will displayed instead of the size.\n" +"\n" +"The ::linkerset command can also be invoked with a single argument -- the\n" +"name of a specific linker set. In this invocation, the ::linkerset command\n" +"will display the addresses of each object in the set and can be used as\n" +"part of a command pipeline.\n"; + + static const char ldset_examples[] = +" ::linkerset\n" +" ::linkerset sysinit_set | ::print 'struct sysinit'\n"; + + mdb_printf("%s\n", ldset_desc); + (void) mdb_dec_indent(2); + mdb_printf("%<b>EXAMPLES%</b>\n"); + (void) mdb_inc_indent(2); + mdb_printf("%s\n", ldset_examples); +} diff --git a/usr/src/cmd/mdb/common/mdb/mdb_linkerset.h b/usr/src/cmd/mdb/common/mdb/mdb_linkerset.h new file mode 100644 index 0000000000..9cf6a46c20 --- /dev/null +++ b/usr/src/cmd/mdb/common/mdb/mdb_linkerset.h @@ -0,0 +1,42 @@ +/* + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + */ + +/* + * Copyright 2021 Joyent, Inc. + */ + +#ifndef _MDB_LINKERSET_H +#define _MDB_LINKERSET_H + +#ifdef __cplusplus +extern "C" { +#endif + +#ifdef _MDB + +extern int ldsets_walk_init(mdb_walk_state_t *); +extern int ldsets_walk_step(mdb_walk_state_t *); + +extern int ldset_walk_init(mdb_walk_state_t *); +extern int ldset_walk_step(mdb_walk_state_t *); + +extern int cmd_linkerset(uintptr_t, uint_t, int, const mdb_arg_t *); +extern void linkerset_help(void); +extern int cmd_linkerset_tab(mdb_tab_cookie_t *, uint_t, int, + const mdb_arg_t *); + +#endif /* _MDB */ + +#ifdef __cplusplus +} +#endif + +#endif /* _MDB_LINKERSET_H */ diff --git a/usr/src/cmd/mdb/common/mdb/mdb_walkers.c b/usr/src/cmd/mdb/common/mdb/mdb_walkers.c new file mode 100644 index 0000000000..2daa1d2ea2 --- /dev/null +++ b/usr/src/cmd/mdb/common/mdb/mdb_walkers.c @@ -0,0 +1,24 @@ +/* + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + */ + +/* + * Copyright 2021 Joyent, Inc. + */ + +#include <mdb/mdb_modapi.h> +#include <mdb/mdb_linkerset.h> + +const mdb_walker_t mdb_walker_builtins[] = { + { "linkerset", "walk a linkerset", ldset_walk_init, ldset_walk_step }, + { "linkersets", "walk all linkersets", ldsets_walk_init, + ldsets_walk_step }, + NULL +}; diff --git a/usr/src/cmd/svc/Makefile b/usr/src/cmd/svc/Makefile index 6bf41324e1..43c917f534 100644 --- a/usr/src/cmd/svc/Makefile +++ b/usr/src/cmd/svc/Makefile @@ -25,7 +25,8 @@ include ../Makefile.cmd -SUBDIR_CMD= lsvcrun mfstscan servinfo svcadm svccfg svcprop svcs +SUBDIR_CMD= lsvcrun mfstscan servinfo svcadm svccfg svcprop svcs \ + rootisramdisk SUBDIR_DAEMON= configd startd SUBDIR_REPO= milestone profile seed SUBDIR_MISC= shell @@ -35,7 +36,6 @@ all := TARGET = all install := TARGET = install clean := TARGET = clean clobber := TARGET = clobber -lint := TARGET = lint _msg := TARGET = _msg .KEEP_STATE: @@ -58,7 +58,7 @@ ROOTCLASSACTIONS = $(CLASSACTIONS:%=$(ROOT)/usr/sadm/install/scripts/%) install: $(ROOTDTDS) $(ROOTCLASSACTIONS) -all install lint clean clobber: $(SUBDIRS) +all install clean clobber: $(SUBDIRS) _msg: $(SUBDIR_CMD) startd diff --git a/usr/src/cmd/svc/configd/Makefile b/usr/src/cmd/svc/configd/Makefile index 19ce51199a..9511b53fab 100644 --- a/usr/src/cmd/svc/configd/Makefile +++ b/usr/src/cmd/svc/configd/Makefile @@ -50,8 +50,6 @@ NATIVE_BUILD=$(POUND_SIGN) $(NATIVE_BUILD)PROG = $(MYPROG:%=%-native) $(NATIVE_BUILD)OBJS = $(MYOBJS:%.o=%-native.o) -ROOTCMDDIR= $(ROOT)/lib/svc/bin - MYCPPFLAGS = -I. -I../common -I../../../common/svc \ -I$(ROOT)/usr/include/sqlite-sys -D_REENTRANT CPPFLAGS += $(MYCPPFLAGS) @@ -75,7 +73,7 @@ LIBUUTIL = $(SRC)/lib/libuutil LIBSCF = $(SRC)/lib/libscf SCRIPTFILE = restore_repository -ROOTSCRIPTFILE = $(ROOTCMDDIR)/$(SCRIPTFILE) +ROOTSCRIPTFILE = $(ROOTLIBSVCBIN)/$(SCRIPTFILE) # # Native variant (used in ../seed). @@ -121,10 +119,10 @@ $(PROG): $(OBJS) $(COMPILE.c) -o $@ $< $(POST_PROCESS_O) -$(ROOTCMDDIR)/%: %.sh +$(ROOTLIBSVCBIN)/%: %.sh $(INS.rename) -install: all $(ROOTCMD) $(ROOTVARSADMFILE) $(ROOTSCRIPTFILE) +install: all $(ROOTLIBSVCBINPROG) $(ROOTVARSADMFILE) $(ROOTSCRIPTFILE) clean: FRC $(RM) $(MYOBJS) $(MYOBJS:%.o=%-native.o) diff --git a/usr/src/cmd/svc/lsvcrun/Makefile b/usr/src/cmd/svc/lsvcrun/Makefile index 91634e8b32..ed94b1892a 100644 --- a/usr/src/cmd/svc/lsvcrun/Makefile +++ b/usr/src/cmd/svc/lsvcrun/Makefile @@ -27,9 +27,7 @@ PROG = lsvcrun OBJS = lsvcrun.o SRCS = $(OBJS:%.o=%.c) -POFILES = $(OBJS:.o=.po) - -ROOTLIBSVCBINPROG = $(ROOT)/lib/svc/bin/$(PROG) +POFILES = $(OBJS:.o=.po) include ../../Makefile.cmd @@ -37,8 +35,6 @@ LDLIBS += -lcontract -lscf -luutil CERRWARN += -_gcc=-Wno-parentheses CERRWARN += $(CNOWARN_UNINIT) -lint := LINTFLAGS = -ux - .KEEP_STATE: all: $(PROG) @@ -49,12 +45,7 @@ $(PROG): $(OBJS) install: all $(ROOTLIBSVCBINPROG) -$(ROOTLIBSVCBIN)/%: % - $(INS.file) - clean: $(RM) $(OBJS) -lint: lint_SRCS - include ../../Makefile.targ diff --git a/usr/src/cmd/svc/mfstscan/Makefile b/usr/src/cmd/svc/mfstscan/Makefile index 64bcea95b8..7d0071dc52 100644 --- a/usr/src/cmd/svc/mfstscan/Makefile +++ b/usr/src/cmd/svc/mfstscan/Makefile @@ -33,9 +33,7 @@ SRCS = mfstscan.c \ ../common/manifest_find.c \ ../common/manifest_hash.c -POFILES = $(SRCS:.c=.po) - -ROOTLIBSVCBINPROG = $(ROOT)/lib/svc/bin/$(PROG) +POFILES = $(SRCS:.c=.po) include ../../Makefile.cmd @@ -47,8 +45,6 @@ CLOBBERFILES += $(POFILES) CERRWARN += $(CNOWARN_UNINIT) CERRWARN += -_gcc=-Wno-unused-label -lint := LINTFLAGS = -ux -erroff=E_GLOBAL_COULD_BE_STATIC2 - .KEEP_STATE: all: $(PROG) @@ -62,14 +58,9 @@ $(POFILE): $(POFILES) install: all $(ROOTLIBSVCBINPROG) -$(ROOTLIBSVCBIN)/%: % - $(INS.file) - clean: $(RM) $(OBJS) -lint: lint_SRCS - %.o: ../common/%.c $(COMPILE.c) $(OUTPUT_OPTION) $< $(CTFCONVERT_HOOK) $(POST_PROCESS_O) diff --git a/usr/src/cmd/svc/milestone/boot-archive b/usr/src/cmd/svc/milestone/boot-archive index bdf6c0dc9b..b7c859c1c8 100644 --- a/usr/src/cmd/svc/milestone/boot-archive +++ b/usr/src/cmd/svc/milestone/boot-archive @@ -22,6 +22,7 @@ # # Copyright 2010 Sun Microsystems, Inc. All rights reserved. # Use is subject to license terms. +# Copyright 2021 Oxide Computer Company # . /lib/svc/share/smf_include.sh @@ -30,7 +31,14 @@ FILELIST=/etc/svc/volatile/boot_archive_filelist UPDATEFILE=/etc/svc/volatile/boot_archive_needs_update -smf_is_globalzone || exit $SMF_EXIT_OK +if smf_is_nonglobalzone || smf_root_is_ramdisk; then + # + # Boot archives only exist in the global zone of persistent root + # systems, but this is either a non-global zone or a system booted from + # a ramdisk image. + # + exit $SMF_EXIT_OK +fi # # Now check the archive. diff --git a/usr/src/cmd/svc/rootisramdisk/Makefile b/usr/src/cmd/svc/rootisramdisk/Makefile new file mode 100644 index 0000000000..be6888b2d6 --- /dev/null +++ b/usr/src/cmd/svc/rootisramdisk/Makefile @@ -0,0 +1,37 @@ +# +# This file and its contents are supplied under the terms of the +# Common Development and Distribution License ("CDDL"), version 1.0. +# You may only use this file in accordance with the terms of version +# 1.0 of the CDDL. +# +# A full copy of the text of the CDDL should have accompanied this +# source. A copy of the CDDL is also available via the Internet at +# http://www.illumos.org/license/CDDL. +# + +# +# Copyright 2021 Oxide Computer Company +# + +PROG = rootisramdisk +OBJS = rootisramdisk.o +SRCS = $(OBJS:%.o=%.c) + +include ../../Makefile.cmd +include ../../Makefile.cmd.64 +include ../../Makefile.ctf + +.KEEP_STATE: + +all: $(PROG) + +$(PROG): $(OBJS) + $(LINK.c) -o $@ $(OBJS) $(LDLIBS) + $(POST_PROCESS) + +install: all $(ROOTLIBSVCBINPROG) + +clean: + $(RM) $(OBJS) + +include ../../Makefile.targ diff --git a/usr/src/cmd/svc/rootisramdisk/rootisramdisk.c b/usr/src/cmd/svc/rootisramdisk/rootisramdisk.c new file mode 100644 index 0000000000..353be0141a --- /dev/null +++ b/usr/src/cmd/svc/rootisramdisk/rootisramdisk.c @@ -0,0 +1,86 @@ +/* + * This file and its contents are supplied under the terms of the + * Common Development and Distribution License ("CDDL"), version 1.0. + * You may only use this file in accordance with the terms of version + * 1.0 of the CDDL. + * + * A full copy of the text of the CDDL should have accompanied this + * source. A copy of the CDDL is also available via the Internet at + * http://www.illumos.org/license/CDDL. + */ + +/* + * Copyright 2021 Oxide Computer Company + */ + +/* + * rootisramdisk: a helper program for smf_root_is_ramdisk() in + * "/lib/svc/share/smf_include.sh". Exits zero if the root file system is + * mounted from a ramdisk, or non-zero if not, or if we hit an error condition. + */ + +#include <stdlib.h> +#include <stdio.h> +#include <stdbool.h> +#include <fcntl.h> +#include <err.h> +#include <limits.h> +#include <string.h> +#include <sys/modctl.h> +#include <sys/types.h> +#include <sys/mkdev.h> +#include <sys/stat.h> + +#define EXIT_USAGE 2 +#define EXIT_NOT_RAMDISK 3 + +bool g_verbose = false; + +static bool +root_is_ramdisk(void) +{ + struct stat st; + major_t maj; + char driver[PATH_MAX + 1]; + + if (stat("/", &st) != 0) { + err(EXIT_FAILURE, "stat"); + } + + maj = major(st.st_dev); + if (g_verbose) { + fprintf(stderr, "major = %lu\n", (long unsigned)maj); + } + + if (modctl(MODGETNAME, driver, sizeof (driver), &maj) != 0) { + err(EXIT_FAILURE, "modctl"); + } + + if (g_verbose) { + fprintf(stderr, "driver = %s\n", driver); + } + + return (strcmp(driver, "ramdisk") == 0); +} + +int +main(int argc, char *argv[]) +{ + int c; + + while ((c = getopt(argc, argv, ":v")) != -1) { + switch (c) { + case 'v': + g_verbose = true; + break; + case ':': + errx(EXIT_USAGE, "-%c requires an operand", optopt); + break; + case '?': + errx(EXIT_USAGE, "-%c unknown", optopt); + break; + } + } + + return (root_is_ramdisk() ? EXIT_SUCCESS : EXIT_NOT_RAMDISK); +} diff --git a/usr/src/cmd/svc/shell/smf_include.sh b/usr/src/cmd/svc/shell/smf_include.sh index a5e3431d5b..9f8a5f6cd9 100644 --- a/usr/src/cmd/svc/shell/smf_include.sh +++ b/usr/src/cmd/svc/shell/smf_include.sh @@ -25,6 +25,7 @@ # Copyright 2012 Joyent, Inc. All rights reserved. # Copyright 2015 Nexenta Systems, Inc. All rights reserved. # Copyright 2012 Joyent, Inc. All rights reserved. +# Copyright 2021 Oxide Computer Company # smf_present () { @@ -76,6 +77,15 @@ smf_is_nonglobalzone() { return 1 } +# smf_root_is_ramdisk +# +# Returns zero (success) if the system root file system is mounted from a +# ramdisk, non-zero otherwise. +# +smf_root_is_ramdisk() { + /lib/svc/bin/rootisramdisk +} + # smf_configure_ip # # Returns zero (success) if this zone needs IP to be configured i.e. diff --git a/usr/src/cmd/svc/startd/Makefile b/usr/src/cmd/svc/startd/Makefile index 8b15034344..bfd2ad2a15 100644 --- a/usr/src/cmd/svc/startd/Makefile +++ b/usr/src/cmd/svc/startd/Makefile @@ -62,8 +62,6 @@ POFILES = $(OBJS:%.o=%.po) \ include ../../Makefile.cmd include ../../Makefile.ctf -ROOTCMDDIR= $(ROOT)/lib/svc/bin - $(NOT_RELEASE_BUILD)CPPFLAGS += -DDEBUG CFLAGS += $(CCVERBOSE) CPPFLAGS += -I. -I../common @@ -131,7 +129,7 @@ $(PROG): $(ALLOBJS) $(POFILE): $(POFILES) cat $(POFILES) > $(POFILE) -install: all $(ROOTCMD) +install: all $(ROOTLIBSVCBINPROG) clean: $(RM) $(ALLOBJS) diff --git a/usr/src/cmd/tic/Makefile.common b/usr/src/cmd/tic/Makefile.common index 00c0948db7..07df0ca8aa 100644 --- a/usr/src/cmd/tic/Makefile.common +++ b/usr/src/cmd/tic/Makefile.common @@ -43,9 +43,6 @@ MAPFILES= $(MAPFILE.INT) $(MAPFILE.NGB) LDFLAGS += $(MAPFILES:%=-Wl,-M%) CERRWARN += -_gcc=-Wno-char-subscripts -CERRWARN += -_gcc=-Wno-implicit-function-declaration -CERRWARN += -_gcc=-Wno-parentheses -CERRWARN += $(CNOWARN_UNINIT) # not linted SMATCH=off diff --git a/usr/src/cmd/tic/tic_main.c b/usr/src/cmd/tic/tic_main.c index 99312d3093..bde662ed2c 100644 --- a/usr/src/cmd/tic/tic_main.c +++ b/usr/src/cmd/tic/tic_main.c @@ -24,14 +24,14 @@ * Use is subject to license terms. */ /* Copyright (c) 1988 AT&T */ -/* All Rights Reserved */ +/* All Rights Reserved */ -/* +/* * University Copyright- Copyright (c) 1982, 1986, 1988 * The Regents of the University of California * All Rights Reserved - * + * * University Acknowledgment- Portions of this document are derived from * software developed by the University of California, Berkeley, and its * contributors. @@ -233,43 +233,3 @@ check_dir(char dirletter) } return; } - -#include <curses.h> -#if (defined(SYSV) || defined(USG)) && !defined(SIGPOLL) -/* - * mkdir(dirname, mode) - * - * forks and execs the mkdir program to create the given directory - * - */ - -mkdir(dirname, mode) -#ifdef __STDC__ -const -#endif -char *dirname; -int mode; -{ - int fork_rtn; - int status; - - fork_rtn = fork(); - - switch (fork_rtn) { - case 0: /* Child */ - (void) execl("/bin/mkdir", "mkdir", dirname, (char *)0); - _exit(1); - - case -1: /* Error */ - fprintf(stderr, "%s: SYSTEM ERROR!! Fork failed!!!\n", - progname); - exit(1); - - default: - (void) wait(&status); - if ((status != 0) || (chmod(dirname, mode) == -1)) - return (-1); - return (0); - } -} -#endif diff --git a/usr/src/cmd/tic/tic_parse.c b/usr/src/cmd/tic/tic_parse.c index 37f5a7db6f..4afb2d2c62 100644 --- a/usr/src/cmd/tic/tic_parse.c +++ b/usr/src/cmd/tic/tic_parse.c @@ -122,9 +122,25 @@ struct use_header { struct use_header use_list = {NULL, NULL}; int use_count = 0; + +extern int get_token(void); +extern int must_swap(void); +extern void check_dir(char); +extern void err_abort(char *, ...); +extern void panic_mode(char); +extern int read_entry(char *, struct _bool_struct *, struct _num_struct *, + struct _str_struct *); +extern void reset_input(void); +extern void syserr_abort(char *, ...); +extern void warning(char *, ...); + +int do_entry(struct use_item *); +int handle_use(struct use_item *, long, short *, short *, short *); +int save_str(char *); +int write_object(FILE *, short *, short *, short *); void dequeue(struct use_item *); -void init_structure(short Booleans[], short Numbers[], short Strings[]); -void dump_structure(short Booleans[], short Numbers[], short Strings[]); +void dump_structure(short *, short *, short *); +void init_structure(short *, short *, short *); /* * The use_list is a doubly-linked list with NULLs terminating the lists: @@ -276,8 +292,7 @@ dump_list(char *str) */ int -do_entry(item_ptr) -struct use_item *item_ptr; +do_entry(struct use_item *item_ptr) { long entry_offset; int token_type; @@ -524,14 +539,13 @@ void dump_structure(short Booleans[], short Numbers[], short Strings[]) { struct stat64 statbuf; - FILE *fp; + FILE *fp = NULL; char name_list[1024]; char *first_name, *other_names, *cur_name; char filename[128 + 2 + 1]; char linkname[128 + 2 + 1]; int len; int alphastart = 0; - extern char *strchr(), *strrchr(); strcpy(name_list, term_names + string_table); DEBUG(7, "Name list = '%s'\n", name_list); @@ -666,11 +680,7 @@ dump_structure(short Booleans[], short Numbers[], short Strings[]) int -write_object(fp, Booleans, Numbers, Strings) -FILE *fp; -short Booleans[]; -short Numbers[]; -short Strings[]; +write_object(FILE *fp, short Booleans[], short Numbers[], short Strings[]) { struct header header; char *namelist; @@ -707,9 +717,8 @@ short Strings[]; cBooleans[i] = Booleans[i]; if (fwrite(&header, sizeof (header), 1, fp) != 1 || - fwrite(namelist, sizeof (char), namelen, fp) != namelen || - fwrite(cBooleans, sizeof (char), BoolCount, fp) != - BoolCount) + fwrite(namelist, sizeof (char), namelen, fp) != namelen || + fwrite(cBooleans, sizeof (char), BoolCount, fp) != BoolCount) return (-1); if ((namelen+BoolCount) % 2 != 0 && @@ -744,14 +753,13 @@ short Strings[]; */ int -save_str(string) -char *string; +save_str(char *string) { int old_next_free; /* Do not let an offset be 255. It reads as -1 in Vr2 binaries. */ if (next_free % 256 == 255) - next_free++; + string_table[next_free++] = '\0'; old_next_free = next_free; @@ -825,12 +833,8 @@ init_structure(short Booleans[], short Numbers[], short Strings[]) */ int -handle_use(item_ptr, entry_offset, Booleans, Numbers, Strings) -long entry_offset; -struct use_item *item_ptr; -short Booleans[]; -short Numbers[]; -short Strings[]; +handle_use(struct use_item *item_ptr, long entry_offset, + short Booleans[], short Numbers[], short Strings[]) { struct _bool_struct use_bools; struct _num_struct use_nums; @@ -848,8 +852,8 @@ short Strings[]; sprintf(filename, "%c/%s", curr_token.tk_valstring[0], curr_token.tk_valstring); - if (stat64(filename, &statbuf) < 0 || - part2 == 0 && statbuf.st_mtime < start_time) { + if ((stat64(filename, &statbuf) < 0) || + (part2 == 0 && statbuf.st_mtime < start_time)) { DEBUG(2, "Forward USE to %s", curr_token.tk_valstring); if (item_ptr == NULL) { @@ -865,11 +869,13 @@ short Strings[]; filename); for (i = 0; i < BoolCount; i++) { - if (Booleans[i] == FALSE) - if (UB[i] == TRUE) /* now true */ + if (Booleans[i] == FALSE) { + if (UB[i] == TRUE) { /* now true */ Booleans[i] = TRUE; - else if (UB[i] > TRUE) /* cancelled */ + } else if (UB[i] > TRUE) { /* cancelled */ Booleans[i] = -2; + } + } } for (i = 0; i < NumCount; i++) { @@ -878,11 +884,13 @@ short Strings[]; } for (i = 0; i < StrCount; i++) { - if (Strings[i] == -1) - if (US[i] == (char *)-1) + if (Strings[i] == -1) { + if (US[i] == (char *)-1) { Strings[i] = -2; - else if (US[i] != (char *)0) + } else if (US[i] != (char *)0) { Strings[i] = save_str(US[i]); + } + } } } diff --git a/usr/src/cmd/tic/tic_read.c b/usr/src/cmd/tic/tic_read.c index b6acd1d7ce..b1d017cb15 100644 --- a/usr/src/cmd/tic/tic_read.c +++ b/usr/src/cmd/tic/tic_read.c @@ -38,8 +38,6 @@ * contributors. */ -#pragma ident "%Z%%M% %I% %E% SMI" - /* * ******************************************************************** * COPYRIGHT NOTICE * @@ -91,7 +89,12 @@ #include <sys/types.h> #include <sys/stat.h> +#include <sys/types.h> +#include <sys/stat.h> + +#include <fcntl.h> #include <stdlib.h> +#include <unistd.h> #include "curses_inc.h" #include "object.h" @@ -115,12 +118,15 @@ static char TermNames[128]; /* Buffer for terminal names for first term */ static char StringTable[2048]; /* String table for first terminal */ static int beencalled = 0; /* read_entry has been called before */ +extern void err_abort(char *, ...); +extern void syserr_abort(char *, ...); +extern void warning(char *, ...); + +int must_swap(void); + int -read_entry(filename, bptr, nptr, sptr) -char *filename; -struct _bool_struct *bptr; -struct _num_struct *nptr; -struct _str_struct *sptr; +read_entry(char *filename, struct _bool_struct *bptr, struct _num_struct *nptr, + struct _str_struct *sptr) { int fd; int numread; diff --git a/usr/src/cmd/tic/tic_scan.c b/usr/src/cmd/tic/tic_scan.c index c0f748f27f..460394aa99 100644 --- a/usr/src/cmd/tic/tic_scan.c +++ b/usr/src/cmd/tic/tic_scan.c @@ -90,6 +90,9 @@ #define iswhite(ch) (ch == ' ' || ch == '\t') +extern void err_abort(char *, ...); +extern void syserr_abort(char *, ...); +extern void warning(char *, ...); static int first_column; /* See 'next_char()' below */ @@ -128,7 +131,6 @@ void panic_mode(int); * EOF The end of the file has been reached. * */ - int get_token() { diff --git a/usr/src/lib/brand/ipkg/zone/platform.xml b/usr/src/lib/brand/ipkg/zone/platform.xml index 4075fe10d2..c15588bea3 100644 --- a/usr/src/lib/brand/ipkg/zone/platform.xml +++ b/usr/src/lib/brand/ipkg/zone/platform.xml @@ -22,6 +22,7 @@ Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved. Copyright 2018 Nexenta Systems, Inc. + Copyright 2021 Joyent, Inc. DO NOT EDIT THIS FILE. --> @@ -76,6 +77,7 @@ <device match="rlofi" /> <device match="rmt" /> <device match="sad/user" /> + <device match="signalfd" /> <device match="smbsrv" /> <device match="svvslo0" /> <device match="svvslo1" /> diff --git a/usr/src/lib/libxcurses/src/tic/Makefile b/usr/src/lib/libxcurses/src/tic/Makefile deleted file mode 100644 index 7caa48a036..0000000000 --- a/usr/src/lib/libxcurses/src/tic/Makefile +++ /dev/null @@ -1,78 +0,0 @@ -# -# CDDL HEADER START -# -# The contents of this file are subject to the terms of the -# Common Development and Distribution License, Version 1.0 only -# (the "License"). You may not use this file except in compliance -# with the License. -# -# You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE -# or http://www.opensolaris.org/os/licensing. -# See the License for the specific language governing permissions -# and limitations under the License. -# -# When distributing Covered Code, include this CDDL HEADER in each -# file and include the License file at usr/src/OPENSOLARIS.LICENSE. -# If applicable, add the following below this CDDL HEADER, with the -# fields enclosed by brackets "[]" replaced with your own identifying -# information: Portions Copyright [yyyy] [name of copyright owner] -# -# CDDL HEADER END -# -# -#ident "%Z%%M% %I% %E% SMI" -# -# Copyright (c) 1996, by Sun Microsystems, Inc. -# All rights reserved. -# -# lib/libxcurses/src/tic/Makefile -# - -# -# tic.mk -# -# Copyright 1990, 1995 by Mortice Kern Systems Inc. All rights reserved. -# -### -### This makefile INTENTIONALLY AVOIDS MKS MAKE EXTENSIONS in order -### to be portable to other systems that supply only a vanilla/POSIX -### make. -### -# -# -# This makefile assumes that a make wrapper, $RD/bin/$SYS/make, -# loads the required make config file, $RD/h/$SYS/config.mk. -# The make wrapper is a shell script that does : -# -# make -f $RD/h/$SYS/config.mk $@ -# -# Note that $RD/bin/$SYS should be ahead of /bin and /usr/bin in PATH. -# -# -#MAKE = rmake -# -#CFLAGS = -D_XOPEN_SOURCE -# -#HDR = tic.h -#TIC = ticmain.c ticscan.c ticerror.c ticparse.c -#UNTIC = untic.c -# -#EXE = tic$E untic$E -# -#$O$E : -# $(LD) $(LDFLAGS) $(CFLAGS) -o $@ $< -lcurses -# -#all :: $(EXE) -# -#install : all -# $(CP) $(EXE) $(RD)/bin/$(SYS) -# -#clobber :: clean -# $(RM) $(EXE) -# -#tic$E : $(TIC:.c=$O) -# $(LD) $(LDFLAGS) $(CFLAGS) -o $@ $(TIC:.c=$O) -lcurses - -all: - @echo this tic and untic is not currently used by Solaris - @echo use tic and untic in usr/src/lib/libcurses diff --git a/usr/src/lib/libxcurses/src/tic/tic.h b/usr/src/lib/libxcurses/src/tic/tic.h deleted file mode 100644 index 1ed52370c1..0000000000 --- a/usr/src/lib/libxcurses/src/tic/tic.h +++ /dev/null @@ -1,152 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright (c) 1996, by Sun Microsystems, Inc. - * All rights reserved. - */ - -/* - * tic.h Terminal Information Compiler - * - * Copyright 1990, 1992 by Mortice Kern Systems Inc. All rights reserved. - * - * Portions of this code Copyright 1982 by Pavel Curtis. - * - */ - -#ifndef tic_h -#define tic_h 1 - -#ifdef M_RCSID -#ifndef lint -static char const tic_h_rcsID[] = "$Header: /rd/src/tic/rcs/tic.h 1.11 1995/06/22 20:03:36 ant Exp $"; -#endif -#endif - -#include <mks.h> -#include <stdio.h> -#include <stdlib.h> -#include <string.h> -#include <term.h> -#include <time.h> - -extern char *_cmdname; - -/* Exit Status */ -#define SUCCESS 0 -#define NOT_DEFINED 1 -#define USAGE 2 -#define BAD_TERMINAL 3 -#define NOT_VALID 4 -#define ERROR 5 - -#define TERM_NAMES_LENGTH 128 -#define TERM_ENTRY_LENGTH 4096 -#define swap(x) (((x >> 8) & 0377) + 256 * (x & 0377)) - -extern int term_names; /* string offset */ -extern char *string_table; -extern char *source_file; - -#ifdef _XOPEN_CURSES -/* - * MKS XCurses to be conforming has to avoid name space pollution - * by using reserved prefixes. Map the pre-XCurses names to the - * new ones. - */ -#define BOOLCOUNT __COUNT_BOOL -#define NUMCOUNT __COUNT_NUM -#define STRCOUNT __COUNT_STR -#define boolnames __m_boolnames -#define boolcodes __m_boolcodes -#define boolfnames __m_boolfnames -#define numnames __m_numnames -#define numcodes __m_numcodes -#define numfnames __m_numfnames -#define strnames __m_strnames -#define strcodes __m_strcodes -#define strfnames __m_strfnames -#define __t_term_header terminfo_header_t -#define TERMINFO_MAGIC __TERMINFO_MAGIC -#define Booleans _bool -#define Numbers _num -#define Strings _str -#endif - -extern char boolean[BOOLCOUNT]; /* 0, 1, cancel 2 */ -extern short number[NUMCOUNT]; /* positive value, missing -1, cancel -2 */ -extern short string[STRCOUNT]; /* positive offset, missing -1, cancel -2 */ - -extern int check_only; -extern char *destination; /* destination directory for object files */ -extern time_t start_time; /* time at start of compilation */ -extern int curr_line; /* current line # in input */ -extern long curr_file_pos; /* file offset of current line */ -extern int debug_level; /* level of debugging output */ - -#define DEBUG(level, fmt, a1) \ - if (level <= debug_level) \ - fprintf(stderr, fmt, a1); - -/* - * These are the types of tokens returned by the scanner. - * The first three are also used in the hash table of capability - * names. The scanner returns one of these values after loading - * the specifics into the global structure curr_token. - * - * Note that EOF is also, implicitly, a token type. - */ -#define BOOLEAN 0 /* Boolean capability */ -#define NUMBER 1 /* Numeric capability */ -#define STRING 2 /* String-valued capability */ -#define CANCEL 3 /* Capability to be cancelled in following tc's */ -#define NAMES 4 /* The names for a terminal type */ -#define UNDEF 5 /* Invalid token */ - -/* - * The global structure in which the specific parts of a - * scanned token are returned. - */ -typedef struct token { - char *tk_name; /* name of capability */ - int tk_valnumber; /* value of capability (if a number) */ - char *tk_valstring; /* value of capability (if a string) */ -} token; - -extern token curr_token; - -/* - * Functions - */ -extern void compile ANSI((void)); -extern void err_abort(char const *_Fmt, ...); /* GENTEXT: err_abort */ -extern int find(char const *_Capname, void **_Arrayp, int *_Indexp); -extern void panic_mode ANSI((int _Ch)); -extern void reset ANSI((void)); -extern void reset_input ANSI((void)); -extern void warning(char const *_Fmt, ...); /* GENTEXT: warning */ - -extern int warnings; - -#define syserr_abort err_abort - -#endif /* tic_h */ diff --git a/usr/src/lib/libxcurses/src/tic/ticerror.c b/usr/src/lib/libxcurses/src/tic/ticerror.c deleted file mode 100644 index 7363023548..0000000000 --- a/usr/src/lib/libxcurses/src/tic/ticerror.c +++ /dev/null @@ -1,97 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright (c) 1996, by Sun Microsystems, Inc. - * All rights reserved. - */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -/* - * ticerror.c Terminal Information Compiler - * - * Copyright 1990, 1992 by Mortice Kern Systems Inc. All rights reserved. - * - * Portions of this code Copyright 1982 by Pavel Curtis. - * - */ - -#ifdef M_RCSID -#ifndef lint -static char const rcsID[] = "$Header: /rd/src/tic/rcs/ticerror.c 1.14 1995/06/22 18:11:44 ant Exp $"; -#endif -#endif - -#include "tic.h" -#include <stdarg.h> - -int warnings = 0; - -/*f - * Display warning message. - */ -void -warning (char const *f, ...) -{ - va_list ap; - char *fmt = m_msgdup((char *) f); - - va_start(ap, f); - - (void) fprintf( - stderr, m_textmsg(3101, "%s: Warning in \"%s\" line %u,\n", "W _ filename line_num"), - _cmdname, source_file, curr_line - ); - - (void) vfprintf(stderr, fmt, ap); - va_end(ap); - (void) fputc('\n', stderr); - - m_msgfree(fmt); - warnings++; - return; -} - -/*f - * Display error message. - */ -void -err_abort (char const *f, ...) -{ - va_list ap; - char *fmt = m_msgdup((char *) f); - - va_start(ap, f); - - (void) fprintf( - stderr, m_textmsg(3102, "%s: Error in \"%s\" line %u,\n", "E _ filename line_num"), - _cmdname, source_file, curr_line - ); - - (void) vfprintf(stderr, fmt, ap); - va_end(ap); - (void) fputc('\n', stderr); - - m_msgfree(fmt); - exit(1); -} - diff --git a/usr/src/lib/libxcurses/src/tic/ticmain.c b/usr/src/lib/libxcurses/src/tic/ticmain.c deleted file mode 100644 index a1853c5737..0000000000 --- a/usr/src/lib/libxcurses/src/tic/ticmain.c +++ /dev/null @@ -1,208 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright (c) 1996, by Sun Microsystems, Inc. - * All rights reserved. - */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -/* - * ticmain.c - * - * Terminal Information Compiler - * - * Copyright 1990, 1992 by Mortice Kern Systems Inc. All rights reserved. - * - * Portions of this code Copyright 1982 by Pavel Curtis. - * - */ - -#ifdef M_RCSID -#ifndef lint -static char const rcsID[] = "$Header: /rd/src/tic/rcs/ticmain.c 1.11 1995/06/22 18:40:30 ross Exp $"; -#endif -#endif - -#include "tic.h" -#include <ctype.h> -#include <sys/stat.h> - -int curr_line; -int check_only = 0; -int debug_level = 0; -time_t start_time; -char *source_file = M_TERMINFO_DIR; -char *destination = M_TERMINFO_DIR; - -char boolean[BOOLCOUNT]; -short number[NUMCOUNT]; -short string[STRCOUNT]; - -static char const usage[] = m_textstr(3103, "usage: %s [-v[n]] [-c] <file>\n", "U _"); -static char const src_err[] = m_textstr(3104, "terminfo definition file \"%s\" ", "E filename"); -static char const dst_err[] = m_textstr(3105, "terminfo database \"%s\" ", "E filename"); -static char const dstdir_err[] = m_textstr(3106, "terminfo database directory \"%s/%s\" ", "E pathname"); - -static void init(void); - -int -main(int argc, char **argv) -{ - char *ap; - setlocale(LC_ALL, ""); - _cmdname = m_cmdname(*argv); - for (--argc, ++argv; 0 < argc && **argv == '-'; --argc, ++argv) { - ap = &argv[0][1]; - if (*ap == '-' && ap[1] == '\0') { - --argc; - ++argv; - break; - } - while (*ap != '\0') { - switch (*ap++) { - case 'c': - check_only = 1; - continue; - case 'v': - debug_level = 1; - if (isdigit(*ap)) - debug_level = (int) strtol(ap, &ap, 0); - break; - default: - (void) fprintf(stderr, m_strmsg(usage), _cmdname); - return (USAGE); - } - break; - } - } - /* There must be only one source file. */ - if (argc != 1) { - (void) fprintf(stderr, m_strmsg(usage), _cmdname); - return (USAGE); - } - source_file = *argv; - init(); - compile(); - if (warnings > 0) { - return 1; - } - return (0); -} - -/*f - * Miscellaneous initializations - * - * Open source file as standard input - * Check for access rights to destination directories - * Create any directories which don't exist. - */ -static void -init(void) -{ - char *s; - char const *p; - char dir[2]; - struct stat statbuf; - static char const dirnames[] = "abcdefghijklmnopqrstuvwxyz0123456789"; - - curr_line = 0; - start_time = time(NULL); - if (freopen(source_file, "r", stdin) == NULL) { - (void) eprintf(m_strmsg(src_err), source_file); - exit(ERROR); - } - if ((s = getenv("TERMINFO")) != NULL) - destination = s; - if (access(destination, 7) < 0) { - (void) eprintf(m_strmsg(dst_err), destination); - exit(ERROR); - } - if (chdir(destination) < 0) { - (void) eprintf(m_strmsg(dst_err), destination); - exit(ERROR); - } - dir[1] = '\0'; - for (p = dirnames; *p != '\0'; ++p) { - *dir = *p; - if (stat(dir, &statbuf) < 0) { - (void) mkdir(dir, M_DIRMODE); - } else if (access(dir, 7) < 0) { - (void) eprintf(m_strmsg(dstdir_err), destination, dir); - exit(1); - } else if ((statbuf.st_mode & S_IFMT) != S_IFDIR) { - (void) eprintf(m_strmsg(dstdir_err), destination, dir); - exit(1); - } - } -} - -/*f - * Reset boolean[], number[], and string[]. - */ -void -reset(void) -{ - int i; - for (i = 0; i < BOOLCOUNT; ++i) - boolean[i] = 0; - for (i = 0; i < NUMCOUNT; ++i) - number[i] = -1; - for (i = 0; i < STRCOUNT; ++i) - string[i] = -1; -} - -/*f - * Return a linear index value. - * - * Search in the following order boolnames[], numnames[], and strnames[] - * for the matching capability name. Then map the array and index into - * a linear index. Return -1 if capname is not valid. - * - * While this linear approach is slow, TIC is seldom used once the - * database is created, therefore we don't bother spending extra - * effort to speed it up. - */ -int -find(char const *capname, void **arrayp, int *indexp) -{ - char **p; - for (p = boolnames; *p != NULL; ++p) - if (strcmp(*p, capname) == 0) { - *arrayp = (void*) boolean; - *indexp = (int)(p - boolnames); - return (0); - } - for (p = numnames; *p != NULL; ++p) - if (strcmp(*p, capname) == 0) { - *arrayp = (void*) number; - *indexp = (int)(p - numnames); - return (0); - } - for (p = strnames; *p != NULL; ++p) - if (strcmp(*p, capname) == 0) { - *arrayp = (void*) string; - *indexp = (int)(p - strnames); - return (0); - } - return (-1); -} diff --git a/usr/src/lib/libxcurses/src/tic/ticparse.c b/usr/src/lib/libxcurses/src/tic/ticparse.c deleted file mode 100644 index d1c5d0a473..0000000000 --- a/usr/src/lib/libxcurses/src/tic/ticparse.c +++ /dev/null @@ -1,701 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright (c) 1996, by Sun Microsystems, Inc. - * All rights reserved. - */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -/* - * ticparse.c - * - * Terminal Information Compiler - * - * Copyright 1990, 1992 by Mortice Kern Systems Inc. All rights reserved. - * - * Portions of this code Copyright 1982 by Pavel Curtis. - */ - -#ifdef M_RCSID -#ifndef lint -static char rcsID[] = "$Header: /rd/src/tic/rcs/ticparse.c 1.22 1995/06/27 14:56:46 ant Exp $"; -#endif -#endif - -#include "tic.h" -#include <ctype.h> -#include <sys/stat.h> -#include <errno.h> - -extern int get_token ANSI((void)); /* from ticscan.c */ - -char *string_table; -int next_free; /* next free character in string_table */ -int table_size = 0; /* current string_table size */ -int term_names; /* string table offset - current terminal */ -int part2 = 0; /* set to allow old compiled defns to be used */ -int complete = 0; /* 1 if entry done with no forward uses */ - -struct use_item { - long offset; - struct use_item *fptr, *bptr; -}; - -struct use_header { - struct use_item *head, *tail; -}; - -struct use_header use_list = {NULL, NULL}; -int use_count = 0; - -/* - * The use_list is a doubly-linked list with NULLs terminating the lists: - * - * use_item use_item use_item - * --------- --------- --------- - * | | | | | | offset - * |-------| |-------| |-------| - * | ----+-->| ----+-->| NULL | fptr - * |-------| |-------| |-------| - * | NULL |<--+---- |<--+---- | bptr - * --------- --------- --------- - * ^ ^ - * | ------------------ | - * | | | | | - * +--+---- | ----+---+ - * | | | - * ------------------ - * head tail - * use_list - * - */ - -char bad_start[] = m_textstr( - 3107, "File does not start with terminal names in column one", "E" -); -char not_names[] = m_textstr(3108, "Token after a seek not NAMES", "E"); -char use_links[] = m_textstr(3109, "\ -\n\ -Error in following up use-links. Either there is\n\ -a loop in the links or they reference non-existant\n\ -terminals. The following is a list of the entries\n\ -involved:\n\n\ -", "E"); -char nomem_use_list[] = m_textstr( - 3110, "Not enough memory for use_list element", "E" -); -char long_path[] = m_textstr(3111, "Pathname \"%c/%s\" too long.", "W char term"); -char more_than_one[] = m_textstr( - 3112, "More than one entry defined for \"%s\".\n","W term" -); -char fail_open[] = m_textstr(3113, "Failed to open \"%s\".\n", "E filename"); -char write_err[] = m_textstr(3114, "Error in writing \"%s\".\n", "E filename"); -char synonym[] = m_textstr(3115, "Terminal \"%s\" is a synonym for itself.\n", "W term"); -char fail_link[] = m_textstr(3116, "Failed to link \"%s\" to \"%s\".\n", "E file1 file2"); -char name_check[] = m_textstr(3117, "\ -compile: Line %d: Illegal terminal name - '%s'\n\ -Terminal names must start with lowercase or digit.\n\ -", "E line_num term"); -char nomem[] = m_textstr(3118, "Failed to allocated memory.\n", "E"); -char unknown_term[] = m_textstr(202, "Unknown terminal \"%s\".\n", "E term"); -char no_terminfo[] = m_textstr(203, "No terminfo database.\n", "E"); -char unknown_cap[] = m_textstr(3119, "Unknown capability '%s'.", "E action"); -char unknown_token[] = m_textstr(3120, "Unknown token type.", "W"); -char wrong_type[] = m_textstr(3121, "Wrong type used for capability \"%s\".", "W type"); - - -/*f - * debugging routine to dump list - */ -STATIC int -dump_list(str) -char *str; -{ - struct use_item *ptr; - char line[512]; - - fprintf(stderr, "dump_list %s\n", str); - for (ptr = use_list.head; ptr != NULL; ptr = ptr->fptr) - { - fseek(stdin, ptr->offset, 0); - fgets(line, 1024, stdin); - fprintf(stderr, "ptr %x off %d bptr %x fptr %x str %s", - ptr, ptr->offset, ptr->bptr, ptr->fptr, line); - } - fprintf(stderr, "\n"); -} - - -/*f - * Generate an error message if given name does not begin with a - * digit or lower-case letter. - */ -STATIC int -check_name(name) -char *name; -{ - if (!isdigit(name[0]) && !isalpha(name[0])) { - fprintf(stderr, m_strmsg(name_check), curr_line, name); - exit(1); - } -} - -/*f - * Test whether this machine will need byte-swapping - */ -STATIC int -must_swap() -{ - union { - short num; - char byte[2]; - } test; - test.num = 1; - return (test.byte[1]); -} - - -/*f - * Put a record of the given offset onto the use-list. - */ -STATIC int -enqueue(offset) -long offset; -{ - struct use_item *item; - - item = (struct use_item *) malloc(sizeof(struct use_item)); - - if (item == NULL) - syserr_abort(m_strmsg(nomem_use_list)); - - item->offset = offset; - - if (use_list.head != NULL) - { - item->bptr = use_list.tail; - use_list.tail->fptr = item; - item->fptr = NULL; - use_list.tail = item; - } - else - { - use_list.tail = use_list.head = item; - item->fptr = item->bptr = NULL; - } - - use_count ++; -} - - - -/*f - * remove the pointed-to item from the use_list - */ -STATIC int -dequeue(ptr) -struct use_item *ptr; -{ - if (ptr->fptr == NULL) - use_list.tail = ptr->bptr; - else - (ptr->fptr)->bptr = ptr->bptr; - - if (ptr->bptr == NULL) - use_list.head = ptr->fptr; - else - (ptr->bptr)->fptr = ptr->fptr; - - use_count --; -} - - - -/*f - * Write out the compiled entry to the given file. - * Return 0 if OK or -1 if not. - */ -STATIC int -write_object(fp) -FILE *fp; -{ - int i, tlength; - __t_term_header header; - char *tnames, zero = '\0'; - - tnames = string_table + term_names; - tlength = strlen(tnames) + 1; - if (TERM_NAMES_LENGTH < tlength) - tlength = TERM_NAMES_LENGTH; - if (must_swap()) { - header.magic = swap(TERMINFO_MAGIC); - header.name_size = swap(tlength); - header.bool_count = swap(BOOLCOUNT); - header.num_count = swap(NUMCOUNT); - header.str_count = swap(STRCOUNT); - header.str_size = swap(next_free); - } else { - header.magic = TERMINFO_MAGIC; - header.name_size = tlength; - header.bool_count = BOOLCOUNT; - header.num_count = NUMCOUNT; - header.str_count = STRCOUNT; - header.str_size = next_free; - } - - if (fwrite(&header, sizeof (header), 1, fp) != 1 - || fwrite(tnames, sizeof (char), tlength, fp) != tlength - || fwrite(boolean, sizeof (char), BOOLCOUNT, fp) != BOOLCOUNT) - return (-1); - - if ((tlength+BOOLCOUNT) % 2 != 0 - && fwrite(&zero, sizeof (char), 1, fp) != 1) - return (-1); - - if (must_swap()) { - for (i = 0; i < NUMCOUNT; ++i) - number[i] = swap(number[i]); - for (i = 0; i < STRCOUNT; ++i) - string[i] = swap(string[i]); - } - - if (fwrite(number, sizeof (short), NUMCOUNT, fp) != NUMCOUNT - || fwrite(string, sizeof (short), STRCOUNT, fp) != STRCOUNT - || fwrite(string_table, sizeof (char), next_free, fp) != next_free) - return (-1); - return (0); -} - - - -/*f - * Save the compiled version of a description in the filesystem. - * - * make a copy of the name-list - * break it up into first-name and all-but-last-name - * creat(first-name) - * write object information to first-name - * close(first-name) - * for each name in all-but-last-name - * link to first-name - * - */ -STATIC void -dump_structure() -{ - FILE *fp; - struct stat sb; - char *p, *q, *first, *fn, *long_name, dir[2], tname[TERM_NAMES_LENGTH]; - - /* Bag copy of terminal name list. Parse off the last name, - * which should be the terminal's long name. Parse off the - * first name to be used for the terminal filename. - */ - (void) strncpy(tname, string_table + term_names, TERM_NAMES_LENGTH); - DEBUG(7, "Terminal names are \"%s\".\n", tname); - for (p = tname + strlen(tname); tname < p; --p) { - if (*p == '|') { - long_name = ++p; - break; - } - } - if (tname == p) - long_name = tname; - for (p = tname; p < long_name; ++p) { - if (*p == '|') { - if (tname < p) - *p++ = '\0'; - break; - } - } - if (check_only) { - DEBUG(1, "Checked \"%s\".\n", tname); - return; - } - DEBUG(7, "Terminfo file name is \"%s\".\n", tname); - DEBUG(7, "Terminal's long name is \"%s\".\n", long_name); - - /* Create terminfo object file. */ - check_name(tname); - *dir = tolower(*tname); - dir[1] = '\0'; - first = m_pathcat(dir, tname); - if (first == NULL) - err_abort(m_strmsg(long_path), *tname, tname); - if (0 <= stat(first, &sb) && start_time <= sb.st_mtime) - warning(m_strmsg(more_than_one), tname); - if (access(first, W_OK) == -1 && errno != ENOENT) { - perror(first); - err_abort(m_strmsg(write_err), first); - } - (void) unlink(first); - if ((fp = fopen(first, "w")) == NULL) - err_abort(m_strmsg(fail_open), first); - DEBUG(1, "Created \"%s\".\n", first); - if (write_object(fp) < 0) - err_abort(m_strmsg(write_err), first); - (void) fclose(fp); - - /* Create links for alternate names. */ - while (p < long_name) { - for (q = p; p < long_name; ++p) { - if (*p == '|') { - *p++ = '\0'; - break; - } - } - check_name(q); - *dir = tolower(*q); - dir[1] = '\0'; - fn = m_pathcat(dir, q); - if (fn == NULL) { - warning(m_strmsg(long_path), *q, q); - continue; - } - if (strcmp(q, tname) == 0) { - warning(m_strmsg(synonym), tname); - continue; - } - if (0 <= stat(fn, &sb) && start_time <= sb.st_mtime) { - warning(m_strmsg(more_than_one), q); - continue; - } - if (access(fn, W_OK) == -1 && errno != ENOENT) { - err_abort(m_strmsg(write_err), fn); - } - (void) unlink(fn); - if (link(first, fn) < 0) { - if ((fp = fopen(fn, "w")) == NULL) - err_abort(m_strmsg(fail_open), fn); - DEBUG(1, "Created \"%s\".\n", fn); - if (write_object(fp) < 0) - err_abort(m_strmsg(write_err), fn); - (void) fclose(fp); - } else { - DEBUG(1, "Linked \"%s\".\n", fn); - } - free(fn); - } - free(first); -} - - -/*f - * copy string into next free part of string_table, doing a realloc() - * if necessary. return offset of beginning of string from start of - * string_table. - */ -STATIC int -save_str(string) -char *string; -{ - int old_next_free = next_free; - - if (table_size == 0) - { - if ((string_table = malloc(1024)) == NULL) - syserr_abort(m_strmsg(nomem)); - table_size = 1024; - DEBUG(5, "Made initial string table allocation. Size is %d\n", - table_size); - } - - while (table_size < next_free + strlen(string)) - { - if ((string_table = realloc(string_table, table_size + 1024)) - == NULL) - syserr_abort(m_strmsg(nomem)); - table_size += 1024; - DEBUG(5, "Extended string table. Size now %d\n", table_size); - } - - strcpy(&string_table[next_free], string); - DEBUG(7, "Saved string '%s' ", string); - DEBUG(7, "at location %d\n", next_free); - next_free += strlen(string) + 1; - - return (old_next_free); -} - -/*f - * Merge the compiled file whose name is in cur_token.valstring - * with the current entry. - * - * if it's a forward use-link - * if item_ptr == NULL - * queue it up for later handling - * else - * ignore it (we're already going through the queue) - * else it's a backward use-link - * read in the object file for that terminal - * merge contents with current structure - * - * Returned value is 0 if it was a backward link and we - * successfully read it in, -1 if a forward link. - */ -STATIC int -handle_use(item_ptr, entry_offset) -struct use_item *item_ptr; -long entry_offset; -{ - int i, err; - struct stat sb; - char *filename, dir[2]; - - check_name(curr_token.tk_valstring); - *dir = tolower(*curr_token.tk_valstring); - dir[1] = '\0'; - filename = m_pathcat(dir, curr_token.tk_valstring); - if (filename == NULL) { - err_abort( - m_strmsg(long_path), - *curr_token.tk_valstring, curr_token.tk_valstring - ); - } - if (stat(filename, &sb) < 0 - || (part2 == 0 && sb.st_mtime < start_time)) { - DEBUG(2, "Forward USE to %s", curr_token.tk_valstring); - if (item_ptr == NULL) { - DEBUG(2, " (enqueued)\n", ""); - enqueue(entry_offset); - } else { - DEBUG(2, " (skipped)\n", ""); - } - free(filename); - return (-1); - } - DEBUG(2, "Backward USE to %s\n", curr_token.tk_valstring); - (void) setupterm(curr_token.tk_valstring, STDOUT_FILENO, &err); - switch (err) { - case 1: - for (i = 0; i < BOOLCOUNT; ++i) { - if (boolean[i] == 0 && cur_term->Booleans[i]) - boolean[i] = 1; - } - for (i = 0; i < NUMCOUNT; ++i) { - if (number[i] == -1 && cur_term->Numbers[i] != -1) - number[i] = cur_term->Numbers[i]; - } - for (i = 0; i < STRCOUNT; ++i) { - if (string[i] == -1 && cur_term->Strings[i] != NULL) - string[i] = save_str(cur_term->Strings[i]); - } - (void) del_curterm(cur_term); - free(filename); - break; - case 0: - err_abort(m_strmsg(unknown_term), filename); - exit(BAD_TERMINAL); - case -1: - err_abort(m_strmsg(no_terminfo)); - exit(BAD_TERMINAL); - } - return (0); -} - - - -/*f - * Compile one entry. During the first pass, item_ptr is NULL. In pass - * two, item_ptr points to the current entry in the use_list. - * - * found-forward-use = FALSE - * re-initialise internal arrays - * save names in string_table - * get_token() - * while (not EOF and not NAMES) - * if found-forward-use - * do nothing - * else if 'use' - * if handle_use() < 0 - * found-forward-use = TRUE - * else - * check for existance and type-correctness - * enter cap into structure - * if STRING - * save string in string_table - * get_token() - * if ! found-forward-use - * clear CANCELS out of the structure - * dump compiled entry into filesystem - */ -STATIC int -do_entry(item_ptr) -struct use_item *item_ptr; -{ - void *array; - long entry_offset; - int i, index; - register int token_type; - int found_forward_use = 0; - - reset(); - next_free = 0; - - complete = 0; - term_names = save_str(curr_token.tk_name); - DEBUG(2, "Starting '%s'\n", curr_token.tk_name); - entry_offset = curr_file_pos; - - for (token_type = get_token(); - token_type != EOF && token_type != NAMES; - token_type = get_token()) { - if (found_forward_use) { - ; - } else if (strcmp(curr_token.tk_name, "use") == 0) { - if (handle_use(item_ptr, entry_offset) < 0) - found_forward_use = 1; - } else { - if (find(curr_token.tk_name, &array, &index) < 0) { - warning( - m_strmsg(unknown_cap), - curr_token.tk_name - ); - continue; - } - switch (token_type) { - case CANCEL: - if (array == boolean) - boolean[index] = 2; - else - ((short*) array)[index] = -2; - continue; - case BOOLEAN: - if (array == boolean) { - boolean[index] = 1; - continue; - } - break; - case NUMBER: - if (array == number) { - number[index] = curr_token.tk_valnumber; - continue; - } - break; - case STRING: - if (array == string) { - string[index] = save_str( - curr_token.tk_valstring - ); - continue; - } - break; - default: - warning(m_strmsg(unknown_token)); - panic_mode(','); - continue; - } - warning(m_strmsg(wrong_type), curr_token.tk_name); - } - } - if (found_forward_use) - return (token_type); - - /* Changed canceled values into in-active values. */ - for (i = 0; i < BOOLCOUNT; ++i) - if (boolean[i] == 2) - boolean[i] = 0; - for (i = 0; i < NUMCOUNT; ++i) - if (number[i] == -2) - number[i] = -1; - for (i = 0; i < STRCOUNT; ++i) - if (string[i] == -2) - string[i] = -1; - dump_structure(); - complete = 1; - return (token_type); -} - - - -/*f - * Main loop of the compiler. - * - * get_token() - * if curr_token != NAMES - * err_abort() - * while (not at end of file) - * do an entry - */ -void -compile() -{ - char line[1024]; - int token_type; - struct use_item *ptr; - int old_use_count; - - token_type = get_token(); - - if (token_type != NAMES) - err_abort(m_strmsg(bad_start)); - - while (token_type != EOF) - token_type = do_entry(NULL); - - DEBUG(2, "Starting handling of forward USE's\n", ""); - - for (part2=0; part2<2; part2++) { - old_use_count = -1; - - DEBUG(2, "\n\nPART %d\n\n", part2); - - while (use_list.head != NULL && old_use_count != use_count) - { - old_use_count = use_count; - for (ptr = use_list.tail; ptr != NULL; ptr = ptr->bptr) - { - fseek(stdin, ptr->offset, 0); - reset_input(); - if ((token_type = get_token()) != NAMES) - syserr_abort(m_strmsg(not_names)); - (void) do_entry(ptr); - if (complete) - dequeue(ptr); - } - - for (ptr = use_list.head; ptr != NULL; ptr = ptr->fptr) - { - fseek(stdin, ptr->offset, 0); - reset_input(); - if ((token_type = get_token()) != NAMES) - syserr_abort(m_strmsg(not_names)); - (void) do_entry(ptr); - if (complete) - dequeue(ptr); - } - - DEBUG(2,"Finished a pass through enqueued forward USE's\n",""); - } - } - - if (use_list.head != NULL) { - fprintf(stderr, use_links); - for (ptr = use_list.head; ptr != NULL; ptr = ptr->fptr) { - fseek(stdin, ptr->offset, 0); - fgets(line, 1024, stdin); - fprintf(stderr, "%s", line); - } - exit(1); - } -} diff --git a/usr/src/lib/libxcurses/src/tic/ticscan.c b/usr/src/lib/libxcurses/src/tic/ticscan.c deleted file mode 100644 index ad16baf407..0000000000 --- a/usr/src/lib/libxcurses/src/tic/ticscan.c +++ /dev/null @@ -1,417 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright (c) 1996, by Sun Microsystems, Inc. - * All rights reserved. - */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -/* - * ticscan.c Terminal Information Compiler - * - * Copyright 1990, 1992 by Mortice Kern Systems Inc. All rights reserved. - * - * Portions of this code Copyright 1982 by Pavel Curtis. - * - */ - -#ifdef M_RCSID -#ifndef lint -static char rcsID[] = "$Header: /rd/src/tic/rcs/ticscan.c 1.13 1994/02/08 20:19:29 rog Exp $"; -#endif -#endif - -#include "tic.h" -#include <limits.h> -#include <ctype.h> - -#define iswhite(ch) (ch == ' ' || ch == '\t') - - -token curr_token; -long curr_file_pos; -int curr_column = -1; -char line[LINE_MAX+1]; -static int first_column; /* See 'next_char()' below */ - -STATIC int next_char ANSI((void)); -STATIC int trans_string ANSI((char *)); -STATIC int escape ANSI((int)); -STATIC void backspace ANSI((void)); - -char early_eof[] = m_textstr(3122, "Premature EOF", "E"); -char nl_middle[] = m_textstr(3123, "Newline in middle of terminal name", "E"); -char ill_char[] = m_textstr(3124, "Illegal character - '%c'", "E char"); -char ill_ctrl[] = m_textstr(3125, "Illegal control character - '%c'", "E char"); -char off_beg[] = m_textstr(3126, "Backspaced off beginning of line", "E"); -char no_comma[] = m_textstr(3127, "Missing comma", "E"); -char very_long[] = m_textstr(3128, "Very long string found. Missing comma?", "E"); -char token_msg[] = m_textstr(3129, "Token: ", "I"); -char bool_msg[] = m_textstr(3130, "Boolean; name='%s'\n", "I string"); -char num_msg[] = m_textstr(3131, "Number; name='%s', value=%d\n", "I name value"); -char str_msg[] = m_textstr(3132, "String; name='%s', value='%s'\n", "I name value"); -char cancel[] = m_textstr(3133, "Cancel; name='%s'\n", "I name"); -char names[] = m_textstr(3134, "Names; value='%s'\n", "I value"); -char eof_msg[] = m_textstr(3135, "End of file.\n", "I"); -char bad_token[] = m_textstr(3136, "Bad token type", "E"); - - -/*f - * Scans the input for the next token, storing the specifics in the - * global structure 'curr_token' and returning one of the following: - * - * NAMES A line beginning in column 1. 'name' - * will be set to point to everything up to - * but not including the first comma on the line. - * BOOLEAN An entry consisting of a name followed by - * a comma. 'name' will be set to point to the - * name of the capability. - * NUMBER An entry of the form - * name#digits, - * 'name' will be set to point to the capability - * name and 'valnumber' to the number given. - * STRING An entry of the form - * name=characters, - * 'name' is set to the capability name and - * 'valstring' to the string of characters, with - * input translations done. - * CANCEL An entry of the form - * name@, - * 'name' is set to the capability name and - * 'valnumber' to -1. - * EOF The end of the file has been reached. - */ -int -get_token() -{ - long number; - int type; - int ch; - static char buffer[1024]; - register char *ptr; - int dot_flag = 0; - - while ((ch = next_char()) == '\n' || iswhite(ch)) { - ; - } - - if (ch == EOF) - type = EOF; - else - { - if (ch == '.') - { - dot_flag = 1; - - while ((ch = next_char()) == ' ' || ch == '\t') - ; - } - - if (! isalnum(ch)) { - warning(m_strmsg(ill_char), ch); - panic_mode(','); - } - - ptr = buffer; - *(ptr++) = ch; - - if (first_column) - { - while ((ch = next_char()) != ',' && ch != '\n' && ch != EOF) - *(ptr++) = ch; - - if (ch == EOF) - err_abort(m_strmsg(early_eof)); - else if (ch == '\n') { - warning(m_strmsg(nl_middle)); - panic_mode(','); - } - - *ptr = '\0'; - curr_token.tk_name = buffer; - type = NAMES; - } - else - { - ch = next_char(); - while (isalnum(ch)) - { - *(ptr++) = ch; - ch = next_char(); - } - - *ptr++ = '\0'; - switch (ch) - { - case ',': - curr_token.tk_name = buffer; - type = BOOLEAN; - break; - - case '@': - if (next_char() != ',') - warning(m_strmsg(no_comma)); - curr_token.tk_name = buffer; - type = CANCEL; - break; - - case '#': - number = 0; - while (isdigit(ch = next_char())) - number = number * 10 + ch - '0'; - if (ch != ',') - warning(m_strmsg(no_comma)); - curr_token.tk_name = buffer; - curr_token.tk_valnumber = number; - type = NUMBER; - break; - - case '=': - ch = trans_string(ptr); - if (ch != ',') - warning(m_strmsg(no_comma)); - curr_token.tk_name = buffer; - curr_token.tk_valstring = ptr; - type = STRING; - break; - - default: - warning(m_strmsg(ill_char), ch); - } - } /* end else (first_column == 0) */ - } /* end else (ch != EOF) */ - - if (dot_flag == 1) - DEBUG(8, "Commented out ", ""); - - if (debug_level >= 8) - { - fprintf(stderr, m_strmsg(token_msg)); - switch (type) - { - case BOOLEAN: - fprintf(stderr, m_strmsg(bool_msg), curr_token.tk_name); - break; - - case NUMBER: - fprintf( - stderr, m_strmsg(num_msg), - curr_token.tk_name, curr_token.tk_valnumber - ); - break; - - case STRING: - fprintf( - stderr, m_strmsg(str_msg), - curr_token.tk_name, curr_token.tk_valstring - ); - break; - - case CANCEL: - fprintf(stderr, m_strmsg(cancel), curr_token.tk_name); - break; - - case NAMES: - fprintf(stderr, m_strmsg(names), curr_token.tk_name); - break; - - case EOF: - fprintf(stderr, m_strmsg(eof_msg)); - break; - - default: - warning(m_strmsg(bad_token)); - } - } - - if (dot_flag == 1) /* if commented out, use the next one */ - type = get_token(); - - return(type); -} - - -/*f - * Returns the next character in the input stream. Comments and leading - * white space are stripped. The global state variable 'firstcolumn' is - * set TRUE if the character returned is from the first column of the input - * line. The global variable curr_line is incremented for each new line. - * The global variable curr_file_pos is set to the file offset of the - * beginning of each line. - */ -STATIC int -next_char() -{ - char *rtn_value; - - if (curr_column < 0 || LINE_MAX < curr_column - || line[curr_column] == '\0') { - do { - curr_file_pos = ftell(stdin); - if ((rtn_value = fgets(line, LINE_MAX, stdin)) != NULL) - curr_line++; - } while (rtn_value != NULL && line[0] == '#'); - - if (rtn_value == NULL) - return (EOF); - - curr_column = 0; - while (iswhite(line[curr_column])) - curr_column++; - } - first_column = curr_column == 0 && *line != '\n'; - return (line[curr_column++]); -} - - -/*f - * go back one character - */ -STATIC void -backspace() -{ - curr_column--; - - if (curr_column < 0) - syserr_abort(m_strmsg(off_beg)); -} - - -/*f - * Resets the input-reading routines. Used after a seek has been done. - */ -void -reset_input() -{ - curr_column = -1; -} - -/*f - * Reads characters using next_char() until encountering a comma, newline - * or end-of-file. The returned value is the character which caused - * reading to stop. The following translations are done on the input: - * - * ^X goes to ctrl-X (i.e. X & 037) - * {backslash-E,backslash-n,backslash-r,backslash-b, - * backslash-t,backslash-f} go to - * {ESCAPE,newline,carriage-return,backspace,tab,formfeed} - * {backslash-^,backslash-backslash} go to {carat,backslash} - * backslash-ddd (for ddd = up to three octal digits) goes to - * the character ddd - * - * backslash-e == backslash-E - * backslash-0 == backslash-200 - */ -STATIC int -trans_string(ptr) -char *ptr; -{ - int i, number, ch; - register int count = 0; - - while ((ch = next_char()) != ',' && ch != EOF) { - if (ch == '^') { - ch = next_char(); - if (ch == EOF) - err_abort(m_strmsg(early_eof)); - if (!isprint(ch)) - warning(m_strmsg(ill_ctrl), ch); - *(ptr++) = ch & 037; - } else if (ch == '\\') { - /* Try to read a three character octal number. */ - for (number = i = 0; i < 3; ++i) { - ch = next_char(); - if (ch == EOF) - err_abort(m_strmsg(early_eof)); - if (ch < '0' || '7' < ch) { - backspace(); - break; - } - number = number * 8 + ch - '0'; - } - if (0 < i) { - /* Read an octal number. */ - *ptr++ = number == 0 ? 0200 : (char) number; - } else { - /* Escape mapping translation. */ - ch = escape(next_char()); - *ptr++ = ch; - } - } else { - *(ptr++) = ch; - } - if (500 < ++count) - warning(m_strmsg(very_long)); - } - *ptr = '\0'; - return (ch); -} - -/*f - * Panic mode error recovery - skip everything until a "ch" is found. - */ -void -panic_mode(ch) -char ch; -{ - int c; - for (;;) { - c = next_char(); - if (c == ch) - return; - if (c == EOF); - return; - } -} - -/*f - * This routine is a codeset independent method of specifying a translation - * from an unambiguous printable form, to an internal binary value. - * This mapping is defined by Table 2-13 in section 2-12 of POSIX.2. - * - * This table has been extended to account for tic/infocmp specification - * of additional characters: <escape>, <space>, <colon>, <caret>, <comma> - * - * Assume that the escape lead-in character has been processed and - * any escaped octal sequence. - */ -STATIC int -escape(c) -int c; -{ - int i; - static int cntl_code[] = { - '\0', '\\', M_ALERT, '\b', '\f', '\n', '\r', '\t', - M_VTAB, M_ESCAPE, M_ESCAPE, ' ', ':', '^', ',', - -1 - }; - static int escape_char[] = { - '\0', '\\', 'a', 'b', 'f', 'n', 'r', 't', - 'v', 'E', 'e', 's', ':', '^', ',', - -1 - }; - for (i = 0; escape_char[i] != -1; ++i) - if (c == escape_char[i]) - return (cntl_code[i]); - return (c); -} diff --git a/usr/src/lib/libxcurses/src/tic/untic.c b/usr/src/lib/libxcurses/src/tic/untic.c deleted file mode 100644 index 15afd667e6..0000000000 --- a/usr/src/lib/libxcurses/src/tic/untic.c +++ /dev/null @@ -1,264 +0,0 @@ -/* - * CDDL HEADER START - * - * The contents of this file are subject to the terms of the - * Common Development and Distribution License, Version 1.0 only - * (the "License"). You may not use this file except in compliance - * with the License. - * - * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE - * or http://www.opensolaris.org/os/licensing. - * See the License for the specific language governing permissions - * and limitations under the License. - * - * When distributing Covered Code, include this CDDL HEADER in each - * file and include the License file at usr/src/OPENSOLARIS.LICENSE. - * If applicable, add the following below this CDDL HEADER, with the - * fields enclosed by brackets "[]" replaced with your own identifying - * information: Portions Copyright [yyyy] [name of copyright owner] - * - * CDDL HEADER END - */ -/* - * Copyright (c) 1996, by Sun Microsystems, Inc. - * All rights reserved. - */ - -#pragma ident "%Z%%M% %I% %E% SMI" - -/* - * untic.c CURSES Library - * - * Copyright 1990, 1992 by Mortice Kern Systems Inc. All rights reserved. - * - * Portions of this code Copyright 1982 by Pavel Curtis. - * - */ - -#ifdef M_RCSID -#ifndef lint -static char rcsID[] = "$Header: /rd/src/tic/rcs/untic.c 1.18 1995/06/22 20:04:01 ant Exp $"; -#endif -#endif - -#include <mks.h> -#include <ctype.h> -#include <stdio.h> -#include <stdlib.h> -#include <stdarg.h> -#include <term.h> -#include <unistd.h> -#include <m_ord.h> - -#ifdef _XOPEN_CURSES -/* - * MKS XCurses to be conforming has to avoid name space pollution - * by using reserved prefixes. Map the pre-XCurses names to the - * new ones. - */ -#define BOOLCOUNT __COUNT_BOOL -#define NUMCOUNT __COUNT_NUM -#define STRCOUNT __COUNT_STR -#define boolnames __m_boolnames -#define boolcodes __m_boolcodes -#define boolfnames __m_boolfnames -#define numnames __m_numnames -#define numcodes __m_numcodes -#define numfnames __m_numfnames -#define strnames __m_strnames -#define strcodes __m_strcodes -#define strfnames __m_strfnames -#define __t_term_header terminfo_header_t -#define TERMINFO_MAGIC __TERMINFO_MAGIC -#define Booleans _bool -#define Numbers _num -#define Strings _str -#define term_names _names -#endif - -extern char *_cmdname; - -/* Exit Status */ -#define SUCCESS 0 -#define NOT_DEFINED 1 -#define USAGE 2 -#define BAD_TERMINAL 3 -#define NOT_VALID 4 -#define ERROR 5 - -STATIC char *escape ANSI((int)); -STATIC void error ANSI((char *, ...)); /* GENTEXT: error */ -STATIC void untic ANSI((TERMINAL *)); - -char **Bool; -char **Num; -char **Str; - -char usage[] = m_textstr(3137, "usage: %s [-CILV] [term_name ...]\n", "U _"); -char version[] = m_textstr( - 3138, "%s - Display compiled terminfo database entry. Oct 92\n", "I _" -); - - -int -main(argc, argv) -int argc; -char **argv; -{ - int err; - char *ap, **av = argv; - setlocale(LC_ALL, ""); - _cmdname = *argv; - Bool = boolnames; - Num = numnames; - Str = strnames; - for (--argc, ++argv; 0 < argc && **argv == '-'; --argc, ++argv) { - ap = &argv[0][1]; - if (*ap == '-' && ap[1] == '\0') { - --argc; - ++argv; - break; - } - while (*ap != '\0') { - switch (*ap++) { - case 'C': - Bool = boolcodes; - Num = numcodes; - Str = strcodes; - break; - case 'I': - Bool = boolnames; - Num = numnames; - Str = strnames; - break; - case 'L': - Bool = boolfnames; - Num = numfnames; - Str = strfnames; - break; - case 'V': - (void) fprintf( - stderr, m_strmsg(version), _cmdname - ); - break; - default: - (void) fprintf( - stderr, m_strmsg(usage), _cmdname - ); - return (USAGE); - } - break; - } - } - if (argc <= 0) { - if ((ap = getenv("TERM")) == NULL) { - (void) fprintf(stderr, m_strmsg(usage), _cmdname); - return (USAGE); - } - /* Assume that, even if there were no parameters, space - * for argv[0] (the command name) and argv[1] (NULL) would - * have been put aside. We can use this space to fake a - * a single default parameter. - */ - argc = 1; - argv[0] = ap; - argv[1] = NULL; - - } - use_env(0); - for (; 0 < argc; --argc, ++argv) { - (void) setupterm(*argv, STDOUT_FILENO, &err); - switch (err) { - case 1: - untic(cur_term); - (void) del_curterm(cur_term); - break; - case 0: - error( - m_textmsg(202, "Unknown terminal \"%s\".\n", "E term"), - *argv - ); - return (BAD_TERMINAL); - case -1: - error(m_textmsg(203, "No terminfo database.\n", "E")); - return (BAD_TERMINAL); - } - } - return (SUCCESS); -} - -/*f - * Dump the contents of a compiled terminfo file into a - * human readable format. - */ -STATIC void -untic(tp) -TERMINAL *tp; -{ - int i; - char *p; - (void) printf("%s,\n", tp->term_names); - for (i = 0; i < BOOLCOUNT; ++i) { - if (tp->Booleans[i]) - (void) printf("\t%s,\n", Bool[i]); - } - for (i = 0; i < NUMCOUNT; ++i) { - if (tp->Numbers[i] != -1) - (void) printf("\t%s#%d,\n", Num[i],tp->Numbers[i]); - } - for (i = 0; i < STRCOUNT; ++i) { - if (tp->Strings[i] != NULL) { - (void) printf("\t%s=", Str[i]); - for (p = tp->Strings[i]; *p != '\0'; ++p) - (void) fputs(escape(*p), stdout); - (void) fputs(",\n", stdout); - } - } - (void) putchar('\n'); -} - -/*f - * Display error message. - */ -STATIC void -error VARARG1(char*, fmt) -{ - va_list ap; - (void) fprintf(stderr, "%s: ", _cmdname); - va_start(ap, fmt); - (void) vfprintf(stderr, fmt, ap); - va_end(ap); -} - -/*f - * This routine is a codeset independent method of specifying a translation - * from an internal binary value, to an unambiguous printable format. - * This mapping is defined by Table 2-13 in section 2-12 of POSIX.2. - * - * This table has been extended to account for tic/infocmp specification - * of additional characters: <escape>, <space>, <colon>, <caret>, <comma> - */ -char * -escape(c) -int c; -{ - int i; - static char buf[5]; - static int cntl_code[] = { - '\0', '\\', M_ALERT, '\b', '\f', '\n', '\r', '\t', - M_VTAB, M_ESCAPE, ' ', ':', '^', ',', - -1 - }; - static char *cntl_str[] = { - "\\0", "\\\\", "\\a", "\\b", "\\f", "\\n", "\\r", "\\t", - "\\v", "\\E", "\\s", "\\:", "\\^", "\\," - }; - for (i = 0; cntl_code[i] != -1; ++i) - if (c == cntl_code[i]) - return (cntl_str[i]); - if (!isprint(c)) - (void) sprintf(buf, "\\%03.3o", (unsigned char) c); - else - buf[0] = c, buf[1] = '\0'; - return (buf); -} diff --git a/usr/src/lib/udapl/udapl_tavor/tavor/dapl_tavor_hca.c b/usr/src/lib/udapl/udapl_tavor/tavor/dapl_tavor_hca.c index 455bb077a8..5b01e20f39 100644 --- a/usr/src/lib/udapl/udapl_tavor/tavor/dapl_tavor_hca.c +++ b/usr/src/lib/udapl/udapl_tavor/tavor/dapl_tavor_hca.c @@ -68,6 +68,7 @@ static int dapli_process_fake_ibds(DAPL_HCA **hca_list, int hca_idx); static DAPL_OS_LOCK g_tavor_state_lock; static struct dapls_ib_hca_state g_tavor_state[MAX_HCAS]; DAPL_OS_LOCK g_tavor_uar_lock; +DAPL_OS_LOCK dapls_ib_dbp_lock; DAT_RETURN dapli_init_hca( diff --git a/usr/src/lib/udapl/udapl_tavor/tavor/dapl_tavor_ibtf_impl.h b/usr/src/lib/udapl/udapl_tavor/tavor/dapl_tavor_ibtf_impl.h index ef089cccc8..9d0207f640 100644 --- a/usr/src/lib/udapl/udapl_tavor/tavor/dapl_tavor_ibtf_impl.h +++ b/usr/src/lib/udapl/udapl_tavor/tavor/dapl_tavor_ibtf_impl.h @@ -195,7 +195,7 @@ struct dapls_ib_hca_state { char hca_path[MAXPATHLEN]; }; -DAPL_OS_LOCK dapls_ib_dbp_lock; +extern DAPL_OS_LOCK dapls_ib_dbp_lock; /* Function that returns a pointer to the specified doorbell entry */ uint32_t *dapls_ib_get_dbp(uint64_t maplen, int fd, uint64_t mapoffset, diff --git a/usr/src/pkg/manifests/SUNWcs.mf b/usr/src/pkg/manifests/SUNWcs.mf index 7c72d20d26..b67c1defbd 100644 --- a/usr/src/pkg/manifests/SUNWcs.mf +++ b/usr/src/pkg/manifests/SUNWcs.mf @@ -29,6 +29,7 @@ # Copyright 2019 Joyent, Inc. # Copyright (c) 2011, 2015 by Delphix. All rights reserved. # Copyright 2021 OmniOS Community Edition (OmniOSce) Association. +# Copyright 2021 Oxide Computer Company # <include SUNWcs.man1.inc> @@ -479,6 +480,7 @@ file path=lib/inet/nwamd mode=0555 file path=lib/svc/bin/lsvcrun group=sys mode=0555 file path=lib/svc/bin/mfstscan group=sys mode=0555 file path=lib/svc/bin/restore_repository group=sys mode=0555 +file path=lib/svc/bin/rootisramdisk group=sys mode=0555 file path=lib/svc/bin/sqlite group=sys mode=0555 file path=lib/svc/bin/svc.configd group=sys mode=0555 file path=lib/svc/bin/svc.ipfd group=sys mode=0555 diff --git a/usr/src/uts/common/io/bnxe/bnxe_hw.c b/usr/src/uts/common/io/bnxe/bnxe_hw.c index 1ecfb8c734..68bbdc7d6d 100644 --- a/usr/src/uts/common/io/bnxe/bnxe_hw.c +++ b/usr/src/uts/common/io/bnxe/bnxe_hw.c @@ -128,7 +128,7 @@ static boolean_t BnxeRssEnable(um_device_t * pUM) static lm_status_t BnxeRssDisable(um_device_t * pUM) { - int rc; + lm_status_t rc; rc = lm_disable_rss((lm_device_t *)pUM, FALSE, NULL); @@ -146,7 +146,7 @@ static lm_status_t BnxeRssDisable(um_device_t * pUM) BnxeFmErrorReport(pUM, DDI_FM_DEVICE_INVAL_STATE); } - return (rc == LM_STATUS_SUCCESS) ? B_TRUE : B_FALSE; + return (rc); } @@ -693,7 +693,7 @@ void BnxeUpdatePhy(um_device_t * pUM) * This is problematic. For non-PMF functions the lm_niv_vif_set for * a link up will come very early and is queued for processing right * after lm_chip_start. Thereafter setting the loopback mode brings - * the interface back down. Don't know if setting the loopback mode + * the interface back down. Don't know if setting the loopback mode * is even required when forcing it off. XXX */ if (IS_MF_AFEX_MODE(&pUM->lm_dev)) @@ -1300,7 +1300,7 @@ int BnxeHwStartL2(um_device_t * pUM) BnxeLogDbg(pUM, "Setting L2 MAC Address"); - /* use the hw programmed address (GLDv3 will overwrite if needed) */ + /* use the hw programmed address (GLDv3 will overwrite if needed) */ { u8_t zero_mac_addr[ETHERNET_ADDRESS_SIZE]; diff --git a/usr/src/uts/common/io/comstar/lu/stmf_sbd/sbd.c b/usr/src/uts/common/io/comstar/lu/stmf_sbd/sbd.c index 60587bcdf6..88dee95fb8 100644 --- a/usr/src/uts/common/io/comstar/lu/stmf_sbd/sbd.c +++ b/usr/src/uts/common/io/comstar/lu/stmf_sbd/sbd.c @@ -2677,7 +2677,10 @@ sbd_modify_lu(sbd_modify_lu_t *mlu, int struct_sz, uint32_t *err_ret) /* if there is data in the buf, null terminate it */ if (struct_sz > sizeof (*mlu)) { - mlu->mlu_buf[struct_sz - sizeof (*mlu) + 8 - 1] = 0; + char *mlu_buf; + + mlu_buf = &(mlu->mlu_buf[0]); + mlu_buf[struct_sz - sizeof (*mlu) + 8 - 1] = '\0'; } *err_ret = 0; @@ -2904,7 +2907,10 @@ sbd_set_global_props(sbd_global_props_t *mlu, int struct_sz, /* if there is data in the buf, null terminate it */ if (struct_sz > sizeof (*mlu)) { - mlu->mlu_buf[struct_sz - sizeof (*mlu) + 8 - 1] = 0; + char *mlu_buf; + + mlu_buf = &(mlu->mlu_buf[0]); + mlu_buf[struct_sz - sizeof (*mlu) + 8 - 1] = '\0'; } *err_ret = 0; |
