summaryrefslogtreecommitdiff
path: root/usr/src/cmd
diff options
context:
space:
mode:
authorDan McDonald <danmcd@joyent.com>2021-03-10 11:44:24 -0500
committerDan McDonald <danmcd@joyent.com>2021-03-10 11:44:26 -0500
commita7bc083acd38bbad5d7bea081d859b9f3fdd1563 (patch)
treec4a29da3bae00d6dff4d48283fb2bc83732a62d9 /usr/src/cmd
parent7d2d5362a2023f1f710d88f54cc46aa6b2910461 (diff)
parentef1266efec4565fb64aeda150f6100dadde8bca8 (diff)
downloadillumos-joyent-a7bc083acd38bbad5d7bea081d859b9f3fdd1563.tar.gz
[illumos-gate merge]
commit ef1266efec4565fb64aeda150f6100dadde8bca8 13597 ipf: variable may be used uninitialized in this function commit d464f34577edaa31dd6978ec04d66a57529dd2c8 13587 stmf_sbd: array subscript 8 is above array bounds commit e3b270024f3e952233b61d3dcb4129ba75bf2720 13520 udapl_tavor: symbol 'dapls_ib_dbp_lock' is multiply-defined commit 089ef9c1879ed031043f7bb75bd1f472558dcbbf 13576 Add mdb ::linkerset command commit f6c47fdeea63a9c5d1abefdffb93d3f87e12b7d0 13605 ramdisk systems have no boot_archive commit 2587b3a0593a431a99cc2dc78bf1034e672a35e2 13606 tic(1) writes uninitialized data to some terminfo entries commit d893e05e2a64324d7059baefcbf7bd9872a32ad9 13595 logadm: failing to build test programs commit bfbf29e2d493eb4d7f76ee725d3229899602a088 13552 fs.d: multiply-defined symbols commit 19df86dc540ec91584176ab69b765edae4562731 13613 ipkg platform.xml missing /dev/signalfd commit 8993acd7cf0075cbfaf6df95d292f897079b5618 13591 bnxe: implicit conversion from 'enum <anonymous>' to 'lm_status_t' Conflicts: usr/src/cmd/mdb/common/mdb/mdb_cmds.c
Diffstat (limited to 'usr/src/cmd')
-rw-r--r--usr/src/cmd/Makefile.cmd1
-rw-r--r--usr/src/cmd/boot/scripts/boot-archive-update.ksh10
-rw-r--r--usr/src/cmd/fs.d/autofs/autod_main.c1
-rw-r--r--usr/src/cmd/fs.d/autofs/automount.h10
-rw-r--r--usr/src/cmd/fs.d/autofs/ns_files.c5
-rw-r--r--usr/src/cmd/fs.d/udfs/fsck/fsck.h117
-rw-r--r--usr/src/cmd/fs.d/udfs/fsck/main.c26
-rw-r--r--usr/src/cmd/fs.d/udfs/fsck/pass1.c4
-rw-r--r--usr/src/cmd/fs.d/udfs/fsck/setup.c36
-rw-r--r--usr/src/cmd/fs.d/udfs/fsck/utilities.c4
-rw-r--r--usr/src/cmd/fs.d/ufs/fsck/fsck.h132
-rw-r--r--usr/src/cmd/fs.d/ufs/fsck/inode.c10
-rw-r--r--usr/src/cmd/fs.d/ufs/fsck/main.c35
-rw-r--r--usr/src/cmd/fs.d/ufs/fsck/setup.c16
-rw-r--r--usr/src/cmd/fs.d/ufs/fsck/utilities.c12
-rwxr-xr-xusr/src/cmd/ipf/lib/common/printhash_live.c4
-rw-r--r--usr/src/cmd/ipf/lib/common/printpool_live.c4
-rw-r--r--usr/src/cmd/ipf/tools/ipfstat.c3
-rw-r--r--usr/src/cmd/logadm/conf.c6
-rw-r--r--usr/src/cmd/mdb/Makefile.kmdb.files8
-rw-r--r--usr/src/cmd/mdb/Makefile.mdb4
-rw-r--r--usr/src/cmd/mdb/common/mdb/mdb.c9
-rw-r--r--usr/src/cmd/mdb/common/mdb/mdb_cmds.c5
-rw-r--r--usr/src/cmd/mdb/common/mdb/mdb_linkerset.c500
-rw-r--r--usr/src/cmd/mdb/common/mdb/mdb_linkerset.h42
-rw-r--r--usr/src/cmd/mdb/common/mdb/mdb_walkers.c24
-rw-r--r--usr/src/cmd/svc/Makefile6
-rw-r--r--usr/src/cmd/svc/configd/Makefile8
-rw-r--r--usr/src/cmd/svc/lsvcrun/Makefile11
-rw-r--r--usr/src/cmd/svc/mfstscan/Makefile11
-rw-r--r--usr/src/cmd/svc/milestone/boot-archive10
-rw-r--r--usr/src/cmd/svc/rootisramdisk/Makefile37
-rw-r--r--usr/src/cmd/svc/rootisramdisk/rootisramdisk.c86
-rw-r--r--usr/src/cmd/svc/shell/smf_include.sh10
-rw-r--r--usr/src/cmd/svc/startd/Makefile4
-rw-r--r--usr/src/cmd/tic/Makefile.common3
-rw-r--r--usr/src/cmd/tic/tic_main.c46
-rw-r--r--usr/src/cmd/tic/tic_parse.c70
-rw-r--r--usr/src/cmd/tic/tic_read.c20
-rw-r--r--usr/src/cmd/tic/tic_scan.c4
40 files changed, 1052 insertions, 302 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()
{