summaryrefslogtreecommitdiff
path: root/usr/src
diff options
context:
space:
mode:
authorJohn Sonnenschein <johns@joyent.com>2012-07-30 18:55:21 +0000
committerJohn Sonnenschein <johns@joyent.com>2012-07-30 18:55:21 +0000
commit3f12efe73c075bbfe7e254714e8fabfb50f86af0 (patch)
treef429351c58a9955c46f03b8789bce1e152d32660 /usr/src
parent2453263d59c2317dbe88d1c9e12893a32abd91b8 (diff)
parent5ada8a07255938930de285f1d55b0ef0bdba90ff (diff)
downloadillumos-joyent-3f12efe73c075bbfe7e254714e8fabfb50f86af0.tar.gz
Illumos Sync
Merge github.com:illumos/illumos-gate Conflicts: exception_lists/check_rtime usr/src/Makefile.master usr/src/Makefile.master.64 usr/src/cmd/Makefile usr/src/cmd/lms/Makefile usr/src/cmd/lp/Makefile.lp usr/src/cmd/mdb/Makefile.mdb usr/src/cmd/mdb/common/mdb/mdb_cmds.c usr/src/cmd/mdb/common/mdb/mdb_print.c usr/src/cmd/mdb/common/mdb/mdb_print.h usr/src/cmd/mdb/common/mdb/mdb_tab.c usr/src/cmd/mdb/common/mdb/mdb_termio.c usr/src/cmd/mdb/common/mdb/mdb_whatis.c usr/src/cmd/svc/svccfg/svccfg_libscf.c usr/src/cmd/zpool/zpool_main.c usr/src/lib/Makefile usr/src/lib/libc/inc/thr_inlines.h usr/src/lib/libc/port/mapfile-vers usr/src/lib/libc/sparc/Makefile.com usr/src/lib/libc/sparc/crt/_rtld.c usr/src/lib/libc/sparcv9/Makefile.com usr/src/lib/libdtrace/common/dt_open.c usr/src/lib/libdtrace/common/dt_options.c usr/src/lib/libumem/common/envvar.c usr/src/lib/libumem/common/vmem_base.c usr/src/lib/libzfs/common/libzfs_impl.h usr/src/lib/libzfs/common/libzfs_iter.c usr/src/lib/libzfs/common/libzfs_util.c usr/src/lib/libzfs/common/mapfile-vers usr/src/lib/sun_fc/Makefile.com usr/src/lib/sun_fc/amd64/Makefile usr/src/lib/sun_fc/sparcv9/Makefile usr/src/man/man1m/Makefile usr/src/uts/common/Makefile.files usr/src/uts/common/dtrace/dtrace.c usr/src/uts/common/fs/zfs/arc.c usr/src/uts/common/fs/zfs/dmu.c usr/src/uts/common/fs/zfs/dsl_dataset.c usr/src/uts/common/fs/zfs/dsl_pool.c usr/src/uts/common/fs/zfs/sys/zio.h usr/src/uts/common/io/fibre-channel/fca/fcoei/fcoei_eth.c usr/src/uts/common/io/fibre-channel/fca/fcoei/fcoei_lv.c usr/src/uts/common/sys/dtrace.h
Diffstat (limited to 'usr/src')
-rw-r--r--usr/src/Makefile.lint2
-rw-r--r--usr/src/Makefile.master69
-rw-r--r--usr/src/Makefile.master.642
-rw-r--r--usr/src/Targetdirs18
-rw-r--r--usr/src/cmd/Makefile2
-rw-r--r--usr/src/cmd/abi/appcert/etc/etc.warn.in4
-rw-r--r--usr/src/cmd/auditreduce/option.c14
-rw-r--r--usr/src/cmd/beadm/beadm.c90
-rw-r--r--usr/src/cmd/boot/scripts/root_archive.ksh585
-rw-r--r--usr/src/cmd/cmd-inet/etc/services98
-rw-r--r--usr/src/cmd/cmd-inet/lib/nwamd/door_if.c3
-rw-r--r--usr/src/cmd/cmd-inet/lib/nwamd/known_wlans.c26
-rw-r--r--usr/src/cmd/cmd-inet/lib/nwamd/ncu_phys.c175
-rw-r--r--usr/src/cmd/cmd-inet/usr.bin/rcp.c2
-rw-r--r--usr/src/cmd/cmd-inet/usr.sbin/ipadm/ipadm.c17
-rw-r--r--usr/src/cmd/cmd-inet/usr.sbin/ipsecutils/ipsecalgs.xml20
-rw-r--r--usr/src/cmd/cmd-inet/usr.sbin/nwamadm/nwamadm.c2
-rw-r--r--usr/src/cmd/cmd-inet/usr.sbin/snoop/snoop_capture.c4
-rw-r--r--usr/src/cmd/cmd-inet/usr.sbin/snoop/snoop_filter.c12
-rw-r--r--usr/src/cmd/cmd-inet/usr.sbin/snoop/snoop_ip.c3
-rw-r--r--usr/src/cmd/cmd-inet/usr.sbin/snoop/snoop_pf.c10
-rw-r--r--usr/src/cmd/cmd-inet/usr.sbin/snoop/snoop_rpcsec.c81
-rw-r--r--usr/src/cmd/dtrace/dtrace.c6
-rw-r--r--usr/src/cmd/dtrace/test/cmd/scripts/dtest.pl3
-rw-r--r--usr/src/cmd/dtrace/test/tst/common/aggs/tst.sizedkeys.d35
-rw-r--r--usr/src/cmd/dtrace/test/tst/common/aggs/tst.sizedkeys.d.out6
-rw-r--r--usr/src/cmd/dtrace/test/tst/common/arithmetic/tst.basics.d.out8
-rw-r--r--usr/src/cmd/dtrace/test/tst/common/arithmetic/tst.compcast.d50
-rw-r--r--usr/src/cmd/dtrace/test/tst/common/arithmetic/tst.compcast.d.out10
-rw-r--r--usr/src/cmd/dtrace/test/tst/common/arithmetic/tst.complex.d57
-rw-r--r--usr/src/cmd/dtrace/test/tst/common/arithmetic/tst.compnarrowassign.d36
-rw-r--r--usr/src/cmd/dtrace/test/tst/common/arithmetic/tst.compnarrowassign.d.out1
-rw-r--r--usr/src/cmd/dtrace/test/tst/common/arithmetic/tst.execcast.d52
-rw-r--r--usr/src/cmd/dtrace/test/tst/common/arithmetic/tst.execcast.d.out10
-rw-r--r--usr/src/cmd/dtrace/test/tst/common/buffering/tst.fill1.d17
-rw-r--r--usr/src/cmd/dtrace/test/tst/common/buffering/tst.ring3.d28
-rw-r--r--usr/src/cmd/dtrace/test/tst/common/cg/err.D_NOREG.noreg.d41
-rw-r--r--usr/src/cmd/dtrace/test/tst/common/cg/err.baddif.d44
-rw-r--r--usr/src/cmd/dtrace/test/tst/common/env/err.D_PRAGMA_OPTSET.setfromscript.d25
-rw-r--r--usr/src/cmd/dtrace/test/tst/common/env/err.D_PRAGMA_OPTSET.unsetfromscript.d25
-rw-r--r--usr/src/cmd/dtrace/test/tst/common/env/tst.ld_nolazyload.ksh33
-rw-r--r--usr/src/cmd/dtrace/test/tst/common/env/tst.ld_nolazyload.ksh.out2
-rw-r--r--usr/src/cmd/dtrace/test/tst/common/env/tst.setenv1.ksh33
-rw-r--r--usr/src/cmd/dtrace/test/tst/common/env/tst.setenv1.ksh.out2
-rw-r--r--usr/src/cmd/dtrace/test/tst/common/env/tst.setenv2.ksh33
-rw-r--r--usr/src/cmd/dtrace/test/tst/common/env/tst.setenv2.ksh.out2
-rw-r--r--usr/src/cmd/dtrace/test/tst/common/env/tst.unsetenv1.ksh33
-rw-r--r--usr/src/cmd/dtrace/test/tst/common/env/tst.unsetenv1.ksh.out1
-rw-r--r--usr/src/cmd/dtrace/test/tst/common/env/tst.unsetenv2.ksh35
-rw-r--r--usr/src/cmd/dtrace/test/tst/common/env/tst.unsetenv2.ksh.out1
-rw-r--r--usr/src/cmd/dtrace/test/tst/common/pid/tst.newprobes.ksh8
-rw-r--r--usr/src/cmd/dtrace/test/tst/common/pointers/tst.assigncast1.d28
-rw-r--r--usr/src/cmd/dtrace/test/tst/common/pointers/tst.assigncast2.d29
-rw-r--r--usr/src/cmd/dtrace/test/tst/common/pragma/tst.temporal.ksh106
-rw-r--r--usr/src/cmd/dtrace/test/tst/common/pragma/tst.temporal2.ksh102
-rw-r--r--usr/src/cmd/dtrace/test/tst/common/pragma/tst.temporal3.d48
-rw-r--r--usr/src/cmd/dtrace/test/tst/common/predicates/tst.predcache.ksh197
-rw-r--r--usr/src/cmd/dtrace/test/tst/common/print/tst.dyn.d28
-rw-r--r--usr/src/cmd/dtrace/test/tst/common/print/tst.xlate.d42
-rw-r--r--usr/src/cmd/dtrace/test/tst/common/print/tst.xlate.d.out8
-rw-r--r--usr/src/cmd/dtrace/test/tst/common/printf/tst.ints.d.out4
-rw-r--r--usr/src/cmd/dtrace/test/tst/common/printf/tst.signs.d38
-rw-r--r--usr/src/cmd/dtrace/test/tst/common/printf/tst.signs.d.out3
-rw-r--r--usr/src/cmd/dtrace/test/tst/common/speculation/err.BufSizeVariations1.d14
-rw-r--r--usr/src/cmd/dtrace/test/tst/common/speculation/tst.SpecSizeVariations3.d7
-rw-r--r--usr/src/cmd/dtrace/test/tst/common/trace/err.D_TRACE_DYN.bad.d29
-rw-r--r--usr/src/cmd/dtrace/test/tst/common/trace/tst.dyn.d28
-rw-r--r--usr/src/cmd/dtrace/test/tst/common/translators/man.TestTransStability.d61
-rw-r--r--usr/src/cmd/dtrace/test/tst/common/translators/tst.TestTransStability1.ksh62
-rw-r--r--usr/src/cmd/dtrace/test/tst/common/translators/tst.TestTransStability1.ksh.out14
-rw-r--r--usr/src/cmd/dtrace/test/tst/common/translators/tst.TestTransStability2.ksh60
-rw-r--r--usr/src/cmd/dtrace/test/tst/common/translators/tst.TestTransStability2.ksh.out14
-rw-r--r--usr/src/cmd/file/magic2
-rw-r--r--usr/src/cmd/format/menu_command.c32
-rw-r--r--usr/src/cmd/fs.d/hsfs/fstyp/fstyp.c8
-rw-r--r--usr/src/cmd/fs.d/hsfs/fstyp/hsfs_spec.h268
-rw-r--r--usr/src/cmd/fs.d/hsfs/fstyp/iso_impl.h137
-rw-r--r--usr/src/cmd/fs.d/hsfs/fstyp/iso_spec.h359
-rw-r--r--usr/src/cmd/fs.d/hsfs/labelit/hsfs_spec.h269
-rw-r--r--usr/src/cmd/fs.d/hsfs/labelit/iso_impl.h137
-rw-r--r--usr/src/cmd/fs.d/hsfs/labelit/iso_spec.h359
-rw-r--r--usr/src/cmd/fs.d/hsfs/labelit/labelit.c15
-rw-r--r--usr/src/cmd/fs.d/nfs/svc/Makefile6
-rw-r--r--usr/src/cmd/fs.d/nfs/svc/nfs-server21
-rw-r--r--usr/src/cmd/fs.d/nfs/svc/nfslogd.xml68
-rw-r--r--usr/src/cmd/genmsg/genmsg.l4
-rw-r--r--usr/src/cmd/hal/hald-runner/main.c68
-rw-r--r--usr/src/cmd/hal/hald-runner/runner.c49
-rw-r--r--usr/src/cmd/hal/hald-runner/runner.h5
-rw-r--r--usr/src/cmd/isns/isnsd/Makefile8
-rw-r--r--usr/src/cmd/itutools/Makefile88
-rw-r--r--usr/src/cmd/itutools/itu.ksh1245
-rw-r--r--usr/src/cmd/itutools/mkbootmedia.ksh192
-rw-r--r--usr/src/cmd/itutools/pkg2du.ksh438
-rw-r--r--usr/src/cmd/itutools/updatemedia.ksh478
-rw-r--r--usr/src/cmd/lms/Makefile2
-rw-r--r--usr/src/cmd/ls/ls.c35
-rw-r--r--usr/src/cmd/mdb/Makefile.kmdb.files1
-rw-r--r--usr/src/cmd/mdb/Makefile.mdb2
-rw-r--r--usr/src/cmd/mdb/common/mdb/mdb.c5
-rw-r--r--usr/src/cmd/mdb/common/mdb/mdb.h5
-rw-r--r--usr/src/cmd/mdb/common/mdb/mdb_cmds.c5
-rw-r--r--usr/src/cmd/mdb/common/mdb/mdb_main.c13
-rw-r--r--usr/src/cmd/mdb/common/mdb/mdb_module.h5
-rw-r--r--usr/src/cmd/mdb/common/mdb/mdb_print.c58
-rw-r--r--usr/src/cmd/mdb/common/mdb/mdb_print.h5
-rw-r--r--usr/src/cmd/mdb/common/mdb/mdb_tab.c1
-rw-r--r--usr/src/cmd/mdb/common/mdb/mdb_termio.c10
-rw-r--r--usr/src/cmd/mdb/common/mdb/mdb_whatis.c5
-rw-r--r--usr/src/cmd/mdb/common/modules/sockfs/sockfs.c14
-rw-r--r--usr/src/cmd/mdb/common/modules/zfs/zfs.c10
-rw-r--r--usr/src/cmd/mpathadm/mpathadm.c2
-rw-r--r--usr/src/cmd/pgrep/pgrep.c16
-rw-r--r--usr/src/cmd/power/Makefile2
-rw-r--r--usr/src/cmd/psrinfo/Makefile9
-rw-r--r--usr/src/cmd/psrinfo/psrinfo.c655
-rw-r--r--usr/src/cmd/psrinfo/psrinfo.pl853
-rw-r--r--usr/src/cmd/savecore/savecore.c23
-rw-r--r--usr/src/cmd/smbsrv/smbd/Makefile3
-rw-r--r--usr/src/cmd/smbsrv/smbd/smbd_spool.c50
-rw-r--r--usr/src/cmd/su/su.c5
-rw-r--r--usr/src/cmd/svc/configd/restore_repository.sh3
-rw-r--r--usr/src/cmd/svc/startd/Makefile2
-rw-r--r--usr/src/cmd/svc/startd/libscf.c5
-rw-r--r--usr/src/cmd/svc/svccfg/svccfg_libscf.c19
-rw-r--r--usr/src/cmd/tail/Makefile2
-rw-r--r--usr/src/cmd/tar/tar.c138
-rw-r--r--usr/src/cmd/truss/codes.c13
-rw-r--r--usr/src/cmd/vi/port/ex_cmdsub.c5
-rw-r--r--usr/src/cmd/zdb/zdb.c113
-rw-r--r--usr/src/cmd/zfs/Makefile7
-rw-r--r--usr/src/cmd/zfs/zfs_main.c105
-rw-r--r--usr/src/cmd/zhack/Makefile57
-rw-r--r--usr/src/cmd/zhack/Makefile.com67
-rw-r--r--usr/src/cmd/zhack/amd64/Makefile30
-rw-r--r--usr/src/cmd/zhack/i386/Makefile (renamed from usr/src/lib/libldap4/sparc/Makefile)15
-rw-r--r--usr/src/cmd/zhack/sparcv9/Makefile30
-rw-r--r--usr/src/cmd/zhack/zhack.c540
-rw-r--r--usr/src/cmd/zpool/zpool_main.c753
-rw-r--r--usr/src/cmd/ztest/Makefile.com6
-rw-r--r--usr/src/cmd/ztest/ztest.c66
-rw-r--r--usr/src/common/nvpair/fnvpair.c496
-rw-r--r--usr/src/common/zfs/zfeature_common.c156
-rw-r--r--usr/src/common/zfs/zfeature_common.h71
-rw-r--r--usr/src/common/zfs/zfs_comutil.c7
-rw-r--r--usr/src/common/zfs/zfs_comutil.h4
-rw-r--r--usr/src/common/zfs/zpool_prop.c22
-rw-r--r--usr/src/common/zfs/zprop_common.c6
-rw-r--r--usr/src/grub/capability4
-rw-r--r--usr/src/grub/grub-0.97/stage2/fsys_zfs.c422
-rw-r--r--usr/src/grub/grub-0.97/stage2/fsys_zfs.h40
-rw-r--r--usr/src/grub/grub-0.97/stage2/zfs-include/dmu.h70
-rw-r--r--usr/src/grub/grub-0.97/stage2/zfs-include/spa.h7
-rw-r--r--usr/src/grub/grub-0.97/stage2/zfs-include/zfs.h12
-rw-r--r--usr/src/head/iso/setjmp_iso.h11
-rw-r--r--usr/src/head/setjmp.h6
-rw-r--r--usr/src/head/ucontext.h6
-rw-r--r--usr/src/head/unistd.h2
-rw-r--r--usr/src/lib/Makefile10
-rw-r--r--usr/src/lib/fm/topo/modules/common/ses/ses.c12
-rw-r--r--usr/src/lib/fm/topo/modules/i86pc/chip/chip_amd.c6
-rw-r--r--usr/src/lib/hal/libhal/common/libhal.c170
-rw-r--r--usr/src/lib/libc/inc/thr_inlines.h19
-rw-r--r--usr/src/lib/libc/port/gen/privlib.c4
-rw-r--r--usr/src/lib/libc/port/mapfile-vers7
-rw-r--r--usr/src/lib/libc/port/threads/assfail.c19
-rw-r--r--usr/src/lib/libc/port/unwind/unwind.c10
-rw-r--r--usr/src/lib/libc/sparc/crt/_rtboot.s2
-rw-r--r--usr/src/lib/libc/sparc/crt/_rtld.c2
-rw-r--r--usr/src/lib/libctf/common/ctf_lib.c2
-rw-r--r--usr/src/lib/libdtrace/Makefile.com3
-rw-r--r--usr/src/lib/libdtrace/common/dt_aggregate.c30
-rw-r--r--usr/src/lib/libdtrace/common/dt_cc.c86
-rw-r--r--usr/src/lib/libdtrace/common/dt_cg.c345
-rw-r--r--usr/src/lib/libdtrace/common/dt_consume.c457
-rw-r--r--usr/src/lib/libdtrace/common/dt_dis.c23
-rw-r--r--usr/src/lib/libdtrace/common/dt_error.c6
-rw-r--r--usr/src/lib/libdtrace/common/dt_errtags.h5
-rw-r--r--usr/src/lib/libdtrace/common/dt_impl.h12
-rw-r--r--usr/src/lib/libdtrace/common/dt_open.c14
-rw-r--r--usr/src/lib/libdtrace/common/dt_options.c60
-rw-r--r--usr/src/lib/libdtrace/common/dt_parser.c110
-rw-r--r--usr/src/lib/libdtrace/common/dt_pq.c157
-rw-r--r--usr/src/lib/libdtrace/common/dt_pq.h51
-rw-r--r--usr/src/lib/libdtrace/common/dt_printf.c5
-rw-r--r--usr/src/lib/libdtrace/common/dt_proc.c68
-rw-r--r--usr/src/lib/libdtrace/common/dt_proc.h10
-rw-r--r--usr/src/lib/libdtrace/common/dt_regset.c37
-rw-r--r--usr/src/lib/libdtrace/common/dt_regset.h8
-rw-r--r--usr/src/lib/libdtrace/common/dt_subr.c5
-rw-r--r--usr/src/lib/libdtrace/i386/dt_isadep.c7
-rw-r--r--usr/src/lib/libidmap/common/idmap_api.c22
-rw-r--r--usr/src/lib/libldap4/Makefile.com113
-rw-r--r--usr/src/lib/libldap4/THIRDPARTYLICENSE19
-rw-r--r--usr/src/lib/libldap4/THIRDPARTYLICENSE.descrip1
-rw-r--r--usr/src/lib/libldap4/ber/Version.c20
-rw-r--r--usr/src/lib/libldap4/ber/bprint.c67
-rw-r--r--usr/src/lib/libldap4/ber/decode.c630
-rw-r--r--usr/src/lib/libldap4/ber/encode.c658
-rw-r--r--usr/src/lib/libldap4/ber/i18n.c27
-rw-r--r--usr/src/lib/libldap4/ber/io.c683
-rw-r--r--usr/src/lib/libldap4/common/Version.c20
-rw-r--r--usr/src/lib/libldap4/common/abandon.c267
-rw-r--r--usr/src/lib/libldap4/common/add.c270
-rw-r--r--usr/src/lib/libldap4/common/addentry.c63
-rw-r--r--usr/src/lib/libldap4/common/bind.c145
-rw-r--r--usr/src/lib/libldap4/common/cache.c714
-rw-r--r--usr/src/lib/libldap4/common/charset.c1869
-rw-r--r--usr/src/lib/libldap4/common/cldap.c597
-rw-r--r--usr/src/lib/libldap4/common/compare.c259
-rw-r--r--usr/src/lib/libldap4/common/controls.c291
-rw-r--r--usr/src/lib/libldap4/common/delete.c203
-rw-r--r--usr/src/lib/libldap4/common/disptmpl.c751
-rw-r--r--usr/src/lib/libldap4/common/dsparse.c214
-rw-r--r--usr/src/lib/libldap4/common/error.c345
-rw-r--r--usr/src/lib/libldap4/common/extensions.c79
-rw-r--r--usr/src/lib/libldap4/common/extop.c156
-rw-r--r--usr/src/lib/libldap4/common/free.c106
-rw-r--r--usr/src/lib/libldap4/common/friendly.c142
-rw-r--r--usr/src/lib/libldap4/common/getattr.c107
-rw-r--r--usr/src/lib/libldap4/common/getdn.c412
-rw-r--r--usr/src/lib/libldap4/common/getdxbyname.c227
-rw-r--r--usr/src/lib/libldap4/common/getentry.c82
-rw-r--r--usr/src/lib/libldap4/common/getfilter.c447
-rw-r--r--usr/src/lib/libldap4/common/getmsg.c40
-rw-r--r--usr/src/lib/libldap4/common/getref.c79
-rw-r--r--usr/src/lib/libldap4/common/getvalues.c183
-rw-r--r--usr/src/lib/libldap4/common/kbind.c349
-rw-r--r--usr/src/lib/libldap4/common/llib-lldap317
-rw-r--r--usr/src/lib/libldap4/common/mapfile-vers229
-rw-r--r--usr/src/lib/libldap4/common/modify.c246
-rw-r--r--usr/src/lib/libldap4/common/modrdn.c118
-rw-r--r--usr/src/lib/libldap4/common/notif.c106
-rw-r--r--usr/src/lib/libldap4/common/open.c433
-rw-r--r--usr/src/lib/libldap4/common/option.c243
-rw-r--r--usr/src/lib/libldap4/common/os-ip.c614
-rw-r--r--usr/src/lib/libldap4/common/referral.c511
-rw-r--r--usr/src/lib/libldap4/common/regex.c923
-rw-r--r--usr/src/lib/libldap4/common/rename.c176
-rw-r--r--usr/src/lib/libldap4/common/request.c779
-rw-r--r--usr/src/lib/libldap4/common/result.c1657
-rw-r--r--usr/src/lib/libldap4/common/saslbind.c340
-rw-r--r--usr/src/lib/libldap4/common/sbind.c171
-rw-r--r--usr/src/lib/libldap4/common/search.c939
-rw-r--r--usr/src/lib/libldap4/common/sort.c180
-rw-r--r--usr/src/lib/libldap4/common/sortctrl.c426
-rw-r--r--usr/src/lib/libldap4/common/srchpref.c430
-rw-r--r--usr/src/lib/libldap4/common/tmplout.c1176
-rw-r--r--usr/src/lib/libldap4/common/ufn.c594
-rw-r--r--usr/src/lib/libldap4/common/unbind.c216
-rw-r--r--usr/src/lib/libldap4/common/url.c836
-rw-r--r--usr/src/lib/libldap4/common/utils.c28
-rw-r--r--usr/src/lib/libldap4/common/version.c20
-rw-r--r--usr/src/lib/libldap4/common/vlistctrl.c124
-rw-r--r--usr/src/lib/libldap4/include/avl.h65
-rw-r--r--usr/src/lib/libldap4/include/cdefs.h129
-rw-r--r--usr/src/lib/libldap4/include/ch_malloc.h12
-rw-r--r--usr/src/lib/libldap4/include/charray.h23
-rw-r--r--usr/src/lib/libldap4/include/client_door.h15
-rw-r--r--usr/src/lib/libldap4/include/entry.h271
-rw-r--r--usr/src/lib/libldap4/include/fe.h420
-rw-r--r--usr/src/lib/libldap4/include/hsearch.h53
-rw-r--r--usr/src/lib/libldap4/include/lber.h240
-rw-r--r--usr/src/lib/libldap4/include/ldap-int.h343
-rw-r--r--usr/src/lib/libldap4/include/ldap-private.h360
-rw-r--r--usr/src/lib/libldap4/include/ldap.h1375
-rw-r--r--usr/src/lib/libldap4/include/ldapconfig.h279
-rw-r--r--usr/src/lib/libldap4/include/ldif.h65
-rw-r--r--usr/src/lib/libldap4/include/log.h65
-rw-r--r--usr/src/lib/libldap4/include/lthread.h187
-rw-r--r--usr/src/lib/libldap4/include/portable.h224
-rw-r--r--usr/src/lib/libldap4/include/regex.h52
-rw-r--r--usr/src/lib/libldap4/include/sec.h25
-rw-r--r--usr/src/lib/libldap4/include/ssl.h41
-rw-r--r--usr/src/lib/libldap4/include/sysexits-compat.h111
-rw-r--r--usr/src/lib/libldap4/include/thq.h75
-rw-r--r--usr/src/lib/libldap4/misc/ldapfilter.conf112
-rw-r--r--usr/src/lib/libldap4/misc/ldapfriendly249
-rw-r--r--usr/src/lib/libldap4/misc/ldapsearchprefs.conf160
-rw-r--r--usr/src/lib/libldap4/misc/ldaptemplates.conf684
-rw-r--r--usr/src/lib/libldap4/sec/cram_md5.c62
-rw-r--r--usr/src/lib/libldap4/sec/secutil.c63
-rw-r--r--usr/src/lib/libldap4/util/line64.c388
-rw-r--r--usr/src/lib/libldap4/util/log.c168
-rw-r--r--usr/src/lib/libnisdb/ldap_op.c14
-rw-r--r--usr/src/lib/libnvpair/Makefile.com8
-rw-r--r--usr/src/lib/libnvpair/libnvpair.c5
-rw-r--r--usr/src/lib/libnvpair/mapfile-vers68
-rw-r--r--usr/src/lib/libscf/common/scf_tmpl.c12
-rw-r--r--usr/src/lib/libshare/smb/Makefile.com3
-rw-r--r--usr/src/lib/libshare/smb/libshare_smb.c25
-rw-r--r--usr/src/lib/libumem/common/envvar.c1
-rw-r--r--usr/src/lib/libumem/common/vmem_base.c2
-rw-r--r--usr/src/lib/libuuid/common/uuid.c8
-rw-r--r--usr/src/lib/libzfs/Makefile.com5
-rw-r--r--usr/src/lib/libzfs/common/libzfs.h51
-rw-r--r--usr/src/lib/libzfs/common/libzfs_config.c83
-rw-r--r--usr/src/lib/libzfs/common/libzfs_dataset.c303
-rw-r--r--usr/src/lib/libzfs/common/libzfs_impl.h10
-rw-r--r--usr/src/lib/libzfs/common/libzfs_iter.c8
-rw-r--r--usr/src/lib/libzfs/common/libzfs_pool.c287
-rw-r--r--usr/src/lib/libzfs/common/libzfs_sendrecv.c103
-rw-r--r--usr/src/lib/libzfs/common/libzfs_status.c43
-rw-r--r--usr/src/lib/libzfs/common/libzfs_util.c43
-rw-r--r--usr/src/lib/libzfs/common/llib-lzfs6
-rw-r--r--usr/src/lib/libzfs/common/mapfile-vers12
-rw-r--r--usr/src/lib/libzfs_core/Makefile (renamed from usr/src/lib/libldap4/Makefile)31
-rw-r--r--usr/src/lib/libzfs_core/Makefile.com69
-rw-r--r--usr/src/lib/libzfs_core/amd64/Makefile (renamed from usr/src/lib/libldap4/amd64/Makefile)17
-rw-r--r--usr/src/lib/libzfs_core/common/libzfs_core.c477
-rw-r--r--usr/src/lib/libzfs_core/common/libzfs_core.h62
-rw-r--r--usr/src/lib/libzfs_core/common/llib-lzfs_core (renamed from usr/src/cmd/dtrace/test/tst/common/print/err.D_PRINT_DYN.bad.d)11
-rw-r--r--usr/src/lib/libzfs_core/common/mapfile-vers56
-rw-r--r--usr/src/lib/libzfs_core/i386/Makefile (renamed from usr/src/lib/libldap4/i386/Makefile)15
-rw-r--r--usr/src/lib/libzfs_core/sparc/Makefile29
-rw-r--r--usr/src/lib/libzfs_core/sparcv9/Makefile (renamed from usr/src/lib/libldap4/sparcv9/Makefile)15
-rw-r--r--usr/src/lib/libzpool/common/kernel.c12
-rw-r--r--usr/src/lib/libzpool/common/llib-lzpool6
-rw-r--r--usr/src/lib/libzpool/common/sys/zfs_context.h9
-rw-r--r--usr/src/lib/smbsrv/libmlsvc/Makefile.com3
-rw-r--r--usr/src/lib/smbsrv/libmlsvc/common/spoolss_svc.c27
-rw-r--r--usr/src/lib/sun_fc/Makefile.com12
-rw-r--r--usr/src/lib/sun_fc/amd64/Makefile2
-rw-r--r--usr/src/lib/sun_fc/sparcv9/Makefile2
-rw-r--r--usr/src/man/man1/tar.1107
-rw-r--r--usr/src/man/man1m/Makefile6
-rw-r--r--usr/src/man/man1m/beadm.1m126
-rw-r--r--usr/src/man/man1m/itu.1m321
-rw-r--r--usr/src/man/man1m/mkbootmedia.1m120
-rw-r--r--usr/src/man/man1m/pkg2du.1m150
-rw-r--r--usr/src/man/man1m/root_archive.1m96
-rw-r--r--usr/src/man/man1m/updatemedia.1m145
-rw-r--r--usr/src/man/man1m/zfs.1m19
-rw-r--r--usr/src/man/man1m/zpool.1m139
-rw-r--r--usr/src/man/man3malloc/umem_alloc.3malloc25
-rw-r--r--usr/src/man/man5/Makefile202
-rw-r--r--usr/src/man/man5/zpool-features.5173
-rw-r--r--usr/src/pkg/manifests/SUNWarbel.mf7
-rw-r--r--usr/src/pkg/manifests/SUNWcs.man1m.inc5
-rw-r--r--usr/src/pkg/manifests/SUNWcs.mf6
-rw-r--r--usr/src/pkg/manifests/driver-network-arbel.mf10
-rw-r--r--usr/src/pkg/manifests/driver-network-ixgbe.mf4
-rw-r--r--usr/src/pkg/manifests/driver-network-yge.mf1
-rw-r--r--usr/src/pkg/manifests/driver-serial-usbftdi.mf3
-rw-r--r--usr/src/pkg/manifests/service-file-system-nfs.mf2
-rw-r--r--usr/src/pkg/manifests/system-dtrace-tests.mf53
-rw-r--r--usr/src/pkg/manifests/system-file-system-zfs-tests.mf4
-rw-r--r--usr/src/pkg/manifests/system-file-system-zfs.mf19
-rw-r--r--usr/src/pkg/manifests/system-header.mf2
-rw-r--r--usr/src/pkg/manifests/system-library.mf4
-rw-r--r--usr/src/tools/ctf/cvt/dwarf.c118
-rw-r--r--usr/src/tools/cw/Makefile6
-rw-r--r--usr/src/tools/cw/cw.c5
-rw-r--r--usr/src/tools/env/illumos.sh3
-rw-r--r--usr/src/tools/scripts/git-pbchk.py18
-rw-r--r--usr/src/ucbhead/setjmp.h10
-rw-r--r--usr/src/uts/Makefile.uts1
-rw-r--r--usr/src/uts/common/Makefile.files18
-rw-r--r--usr/src/uts/common/dtrace/dtrace.c227
-rw-r--r--usr/src/uts/common/fs/hsfs/hsfs_vfsops.c3
-rw-r--r--usr/src/uts/common/fs/nfs/nfs4_state.c10
-rw-r--r--usr/src/uts/common/fs/smbsrv/smb_print.c13
-rw-r--r--usr/src/uts/common/fs/smbsrv/smb_server.c16
-rw-r--r--usr/src/uts/common/fs/zfs/arc.c55
-rw-r--r--usr/src/uts/common/fs/zfs/bptree.c224
-rw-r--r--usr/src/uts/common/fs/zfs/dbuf.c3
-rw-r--r--usr/src/uts/common/fs/zfs/ddt.c9
-rw-r--r--usr/src/uts/common/fs/zfs/dmu.c126
-rw-r--r--usr/src/uts/common/fs/zfs/dmu_objset.c297
-rw-r--r--usr/src/uts/common/fs/zfs/dmu_send.c380
-rw-r--r--usr/src/uts/common/fs/zfs/dmu_traverse.c107
-rw-r--r--usr/src/uts/common/fs/zfs/dmu_tx.c7
-rw-r--r--usr/src/uts/common/fs/zfs/dnode.c19
-rw-r--r--usr/src/uts/common/fs/zfs/dnode_sync.c4
-rw-r--r--usr/src/uts/common/fs/zfs/dsl_dataset.c312
-rw-r--r--usr/src/uts/common/fs/zfs/dsl_deleg.c36
-rw-r--r--usr/src/uts/common/fs/zfs/dsl_dir.c72
-rw-r--r--usr/src/uts/common/fs/zfs/dsl_pool.c57
-rw-r--r--usr/src/uts/common/fs/zfs/dsl_prop.c27
-rw-r--r--usr/src/uts/common/fs/zfs/dsl_scan.c136
-rw-r--r--usr/src/uts/common/fs/zfs/dsl_synctask.c18
-rw-r--r--usr/src/uts/common/fs/zfs/rrwlock.c13
-rw-r--r--usr/src/uts/common/fs/zfs/sa.c16
-rw-r--r--usr/src/uts/common/fs/zfs/spa.c517
-rw-r--r--usr/src/uts/common/fs/zfs/spa_config.c9
-rw-r--r--usr/src/uts/common/fs/zfs/spa_history.c214
-rw-r--r--usr/src/uts/common/fs/zfs/spa_misc.c57
-rw-r--r--usr/src/uts/common/fs/zfs/sys/bptree.h64
-rw-r--r--usr/src/uts/common/fs/zfs/sys/dmu.h123
-rw-r--r--usr/src/uts/common/fs/zfs/sys/dmu_impl.h28
-rw-r--r--usr/src/uts/common/fs/zfs/sys/dmu_objset.h11
-rw-r--r--usr/src/uts/common/fs/zfs/sys/dmu_traverse.h4
-rw-r--r--usr/src/uts/common/fs/zfs/sys/dsl_dataset.h20
-rw-r--r--usr/src/uts/common/fs/zfs/sys/dsl_deleg.h5
-rw-r--r--usr/src/uts/common/fs/zfs/sys/dsl_pool.h9
-rw-r--r--usr/src/uts/common/fs/zfs/sys/dsl_prop.h3
-rw-r--r--usr/src/uts/common/fs/zfs/sys/dsl_scan.h4
-rw-r--r--usr/src/uts/common/fs/zfs/sys/rrwlock.h6
-rw-r--r--usr/src/uts/common/fs/zfs/sys/spa.h49
-rw-r--r--usr/src/uts/common/fs/zfs/sys/spa_impl.h9
-rw-r--r--usr/src/uts/common/fs/zfs/sys/vdev.h5
-rw-r--r--usr/src/uts/common/fs/zfs/sys/vdev_impl.h3
-rw-r--r--usr/src/uts/common/fs/zfs/sys/zap.h9
-rw-r--r--usr/src/uts/common/fs/zfs/sys/zfeature.h52
-rw-r--r--usr/src/uts/common/fs/zfs/sys/zfs_ioctl.h31
-rw-r--r--usr/src/uts/common/fs/zfs/sys/zio.h14
-rw-r--r--usr/src/uts/common/fs/zfs/vdev.c7
-rw-r--r--usr/src/uts/common/fs/zfs/vdev_label.c103
-rw-r--r--usr/src/uts/common/fs/zfs/zap.c14
-rw-r--r--usr/src/uts/common/fs/zfs/zap_micro.c6
-rw-r--r--usr/src/uts/common/fs/zfs/zfeature.c419
-rw-r--r--usr/src/uts/common/fs/zfs/zfs_ctldir.c4
-rw-r--r--usr/src/uts/common/fs/zfs/zfs_ioctl.c1690
-rw-r--r--usr/src/uts/common/fs/zfs/zfs_vfsops.c6
-rw-r--r--usr/src/uts/common/fs/zfs/zio.c46
-rw-r--r--usr/src/uts/common/fs/zfs/zvol.c5
-rw-r--r--usr/src/uts/common/io/blkdev/blkdev.c63
-rw-r--r--usr/src/uts/common/io/comstar/port/iscsit/iscsit.c23
-rw-r--r--usr/src/uts/common/io/fibre-channel/fca/fcoei/fcoei_eth.c2
-rw-r--r--usr/src/uts/common/io/fibre-channel/fca/fcoei/fcoei_lv.c35
-rw-r--r--usr/src/uts/common/io/scsi/adapters/mpt_sas/mptsas.c5
-rw-r--r--usr/src/uts/common/io/scsi/adapters/mpt_sas/mptsas_impl.c15
-rw-r--r--usr/src/uts/common/io/usb/clients/usbser/usbftdi/uftdi_dsd.c91
-rw-r--r--usr/src/uts/common/io/usb/usbdevs4
-rw-r--r--usr/src/uts/common/os/printf.c18
-rw-r--r--usr/src/uts/common/os/vmem.c17
-rw-r--r--usr/src/uts/common/smbsrv/smb_kproto.h4
-rw-r--r--usr/src/uts/common/sys/ccompile.h13
-rw-r--r--usr/src/uts/common/sys/cmn_err.h21
-rw-r--r--usr/src/uts/common/sys/dtrace.h935
-rw-r--r--usr/src/uts/common/sys/dtrace_impl.h59
-rw-r--r--usr/src/uts/common/sys/feature_tests.h4
-rw-r--r--usr/src/uts/common/sys/fork.h2
-rw-r--r--usr/src/uts/common/sys/fs/hsfs_isospec.h5
-rw-r--r--usr/src/uts/common/sys/fs/zfs.h104
-rw-r--r--usr/src/uts/common/sys/ib/clients/rdsv3/rdsv3_impl.h4
-rw-r--r--usr/src/uts/common/sys/nvpair.h69
-rw-r--r--usr/src/uts/common/sys/ontrap.h4
-rw-r--r--usr/src/uts/common/sys/scsi/adapters/mpt_sas/mptsas_var.h3
-rw-r--r--usr/src/uts/common/sys/sunddi.h2
-rw-r--r--usr/src/uts/common/sys/sysmacros.h14
-rw-r--r--usr/src/uts/common/sys/systm.h4
-rw-r--r--usr/src/uts/common/sys/usb/clients/usbser/usbftdi/uftdi_var.h2
-rw-r--r--usr/src/uts/common/sys/vmem.h2
-rw-r--r--usr/src/uts/i86pc/Makefile.rules7
-rw-r--r--usr/src/uts/i86xpv/Makefile.rules2
-rw-r--r--usr/src/uts/sparc/Makefile.sparc.shared2
-rw-r--r--usr/src/uts/sun4u/Makefile.sun4u.shared2
-rw-r--r--usr/src/uts/sun4v/Makefile.sun4v.shared2
449 files changed, 14362 insertions, 39526 deletions
diff --git a/usr/src/Makefile.lint b/usr/src/Makefile.lint
index 193d292d21..b94490b997 100644
--- a/usr/src/Makefile.lint
+++ b/usr/src/Makefile.lint
@@ -20,6 +20,7 @@
#
# Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2012 by Delphix. All rights reserved.
# include global definitions
include Makefile.master
@@ -324,6 +325,7 @@ COMMON_SUBDIRS = \
cmd/zdb \
cmd/zdump \
cmd/zfs \
+ cmd/zhack \
cmd/zinject \
cmd/zlogin \
cmd/zoneadm \
diff --git a/usr/src/Makefile.master b/usr/src/Makefile.master
index c818962f62..e26e296680 100644
--- a/usr/src/Makefile.master
+++ b/usr/src/Makefile.master
@@ -21,7 +21,9 @@
#
# Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2012 by Delphix. All rights reserved.
#
+
#
# Makefile.master, global definitions for system source
#
@@ -109,23 +111,37 @@ STRIP_COMMENTS= $(INTERNAL_RELEASE_BUILD)
TONICBUILD= $(POUND_SIGN)
$(TONICBUILD)CLOSEDROOT= $(ROOT)-closed
-# set __GNUC= in the environment to build 32-bit with the gcc compiler.
-# The default is to use the Sun Studio compiler for all processor types.
-__GNUC= $(POUND_SIGN)
-# __SUNC is the default, Sun C compiler, set to $(POUND_SIGN) if __GNUC is
-# primary to facilitate conditional make rules.
+# The variables below control the compilers used during the build.
+# There are a number of permutations.
+#
+# __GNUC and __SUNC control (and indicate) the primary compiler. Whichever
+# one is not POUND_SIGN is the primary, with the other as the shadow. They
+# may also be used to control entirely compiler-specific Makefile assignments.
+# __SUNC and Sun Studio are the default.
+#
+# __GNUC64 indicates that the 64bit build should use the GNU C compiler.
+# There is no Sun C analogue.
+#
+# The following version-specific options are operative regardless of which
+# compiler is primary, and control the versions of the given compilers to be
+# used. They also allow compiler-version specific Makefile fragments.
+#
+# __SSNEXT when set to the empty string enables options specific to the 'next'
+# version of the Sun Studio compiler.
+#
+# __GNUC3 when the empty string uses and refers to GCC 3.x, it is the default.
+# __GNUC4 when the empty string uses and refers to GCC 4.x.
+
+__GNUC= $(POUND_SIGN)
$(__GNUC)__SUNC= $(POUND_SIGN)
+__GNUC64= $(__GNUC)
-# set __GNUC64= in the environment to build 64-bit with the gcc compiler.
-# Inherit the __GNUC value by default, and if that is set to $(POUND_SIGN)
-# then this means use the Sun Studio compiler.
-__GNUC64= $(__GNUC)
+__SSNEXT= $(POUND_SIGN)
-# set __SSNEXT= in the enviroment to build with the 'next' release of
-# the Sun Studio compiler. This will cause command line options specific
-# to the 'next' version of the Sun Studio compiler to be used.
-__SSNEXT= $(POUND_SIGN)
+__GNUC3=
+__GNUC4= $(POUND_SIGN)
+$(__GNUC4)__GNUC3= $(POUND_SIGN)
# set __GNUC4 in the environment to build with GCC 4.4 These two variables are
# operative even when __GNUC is not, as they affect flags that will be used by
@@ -212,7 +228,7 @@ WC= /usr/bin/wc
XARGS= /usr/bin/xargs
ELFEDIT= /usr/bin/elfedit
ELFSIGN= /usr/bin/elfsign
-DTRACE= /usr/sbin/dtrace
+DTRACE= /usr/sbin/dtrace -xnolibs
UNIQ= /usr/bin/uniq
TAR= /usr/bin/tar
@@ -339,6 +355,15 @@ CCSTATICSYM= -Wc,-Qassembler-ounrefsym=0
#
# generate 32-bit addresses in the v9 kernel. Saves memory.
CCABS32= -Wc,-xcode=abs32
+#
+# generate v9 code which tolerates callers using the v7 ABI, for the sake of
+# system calls.
+$(__GNUC4)CC32BITCALLERS= -_gcc=-massume-32bit-callers
+
+# GCC, especially, is increasingly beginning to auto-inline functions and
+# sadly does so separately not under the general -fno-inline-functions
+$(__GNUC4)CCNOAUTOINLINE= -_gcc=-fno-inline-small-functions \
+ -_gcc=-fno-inline-functions-called-once
# One optimization the compiler might perform is to turn this:
# #pragma weak foo
@@ -404,7 +429,7 @@ CERRWARN += -erroff=E_STATEMENT_NOT_REACHED
# Normally cw(1) would translate -v into a set of options including these
# but as they're GCC 4.x specific, we can't do that
-$(__GNUC4)CERRWARN += -_gcc=-Wno-address
+$(__GNUC4)CERRWARN += -_gcc=-Wno-address -_gcc=-Wno-array-bounds
#
# turn warnings into errors (C++)
@@ -458,10 +483,6 @@ CNOGLOBAL= -W0,-noglobal
# In the same spirit, this will also remove the date from the N_OPT stab.
CGLOBALSTATIC= -W0,-xglobalstatic
-# Normally, gcc uses indirect DWARF strings to save space. However,
-# this causes relocations that ctfconvert cannot handle. Disable this.
-CDWARFSTR= -_gcc=-fno-dwarf2-indirect-strings
-
# Sometimes we want all symbols and types in debugging information even
# if they aren't used.
CALLSYMS= -W0,-xdbggen=no%usedonly
@@ -527,17 +548,17 @@ XREGSFLAG64 = $($(MACH64)_XREGSFLAG)
CFLAGS= $(COPTFLAG) $($(MACH)_CFLAGS) $(SPACEFLAG) $(CCMODE) \
$(ILDOFF) $(CERRWARN) $(C99MODE) $(CCUNBOUND) $(IROPTFLAG) \
- $(CGLOBALSTATIC)
+ $(CGLOBALSTATIC) $(CCNOAUTOINLINE)
CFLAGS64= $(COPTFLAG64) $($(MACH64)_CFLAGS) $(SPACEFLAG64) $(CCMODE64) \
$(ILDOFF) $(CERRWARN) $(C99MODE) $(CCUNBOUND) $(IROPTFLAG64) \
- $(CGLOBALSTATIC)
+ $(CGLOBALSTATIC) $(CCNOAUTOINLINE)
#
# Flags that are used to build parts of the code that are subsequently
# run on the build machine (also known as the NATIVE_BUILD).
#
NATIVE_CFLAGS= $(COPTFLAG) $($(NATIVE_MACH)_CFLAGS) $(CCMODE) \
$(ILDOFF) $(CERRWARN) $(C99MODE) $($(NATIVE_MACH)_CCUNBOUND) \
- $(IROPTFLAG) $(CGLOBALSTATIC)
+ $(IROPTFLAG) $(CGLOBALSTATIC) $(CCNOAUTOINLINE)
DTEXTDOM=-DTEXT_DOMAIN=\"$(TEXT_DOMAIN)\" # For messaging.
DTS_ERRNO=-D_TS_ERRNO
@@ -679,7 +700,9 @@ COMPILE.java= $(JAVAC) $(JAVAFLAGS) -classpath $(CLASSPATH)
# Link time macros
#
CCNEEDED = -lC
-$(__GNUC)CCNEEDED = -L$(GCCLIBDIR) -lstdc++ -lgcc_s
+CCEXTNEEDED = -lCrun -lCstd
+$(__GNUC)CCNEEDED = -L$(GCCLIBDIR) -R$(GCCLIBDIR) -lstdc++ -lgcc_s
+$(__GNUC)CCEXTNEEDED = $(CCNEEDED)
LINK.c= $(CC) $(CFLAGS) $(CPPFLAGS) $(LDFLAGS)
LINK64.c= $(CC) $(CFLAGS64) $(CPPFLAGS) $(LDFLAGS)
diff --git a/usr/src/Makefile.master.64 b/usr/src/Makefile.master.64
index c70dd75860..42bc62e679 100644
--- a/usr/src/Makefile.master.64
+++ b/usr/src/Makefile.master.64
@@ -82,7 +82,7 @@ BUILD.SO= $(CC) $(CFLAGS) -o $@ $(GSHARED) $(DYNFLAGS) \
MAPFILECLASS= -64
CCNEEDED = -lCrun
-$(__GNUC64)CCNEEDED = -L$(GCCLIBDIR) -lstdc++
+$(__GNUC64)CCNEEDED = -L$(GCCLIBDIR) -R$(GCCLIBDIR) -lstdc++
$(__GNUC64)$(__GNUC3)CCNEEDED += -lgcc_s_$(MACH64)
$(__GNUC64)$(__GNUC4)CCNEEDED += -lgcc_s
diff --git a/usr/src/Targetdirs b/usr/src/Targetdirs
index 756841ee74..33a4a97fd7 100644
--- a/usr/src/Targetdirs
+++ b/usr/src/Targetdirs
@@ -22,6 +22,7 @@
# Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
# Copyright 2011, Richard Lowe
# Copyright 2011 Nexenta Systems, Inc. All rights reserved.
+# Copyright (c) 2012 by Delphix. All rights reserved.
#
#
@@ -1031,6 +1032,8 @@ $(ROOT)/usr/lib/libxnet.so.1:= REALPATH=../../lib/libxnet.so.1
$(ROOT)/usr/lib/libxnet.so:= REALPATH=../../lib/libxnet.so.1
$(ROOT)/usr/lib/libzfs.so.1:= REALPATH=../../lib/libzfs.so.1
$(ROOT)/usr/lib/libzfs.so:= REALPATH=../../lib/libzfs.so.1
+$(ROOT)/usr/lib/libzfs_core.so.1:= REALPATH=../../lib/libzfs_core.so.1
+$(ROOT)/usr/lib/libzfs_core.so:= REALPATH=../../lib/libzfs_core.so.1
$(ROOT)/usr/lib/llib-ladm.ln:= REALPATH=../../lib/llib-ladm.ln
$(ROOT)/usr/lib/llib-ladm:= REALPATH=../../lib/llib-ladm
$(ROOT)/usr/lib/llib-laio.ln:= REALPATH=../../lib/llib-laio.ln
@@ -1131,6 +1134,8 @@ $(ROOT)/usr/lib/llib-lxnet.ln:= REALPATH=../../lib/llib-lxnet.ln
$(ROOT)/usr/lib/llib-lxnet:= REALPATH=../../lib/llib-lxnet
$(ROOT)/usr/lib/llib-lzfs.ln:= REALPATH=../../lib/llib-lzfs.ln
$(ROOT)/usr/lib/llib-lzfs:= REALPATH=../../lib/llib-lzfs
+$(ROOT)/usr/lib/llib-lzfs_core.ln:= REALPATH=../../lib/llib-lzfs_core.ln
+$(ROOT)/usr/lib/llib-lzfs_core:= REALPATH=../../lib/llib-lzfs_core
$(ROOT)/usr/lib/nss_compat.so.1:= REALPATH=../../lib/nss_compat.so.1
$(ROOT)/usr/lib/nss_dns.so.1:= REALPATH=../../lib/nss_dns.so.1
$(ROOT)/usr/lib/nss_files.so.1:= REALPATH=../../lib/nss_files.so.1
@@ -1377,6 +1382,10 @@ $(ROOT)/usr/lib/$(MACH64)/libzfs.so:= \
REALPATH=../../../lib/$(MACH64)/libzfs.so.1
$(ROOT)/usr/lib/$(MACH64)/libzfs.so.1:= \
REALPATH=../../../lib/$(MACH64)/libzfs.so.1
+$(ROOT)/usr/lib/$(MACH64)/libzfs_core.so:= \
+ REALPATH=../../../lib/$(MACH64)/libzfs_core.so.1
+$(ROOT)/usr/lib/$(MACH64)/libzfs_core.so.1:= \
+ REALPATH=../../../lib/$(MACH64)/libzfs_core.so.1
$(ROOT)/usr/lib/$(MACH64)/libfdisk.so.1:= \
REALPATH=../../../lib/$(MACH64)/libfdisk.so.1
$(ROOT)/usr/lib/$(MACH64)/libfdisk.so:= \
@@ -1473,6 +1482,8 @@ $(ROOT)/usr/lib/$(MACH64)/llib-lxnet.ln:= \
REALPATH=../../../lib/$(MACH64)/llib-lxnet.ln
$(ROOT)/usr/lib/$(MACH64)/llib-lzfs.ln:= \
REALPATH=../../../lib/$(MACH64)/llib-lzfs.ln
+$(ROOT)/usr/lib/$(MACH64)/llib-lzfs_core.ln:= \
+ REALPATH=../../../lib/$(MACH64)/llib-lzfs_core.ln
$(ROOT)/usr/lib/$(MACH64)/llib-lfdisk.ln:= \
REALPATH=../../../lib/$(MACH64)/llib-lfdisk.ln
$(ROOT)/usr/lib/$(MACH64)/nss_compat.so.1:= \
@@ -1627,6 +1638,8 @@ SYM.USRLIB= \
/usr/lib/libxnet.so.1 \
/usr/lib/libzfs.so \
/usr/lib/libzfs.so.1 \
+ /usr/lib/libzfs_core.so \
+ /usr/lib/libzfs_core.so.1 \
/usr/lib/llib-ladm \
/usr/lib/llib-ladm.ln \
/usr/lib/llib-laio \
@@ -1725,6 +1738,8 @@ SYM.USRLIB= \
/usr/lib/llib-lxnet.ln \
/usr/lib/llib-lzfs \
/usr/lib/llib-lzfs.ln \
+ /usr/lib/llib-lzfs_core \
+ /usr/lib/llib-lzfs_core.ln \
/usr/lib/nss_compat.so.1 \
/usr/lib/nss_dns.so.1 \
/usr/lib/nss_files.so.1 \
@@ -1863,6 +1878,8 @@ SYM.USRLIB64= \
/usr/lib/$(MACH64)/libxnet.so.1 \
/usr/lib/$(MACH64)/libzfs.so \
/usr/lib/$(MACH64)/libzfs.so.1 \
+ /usr/lib/$(MACH64)/libzfs_core.so \
+ /usr/lib/$(MACH64)/libzfs_core.so.1 \
/usr/lib/$(MACH64)/llib-ladm.ln \
/usr/lib/$(MACH64)/llib-laio.ln \
/usr/lib/$(MACH64)/llib-lavl.ln \
@@ -1909,6 +1926,7 @@ SYM.USRLIB64= \
/usr/lib/$(MACH64)/llib-luuid.ln \
/usr/lib/$(MACH64)/llib-lxnet.ln \
/usr/lib/$(MACH64)/llib-lzfs.ln \
+ /usr/lib/$(MACH64)/llib-lzfs_core.ln \
/usr/lib/$(MACH64)/nss_compat.so.1 \
/usr/lib/$(MACH64)/nss_dns.so.1 \
/usr/lib/$(MACH64)/nss_files.so.1 \
diff --git a/usr/src/cmd/Makefile b/usr/src/cmd/Makefile
index 2655cd8ed5..52e9c379d6 100644
--- a/usr/src/cmd/Makefile
+++ b/usr/src/cmd/Makefile
@@ -22,6 +22,7 @@
# Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
# Copyright 2010 Nexenta Systems, Inc. All rights reserved.
# Copyright (c) 2012 Joyent, Inc. All rights reserved.
+# Copyright (c) 2012 by Delphix. All rights reserved.
include ../Makefile.master
@@ -450,6 +451,7 @@ COMMON_SUBDIRS= \
zdb \
zdump \
zfs \
+ zhack \
zic \
zinject \
zlogin \
diff --git a/usr/src/cmd/abi/appcert/etc/etc.warn.in b/usr/src/cmd/abi/appcert/etc/etc.warn.in
index 8fff87bca0..ffa02abb63 100644
--- a/usr/src/cmd/abi/appcert/etc/etc.warn.in
+++ b/usr/src/cmd/abi/appcert/etc/etc.warn.in
@@ -1,6 +1,4 @@
#
-# ident "%Z%%M% %I% %E% SMI"
-#
# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
@@ -77,6 +75,8 @@ WARNING:_lwp_create:gettext("uses lightweight processes directly"):libc.so.1|_lw
###############################################################################
WARNING:libldap.so.3:gettext("calls obsolete LDAP library libldap.so.3"):libldap.so.3|*|*DIRECT*:
###############################################################################
+WARNING:libldap.so.4:gettext("calls obsolete LDAP library libldap.so.4"):libldap.so.4|*|*DIRECT*:
+###############################################################################
WARNING:libxfn:gettext("calls obsolete federated naming library libxfn.so"):libxfn.so.1|*|*DIRECT*,libxfn.so.2|*|*DIRECT*:
###############################################################################
WARNING:libXinput:gettext("calls obsolete input library libXinput.so.0"):libXinput.so.0|*|*DIRECT*:
diff --git a/usr/src/cmd/auditreduce/option.c b/usr/src/cmd/auditreduce/option.c
index aea0b14bd8..e4898e2a33 100644
--- a/usr/src/cmd/auditreduce/option.c
+++ b/usr/src/cmd/auditreduce/option.c
@@ -342,7 +342,6 @@ proc_object(char *optarg)
return (-1);
}
return (0);
- /* NOTREACHED */
case OBJ_SOCK:
if (!a_isnum(obj_val, TRUE)) {
obj_id = atol(obj_val);
@@ -389,41 +388,34 @@ proc_object(char *optarg)
freehostent(he);
socket_flag = SOCKFLG_MACHINE;
return (0);
- break;
case OBJ_MSG:
case OBJ_SEM:
case OBJ_SHM:
case OBJ_PROC:
obj_id = atol(obj_val);
return (0);
- /* NOTREACHED */
case OBJ_FGROUP:
case OBJ_MSGGROUP:
case OBJ_SEMGROUP:
case OBJ_SHMGROUP:
case OBJ_PGROUP:
return (proc_group(obj_val, &obj_group));
- /* NOTREACHED */
case OBJ_FOWNER:
case OBJ_MSGOWNER:
case OBJ_SEMOWNER:
case OBJ_SHMOWNER:
case OBJ_POWNER:
return (proc_user(obj_val, &obj_owner));
- /* NOTREACHED */
case OBJ_FMRI:
return (proc_fmri(obj_val));
- /* NOTREACHED */
case OBJ_USER:
return (proc_user(obj_val, &obj_user));
- /* NOTREACHED */
case OBJ_LP: /* lp objects have not yet been defined */
default: /* impossible */
(void) sprintf(errbuf, gettext("invalid object type (%s)"),
obj_str);
error_str = errbuf;
return (-1);
- /* NOTREACHED */
} /* switch */
/*NOTREACHED*/
}
@@ -538,7 +530,6 @@ proc_id(char *optstr, int opt)
}
flags |= M_USERE;
return (proc_user(optstr, &m_usere));
- /* NOTREACHED */
case 'f': /* effective group id */
if (flags & M_GROUPE) {
error_str = gettext(
@@ -547,7 +538,6 @@ proc_id(char *optstr, int opt)
}
flags |= M_GROUPE;
return (proc_group(optstr, &m_groupe));
- /* NOTREACHED */
case 'r': /* real user id */
if (flags & M_USERR) {
error_str = gettext(
@@ -556,7 +546,6 @@ proc_id(char *optstr, int opt)
}
flags |= M_USERR;
return (proc_user(optstr, &m_userr));
- /* NOTREACHED */
case 'u': /* audit user id */
if (flags & M_USERA) {
error_str = gettext(
@@ -565,7 +554,6 @@ proc_id(char *optstr, int opt)
}
flags |= M_USERA;
return (proc_user(optstr, &m_usera));
- /* NOTREACHED */
case 'g': /* real group id */
if (flags & M_GROUPR) {
error_str = gettext(
@@ -574,12 +562,10 @@ proc_id(char *optstr, int opt)
}
flags |= M_GROUPR;
return (proc_group(optstr, &m_groupr));
- /* NOTREACHED */
default: /* impossible */
(void) sprintf(errbuf, gettext("'%c' unknown option"), opt);
error_str = errbuf;
return (-1);
- /* NOTREACHED */
}
/*NOTREACHED*/
}
diff --git a/usr/src/cmd/beadm/beadm.c b/usr/src/cmd/beadm/beadm.c
index 7222b968ee..17d222c9a4 100644
--- a/usr/src/cmd/beadm/beadm.c
+++ b/usr/src/cmd/beadm/beadm.c
@@ -123,21 +123,21 @@ usage(void)
"\n"
"\tsubcommands:\n"
"\n"
- "\tbeadm activate beName\n"
- "\tbeadm create [-d BE_desc]\n"
+ "\tbeadm activate [-v] beName\n"
+ "\tbeadm create [-a] [-d BE_desc]\n"
"\t\t[-o property=value] ... [-p zpool] \n"
- "\t\t[-e nonActiveBe | beName@snapshot] beName\n"
+ "\t\t[-e nonActiveBe | beName@snapshot] [-v] beName\n"
"\tbeadm create [-d BE_desc]\n"
- "\t\t[-o property=value] ... [-p zpool] beName@snapshot\n"
- "\tbeadm destroy [-Ffs] beName \n"
- "\tbeadm destroy [-F] beName@snapshot \n"
- "\tbeadm list [[-a] | [-d] [-s]] [-H] [beName]\n"
- "\tbeadm mount [-s ro|rw] beName [mountpoint]\n"
- "\tbeadm unmount [-f] beName | mountpoint\n"
- "\tbeadm umount [-f] beName | mountpoint\n"
- "\tbeadm rename origBeName newBeName\n"
- "\tbeadm rollback beName snapshot\n"
- "\tbeadm rollback beName@snapshot\n"));
+ "\t\t[-o property=value] ... [-p zpool] [-v] beName@snapshot\n"
+ "\tbeadm destroy [-Ffsv] beName \n"
+ "\tbeadm destroy [-Fv] beName@snapshot \n"
+ "\tbeadm list [[-a] | [-d] [-s]] [-H] [-v] [beName]\n"
+ "\tbeadm mount [-s ro|rw] [-v] beName [mountpoint]\n"
+ "\tbeadm unmount [-fv] beName | mountpoint\n"
+ "\tbeadm umount [-fv] beName | mountpoint\n"
+ "\tbeadm rename [-v] origBeName newBeName\n"
+ "\tbeadm rollback [-v] beName snapshot\n"
+ "\tbeadm rollback [-v] beName@snapshot\n"));
}
static int
@@ -664,8 +664,20 @@ be_do_activate(int argc, char **argv)
{
nvlist_t *be_attrs;
int err = 1;
+ int c;
char *obe_name;
+ while ((c = getopt(argc, argv, "v")) != -1) {
+ switch (c) {
+ case 'v':
+ libbe_print_errors(B_TRUE);
+ break;
+ default:
+ usage();
+ return (1);
+ }
+ }
+
argc -= optind;
argv += optind;
@@ -728,7 +740,7 @@ be_do_create(int argc, char **argv)
char *propval = NULL;
char *strval = NULL;
- while ((c = getopt(argc, argv, "ad:e:io:p:")) != -1) {
+ while ((c = getopt(argc, argv, "ad:e:io:p:v")) != -1) {
switch (c) {
case 'a':
activate = B_TRUE;
@@ -766,6 +778,9 @@ be_do_create(int argc, char **argv)
case 'p':
nbe_zpool = optarg;
break;
+ case 'v':
+ libbe_print_errors(B_TRUE);
+ break;
default:
usage();
goto out2;
@@ -939,7 +954,7 @@ be_do_destroy(int argc, char **argv)
char *snap_name;
char *be_name;
- while ((c = getopt(argc, argv, "fFs")) != -1) {
+ while ((c = getopt(argc, argv, "fFsv")) != -1) {
switch (c) {
case 'f':
destroy_flags |= BE_DESTROY_FLAG_FORCE_UNMOUNT;
@@ -947,6 +962,9 @@ be_do_destroy(int argc, char **argv)
case 's':
destroy_flags |= BE_DESTROY_FLAG_SNAPSHOTS;
break;
+ case 'v':
+ libbe_print_errors(B_TRUE);
+ break;
case 'F':
suppress_prompt = B_TRUE;
break;
@@ -1061,7 +1079,7 @@ be_do_list(int argc, char **argv)
int c = 0;
char *be_name = NULL;
- while ((c = getopt(argc, argv, "nadsH")) != -1) {
+ while ((c = getopt(argc, argv, "adsvH")) != -1) {
switch (c) {
case 'a':
all = B_TRUE;
@@ -1072,6 +1090,9 @@ be_do_list(int argc, char **argv)
case 's':
snaps = B_TRUE;
break;
+ case 'v':
+ libbe_print_errors(B_TRUE);
+ break;
case 'H':
parsable = B_TRUE;
break;
@@ -1145,7 +1166,7 @@ be_do_mount(int argc, char **argv)
char *mountpoint;
char *tmp_mp = NULL;
- while ((c = getopt(argc, argv, "s:")) != -1) {
+ while ((c = getopt(argc, argv, "s:v")) != -1) {
switch (c) {
case 's':
shared_fs = B_TRUE;
@@ -1162,6 +1183,9 @@ be_do_mount(int argc, char **argv)
}
break;
+ case 'v':
+ libbe_print_errors(B_TRUE);
+ break;
default:
usage();
return (1);
@@ -1223,7 +1247,6 @@ be_do_mount(int argc, char **argv)
(void) printf(_("Mounted successfully on: '%s'\n"), mountpoint);
break;
case BE_ERR_BE_NOENT:
- err = 1;
(void) fprintf(stderr, _("%s does not exist or appear "
"to be a valid BE.\nPlease check that the name of "
"the BE provided is correct.\n"), obe_name);
@@ -1235,13 +1258,11 @@ be_do_mount(int argc, char **argv)
break;
case BE_ERR_PERM:
case BE_ERR_ACCESS:
- err = 1;
(void) fprintf(stderr, _("Unable to mount %s.\n"), obe_name);
(void) fprintf(stderr, _("You have insufficient privileges to "
"execute this command.\n"));
break;
default:
- err = 1;
(void) fprintf(stderr, _("Unable to mount %s.\n"), obe_name);
(void) fprintf(stderr, "%s\n", be_err_to_str(err));
}
@@ -1262,11 +1283,14 @@ be_do_unmount(int argc, char **argv)
int c;
int unmount_flags = 0;
- while ((c = getopt(argc, argv, "f")) != -1) {
+ while ((c = getopt(argc, argv, "fv")) != -1) {
switch (c) {
case 'f':
unmount_flags |= BE_UNMOUNT_FLAG_FORCE;
break;
+ case 'v':
+ libbe_print_errors(B_TRUE);
+ break;
default:
usage();
return (1);
@@ -1337,6 +1361,18 @@ be_do_rename(int argc, char **argv)
char *obe_name;
char *nbe_name;
int err = 1;
+ int c;
+
+ while ((c = getopt(argc, argv, "v")) != -1) {
+ switch (c) {
+ case 'v':
+ libbe_print_errors(B_TRUE);
+ break;
+ default:
+ usage();
+ return (1);
+ }
+ }
argc -= optind;
argv += optind;
@@ -1394,6 +1430,18 @@ be_do_rollback(int argc, char **argv)
char *obe_name;
char *snap_name;
int err = 1;
+ int c;
+
+ while ((c = getopt(argc, argv, "v")) != -1) {
+ switch (c) {
+ case 'v':
+ libbe_print_errors(B_TRUE);
+ break;
+ default:
+ usage();
+ return (1);
+ }
+ }
argc -= optind;
argv += optind;
diff --git a/usr/src/cmd/boot/scripts/root_archive.ksh b/usr/src/cmd/boot/scripts/root_archive.ksh
index 90e797afae..159b4c2b70 100644
--- a/usr/src/cmd/boot/scripts/root_archive.ksh
+++ b/usr/src/cmd/boot/scripts/root_archive.ksh
@@ -23,6 +23,7 @@
# Copyright 2010 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
+# Copyright 2012 Nexenta Systems, Inc. All rights reserved.
# utility to pack and unpack a boot/root archive
# both ufs and hsfs (iso9660) format archives are unpacked
@@ -30,23 +31,15 @@
#
# usage: pack <archive> <root>
# unpack <archive> <root>
-# packmedia <solaris_image> <root>
-# unpackmedia <solaris_image> <root>
#
# Where <root> is the directory to unpack to and will be cleaned out
# if it exists.
#
-# In the case of (un)packmedia, the image is packed or unpacked to/from
-# Solaris media and all the things that don't go into the ramdisk image
-# are (un)cpio'd as well
-#
usage()
{
printf "usage: root_archive pack <archive> <root>\n"
printf " root_archive unpack <archive> <root>\n"
- printf " root_archive packmedia <solaris_image> <root>\n"
- printf " root_archive unpackmedia <solaris_image> <root>\n"
exit 1
}
@@ -65,559 +58,6 @@ cleanup()
rm -f /tmp/flist$$
}
-preload_Gnome()
-{
- MEDIA="$1"
- MINIROOT="$2"
-
-
- (
- # Prepopulate the gconf database. This needs to be done and
- # done first for several reasons. 1) Archiving out the gnome
- # libraries and binaries causes the gconftool-2 to not run
- # appropriately at boot time. 2) The binaries and libraries
- # needed to run this are big and thus we want to archive
- # them separately. 3) Having schemas prepopluated in the
- # miniroot means faster boot times.
- #
-
- cd "$MINIROOT"
- HOME="./tmp/root"
- export HOME
- umask 0022
- mumble=.tmp_proto/root/etc/gconf/gconf.xml.defaults
- GCONF_CONFIG_SOURCE="xml:merged:$MINIROOT/$mumble"
- export GCONF_CONFIG_SOURCE
- SCHEMADIR="$MINIROOT/.tmp_proto/root/etc/gconf/schemas"
- export SCHEMADIR
- /usr/bin/gconftool-2 --makefile-install-rule \
- $SCHEMADIR/*.schemas >/dev/null 2>&1
- echo '
- xml:readwrite:/tmp/root/.gconf
- xml:readonly:/etc/gconf/gconf.xml.defaults
- ' > /"$MINIROOT"/.tmp_proto/root/etc/gconf/2/path
- )
-}
-
-archive_Gnome()
-{
- MEDIA="$1"
- MINIROOT="$2"
-
- RELEASE=`/bin/ls -d "$MEDIA/Solaris_"*`
- RELEASE=`basename "$RELEASE"`
- CPIO_DIR="$MEDIA/$RELEASE/Tools/Boot"
-
- # Create the gnome archive
- #
- (
- # usr/share gnome stuff
- cd "$MINIROOT"
- find usr/share/GConf usr/share/application-registry \
- usr/share/autostart usr/share/dtds \
- usr/share/emacs usr/share/gnome usr/share/gnome-2.0 \
- usr/share/gnome-background-properties \
- usr/share/gtk-engines usr/share/gui-install \
- usr/share/icon-naming-utils usr/share/control-center \
- usr/share/icons usr/share/locale usr/share/metacity \
- usr/share/mime usr/share/mime-info usr/share/pixmaps \
- usr/share/scrollkeeper usr/share/sgml usr/share/themes \
- usr/share/xml \
- -print > /tmp/gnome_share.$$ 2>/dev/null
-
- if [ ! -f /tmp/gnome_share.$$ ] ; then
- echo "/tmp/gnome_share.$$ file list not found."
- return
- fi
-
- # usr/lib gnome stuff
-
- find usr/lib/libgnome*\.so\.* \
- usr/lib/libgst*\.so\.* usr/lib/libgconf*\.so\.* \
- usr/lib/libgdk*\.so\.* usr/lib/libgtk*\.so\.* \
- usr/lib/libglade*\.so\.* usr/lib/libmetacity*\.so\.* \
- usr/lib/libfontconfig*\.so\.* usr/lib/libgmodule*\.so\.* \
- usr/lib/libgobject*\.so\.* usr/lib/libgthread*\.so\.* \
- usr/lib/libpopt*\.so\.* usr/lib/libstartup*\.so\.* \
- usr/lib/libexif*\.so\.* usr/lib/libtiff*\.so\.* \
- usr/lib/libstartup*\.so\.* \
- usr/lib/libexif*\.so\.* usr/lib/libORBit*\.so\.* \
- usr/lib/libmlib*\.so\.* usr/lib/libxsl*\.so\.* \
- usr/lib/libpango*\.so\.* usr/lib/libpng*\.so\.* \
- usr/lib/liboil*\.so\.* usr/lib/libbonobo*\.so\.* \
- usr/lib/libart*\.so\.* usr/lib/libcairo*\.so\.* \
- usr/lib/libjpeg*\.so\.* \
- usr/lib/libpolkit*\.so\.* \
- -print | egrep -v '\.so\.[0]$' > \
- /tmp/gnome_lib.$$ 2>/dev/null
-
- find usr/lib/nautilus usr/lib/pango usr/lib/iconv \
- usr/lib/metacity-dialog usr/lib/window-manager-settings \
- usr/lib/bonobo-2.0 usr/lib/bononbo usr/lib/gtk-2.0 \
- usr/lib/GConf usr/lib/bonobo-activation-server \
- usr/lib/python2.4 usr/lib/gstreamer-0.10 \
- usr/lib/gconf-sanity-check-2 usr/lib/gconfd \
- usr/lib/gnome-vfs-2.0 usr/lib/dbus-daemon \
- usr/lib/gnome-vfs-daemon usr/lib/gnome-settings-daemon \
- usr/lib/gnome_segv2 usr/lib/orbit-2.0 \
- usr/lib/libmlib \
- print > /tmp/gnome_libdir.$$ 2>/dev/null
-
- if [ ! -f /tmp/gnome_lib.$$ -a ! -f gnome_libdir.$$ ] ; then
- echo "/tmp/gnome_lib.$$ file list not found."
- return
- fi
-
- # /usr/sfw gnome stuff
- find usr/sfw/bin usr/sfw/include usr/sfw/share usr/sfw/src \
- -print > /tmp/gnome_sfw.$$ 2>/dev/null
-
- if [ ! -f /tmp/gnome_sfw.$$ ] ; then
- echo "/tmp/gnome_sfw.$$ file list not found."
- return
- fi
-
- # gnome app binaries usr/bin
- find usr/bin/gnome* usr/bin/gui-install usr/bin/bonobo* \
- usr/bin/gtk-* usr/bin/fax* usr/bin/gdk* usr/bin/gif2tiff \
- usr/bin/install-lan \
- usr/bin/metacity* usr/bin/gst-* usr/bin/gconftool-2 \
- usr/bin/pango* usr/bin/desktop* usr/bin/djpeg \
- usr/bin/notify-send usr/bin/oil-bugreport \
- usr/bin/bmp2tiff usr/bin/thembus-theme-applier \
- usr/bin/thumbnail usr/lib/update-* \
- usr/bin/ras2tiff usr/bin/raw2tiff usr/bin/rdjpgcom \
- usr/bin/thumbnail usr/bin/dbus* \
- usr/bin/tiff* usr/bin/rgb2ycbcr \
- usr/bin/fc-cache usr/bin/fc-list \
- -print > /tmp/gnome_bin.$$ 2>/dev/null
-
- if [ ! -f /tmp/gnome_bin.$$ ] ; then
- echo "/tmp/gnome_bin.$$ file list not found."
- return
- fi
-
- # Cat all the files together and create the gnome archive
- #
-
- cat /tmp/gnome_libdir.$$ /tmp/gnome_lib.$$ \
- /tmp/gnome_share.$$ /tmp/gnome_sfw.$$ /tmp/gnome_bin.$$ \
- > /tmp/gnome.$$
-
- if [ ! -f /tmp/gnome.$$ ] ; then
- echo "/tmp/gnome.$$ file not found."
- return
- fi
- # Save off this file in the miniroot for use later
- # when unpacking. Clean up old cruft if there.
- #
-
- if [ -f .tmp_proto/gnome_saved ]; then
- rm -f .tmp_proto/gnome_saved
- fi
-
- cp /tmp/gnome.$$ .tmp_proto/gnome_saved
-
- # Create gnome archive
- #
-
- cpio -ocmPuB < /tmp/gnome.$$ 2>/dev/null | bzip2 > \
- "$CPIO_DIR/gnome.cpio.bz2"
-
- # Remove files from miniroot that are in archive.
- # Create symlinks for files in archive
-
- rm -rf `cat /tmp/gnome_share.$$`
-
- for i in `cat /tmp/gnome_share.$$`
- do
- ln -s /tmp/root/$i $i 2>/dev/null
- done
-
- rm -rf `cat /tmp/gnome_lib.$$`
- for i in `cat /tmp/gnome_lib.$$`
- do
- ln -s /tmp/root/$i $i 2>/dev/null
- done
-
- rm -rf `cat /tmp/gnome_libdir.$$`
- for i in `cat /tmp/gnome_libdir.$$`
- do
- ln -s /tmp/root/$i $i 2>/dev/null
- done
-
- rm -rf `cat /tmp/gnome_sfw.$$`
- for i in `cat /tmp/gnome_sfw.$$`
- do
- ln -s /tmp/root/$i $i 2>/dev/null
- done
-
- rm -rf `cat /tmp/gnome_bin.$$`
- for i in `cat /tmp/gnome_bin.$$`
- do
- ln -s /tmp/root/$i $i 2>/dev/null
- done
- rm -f /tmp/gnome_share.$$
- rm -f /tmp/gnome_lib.$$
- rm -f /tmp/gnome_libdir.$$
- rm -f /tmp/gnome_bin.$$
- )
-}
-
-archive_JavaGUI()
-{
- MEDIA="$1"
- MINIROOT="$2"
-
- RELEASE=`/bin/ls -d "$MEDIA/Solaris_"*`
- RELEASE=`basename "$RELEASE"`
-
- CPIO_DIR="$MEDIA/$RELEASE/Tools/Boot"
-
- # Archive the java wizard components that are only used in the
- # non developer express path.
- #
- (
- # path is usr/lib/install/data
- cd "$MINIROOT"
- find usr/lib/install/data/wizards \
- -print > /tmp/java_ui.$$ 2>/dev/null
-
- if [ ! -f /tmp/java_ui.$$ ] ; then
- echo "/tmp/java_ui.$$ file list not found."
- return
- fi
-
- cpio -ocmPuB < /tmp/java_ui.$$ 2>/dev/null | bzip2 > \
- "$CPIO_DIR/javaui.cpio.bz2"
-
- rm -rf `cat /tmp/java_ui.$$`
- ln -s /tmp/root/usr/lib/install/data/wizards \
- usr/lib/install/data/wizards 2>/dev/null
-
- rm -f /tmp/java_ui.$$
-
- )
-}
-
-archive_Misc()
-{
- MEDIA="$1"
- MINIROOT="$2"
-
- RELEASE=`/bin/ls -d "$MEDIA/Solaris_"*`
- RELEASE=`basename "$RELEASE"`
-
- CPIO_DIR="$MEDIA/$RELEASE/Tools/Boot"
-
- # Archive misc stuff that is needed by non devex installer
- #
- (
- # usr/lib stuff
- cd "$MINIROOT"
- find usr/lib/lp -print > /tmp/lp.$$ 2>/dev/null
- if [ ! -f /tmp/lp.$$ ] ; then
- echo "/tmp/lp.$$ file list not found."
- return
- fi
-
- cpio -ocmPuB < /tmp/lp.$$ 2>/dev/null | bzip2 > \
- "$CPIO_DIR/lpmisc.cpio.bz2"
-
- rm -rf `cat /tmp/lp.$$`
- ln -s /tmp/root/usr/lib/lp usr/lib/lp 2>/dev/null
-
- rm -f /tmp/lp.$$
- )
-
-}
-
-archive_Perl()
-{
- MEDIA="$1"
- MINIROOT="$2"
-
- RELEASE=`/bin/ls -d "$MEDIA/Solaris_"*`
- RELEASE=`basename "$RELEASE"`
-
- CPIO_DIR="$MEDIA/$RELEASE/Tools/Boot"
-
- # Archive perl, it is only needed by gnome gui.
- #
- (
- # in usr
- cd "$MINIROOT"
- find usr/perl5 -print > /tmp/perl.$$ 2>/dev/null
-
- if [ ! -f /tmp/perl.$$ ] ; then
- echo "/tmp/perl.$$ file list not found."
- return
- fi
- cpio -ocmPuB < /tmp/perl.$$ 2>/dev/null | bzip2 > \
- "$CPIO_DIR/perl.cpio.bz2"
-
- rm -rf `cat /tmp/perl.$$` 2>/dev/null
- ln -s /tmp/root/usr/perl5 usr/perl5 2>/dev/null
-
- rm -f /tmp/perl.$$
- )
-}
-archive_X()
-{
- MEDIA="$1"
- MINIROOT="$2"
-
- RELEASE=`/bin/ls -d "$MEDIA/Solaris_"*`
- RELEASE=`basename "$RELEASE"`
-
- CPIO_DIR="$MEDIA/$RELEASE/Tools/Boot"
-
- # create the graphics and non-graphics X archive
- #
- (
- cd "$MINIROOT"
- find usr/openwin usr/dt usr/X11 -print 2> /dev/null |\
- cpio -ocmPuB 2> /dev/null | bzip2 > "$CPIO_DIR/X.cpio.bz2"
-
- find usr/openwin/bin/mkfontdir \
- usr/openwin/lib/installalias \
- usr/openwin/server/lib/libfont.so.1 \
- usr/openwin/server/lib/libtypesclr.so.0 \
- -print | cpio -ocmPuB 2> /dev/null | bzip2 > \
- "$CPIO_DIR/X_small.cpio.bz2"
-
- rm -rf usr/dt usr/openwin usr/X11
- ln -s /tmp/root/usr/dt usr/dt
- ln -s /tmp/root/usr/openwin usr/openwin
- ln -s /tmp/root/usr/X11 usr/X11
- )
-}
-
-archive_lu()
-{
- MEDIA="$1"
- MINIROOT="$2"
-
- RELEASE=`/bin/ls -d "$MEDIA/Solaris_"*`
- RELEASE=`basename "$RELEASE"`
-
- CPIO_DIR="$MEDIA/$RELEASE/Tools/Boot"
-
- (
- cd "$MINIROOT"
- find usr/lib/install usr/snadm usr/sbin usr/lib/locale \
- boot/grub boot/solaris/bootenv.rc \
- tmp/root/boot/grub tmp/root/boot/solaris/bootenv.rc \
- 2> /dev/null | cpio -ocmPuB 2> /dev/null | bzip2 \
- > "$CPIO_DIR"/lu.cpio.bz2
- ls platform > "$CPIO_DIR/lu.platforms"
- )
-}
-
-cleanout_pkgdata()
-{
- rm -Rf tmp/root/var/sadm/install tmp/root/var/sadm/pkg
-}
-
-packmedia()
-{
- MEDIA="$1"
- MINIROOT="$2"
-
- RELEASE=`/bin/ls -d "$MEDIA/Solaris_"*`
- RELEASE=`basename "$RELEASE"`
- ARCHIVES="X X_small perl lpmisc javaui gnome"
-
- mkdir -p "$MEDIA/$RELEASE/Tools/Boot"
-
- if [ -d "$MINIROOT/platform/i86pc" ] ; then
- mkdir -p "$MEDIA/boot/amd64"
- mkdir -p "$MEDIA/boot/platform/i86pc/kernel"
- mkdir -p "$MEDIA/boot/platform/i86pc/kernel/amd64"
- mkdir -p "$MEDIA/boot/platform/i86xpv/kernel"
- mkdir -p "$MEDIA/boot/platform/i86xpv/kernel/amd64"
- cp "$MINIROOT/platform/i86pc/multiboot" "$MEDIA/boot"
- cp "$MINIROOT/platform/i86pc/kernel/unix" \
- "$MEDIA/boot/platform/i86pc/kernel/unix"
- cp "$MINIROOT/platform/i86pc/kernel/amd64/unix" \
- "$MEDIA/boot/platform/i86pc/kernel/amd64/unix"
- cp "$MINIROOT/platform/i86xpv/kernel/unix" \
- "$MEDIA/boot/platform/i86xpv/kernel/unix"
- cp "$MINIROOT/platform/i86xpv/kernel/amd64/unix" \
- "$MEDIA/boot/platform/i86xpv/kernel/amd64/unix"
- (
- cd "$MEDIA/$RELEASE/Tools/Boot"
- ln -sf ../../../boot/x86.miniroot
- ln -sf ../../../boot/multiboot
- ln -sf ../../../boot/platform/i86pc/kernel/unix
- ln -sf ../../../boot/platform/i86pc/kernel/amd64/unix
- ln -sf ../../../boot/platform/i86xpv/kernel/unix
- ln -sf ../../../boot/platform/i86xpv/kernel/amd64/unix
- ln -sf ../../../boot/grub/pxegrub
- )
- fi
-
- if [ -d "$MINIROOT/platform/sun4u" ] ; then
- mkdir -p "$MEDIA/boot"
- dd if="$MINIROOT/platform/sun4u/lib/fs/hsfs/bootblk" \
- of="$MEDIA/boot/hsfs.bootblock" \
- bs=1b oseek=1 count=15 conv=sync 2> /dev/null
- fi
-
- for arch in sun4u sun4v ; do
- if [ -d "$MINIROOT/platform/$arch" ] ; then
- archdir="$MEDIA/$RELEASE/Tools/Boot/platform/$arch"
- mkdir -p $archdir
- ln -sf ../../../../../boot/sparc.miniroot \
- "$archdir/boot_archive"
- cp "$MINIROOT/usr/platform/$arch/lib/fs/nfs/inetboot" \
- "$archdir"
- cp "$MINIROOT/platform/$arch/wanboot" \
- "$archdir"
- mkdir -p "$MEDIA/platform/$arch"
- ln -sf ../../boot/sparc.miniroot \
- "$MEDIA/platform/$arch/boot_archive"
- ln -sf ../../$RELEASE/Tools/Boot/platform/$arch/wanboot \
- "$MEDIA/platform/$arch/wanboot"
- fi
- done
-
- # archive package databases to conserve memory
- #
- (
- cd "$MINIROOT"
- find tmp/root/var/sadm/install tmp/root/var/sadm/pkg -print | \
- cpio -ocmPuB 2> /dev/null | bzip2 > \
- "$MEDIA/$RELEASE/Tools/Boot/pkg_db.cpio.bz2"
-
- cleanout_pkgdata
- )
-
- archive_lu "$MEDIA" "$MINIROOT"
-
- archive_X "$MEDIA" "$MINIROOT"
-
- # Take out the gnome and java parts of the installer from
- # the miniroot. These are not required to boot the system
- # and start the installers.
-
- if [ -d "$MINIROOT/platform/i86pc" ] ; then
- preload_Gnome "$MEDIA" "$MINIROOT"
- archive_Gnome "$MEDIA" "$MINIROOT"
- archive_JavaGUI "$MEDIA" "$MINIROOT"
- archive_Misc "$MEDIA" "$MINIROOT"
- archive_Perl "$MEDIA" "$MINIROOT"
- pack "$MEDIA/boot/amd64/x86.miniroot"
-
- # Now that the 64-bit archives & miniroot have been created,
- # restore the files from archives and save the 64-bit
- # archives. Strip the 64-bit objects and create the
- # 32-bit archives and miniroot
-
- unpackmedia "$MEDIA" "$MINIROOT"
- cleanout_pkgdata
- mkdir -p "$MEDIA/$RELEASE/Tools/Boot/amd64"
- for i in $ARCHIVES; do
- mv "$MEDIA/$RELEASE/Tools/Boot/${i}.cpio.bz2" \
- "$MEDIA/$RELEASE/Tools/Boot/amd64"
- done
- if [ -z "$STRIP_AMD64" ]; then
- strip_amd64
- fi
-
- archive_X "$MEDIA" "$MINIROOT"
- archive_Gnome "$MEDIA" "$MINIROOT"
- archive_JavaGUI "$MEDIA" "$MINIROOT"
- archive_Perl "$MEDIA" "$MINIROOT"
- archive_Misc "$MEDIA" "$MINIROOT"
- fi
-
- # copy the install menu to menu.lst so we have a menu
- # on the install media
- #
- if [ -f "$MINIROOT/boot/grub/install_menu" ] ; then
- cp $MINIROOT/boot/grub/install_menu \
- $MEDIA/boot/grub/menu.lst
- fi
-
- #
- # jumpstart utilities in usr/sbin/install.d
- #
- if [ -d "$MINIROOT/usr/sbin/install.d" ] ; then
- (
- cd ${MINIROOT}
- find usr/sbin/install.d/chkprobe \
- -print | cpio -ocmPuB 2> /dev/null | bzip2 > \
- ${MEDIA}/${RELEASE}/Tools/Boot/usr_sbin_install_d.cpio.bz2
- )
- fi
-}
-
-unarchive_X()
-{
- MEDIA="$1"
- UNPACKED_ROOT="$2"
-
- RELEASE=`/bin/ls -d "$MEDIA/Solaris_"*`
- RELEASE=`basename "$RELEASE"`
-
- CPIO_DIR="$MEDIA/$RELEASE/Tools/Boot"
-
- # unpack X
- #
- (
- cd "$UNPACKED_ROOT"
- rm -rf usr/dt usr/openwin usr/X11
- bzcat "$CPIO_DIR/X.cpio.bz2" | cpio -icdmu 2> /dev/null
- )
-}
-
-unpackmedia()
-{
- MEDIA="$1"
- UNPACKED_ROOT="$2"
-
- RELEASE=`/bin/ls -d "$MEDIA/Solaris_"*`
- RELEASE=`basename "$RELEASE"`
-
- unarchive_X "$MEDIA" "$UNPACKED_ROOT"
-
- # unpack package databases
- #
- (
- cd "$UNPACKED_ROOT"
- bzcat "$MEDIA/$RELEASE/Tools/Boot/pkg_db.cpio.bz2" |
- cpio -icdmu 2> /dev/null
-
- if [ -d "$MINIROOT/platform/i86pc" ] ; then
-
- # unpack gnome, perl, java and misc
- # Remove symlinks left from unpacking x86.miniroot
- # so that unpacking subsequent archives will populate
- # appropriately.
- #
- rm -rf usr/perl5
- rm -rf usr/lib/install/data/wizards
- rm -rf usr/lib/lp
-
- # Gnome list saved off from packmedia
- for i in `cat .tmp_proto/gnome_saved`
- do
- rm -rf $i
- done
-
- bzcat "$MEDIA/$RELEASE/Tools/Boot/gnome.cpio.bz2" |
- cpio -icdmu 2>/dev/null
- bzcat "$MEDIA/$RELEASE/Tools/Boot/javaui.cpio.bz2" |
- cpio -icdmu 2>/dev/null
- bzcat "$MEDIA/$RELEASE/Tools/Boot/lpmisc.cpio.bz2" |
- cpio -icdmu 2>/dev/null
- bzcat "$MEDIA/$RELEASE/Tools/Boot/perl.cpio.bz2" |
- cpio -icdmu 2>/dev/null
- fi
- )
-}
-
do_unpack()
{
(
@@ -883,14 +323,11 @@ if [ "`dirname $UNPACKED_ROOT`" = . ] ; then
UNPACKED_ROOT="$BASE/$UNPACKED_ROOT"
fi
-
-MEDIA="$MR"
-
trap cleanup EXIT
# always unpack into a fresh root
case $1 in
- unpack|unpackmedia)
+ unpack)
rm -rf "$UNPACKED_ROOT"
mkdir -p "$UNPACKED_ROOT"
;;
@@ -898,24 +335,6 @@ esac
[ -d "$UNPACKED_ROOT" ] || usage
case $1 in
- packmedia)
- packmedia "$MEDIA" "$UNPACKED_ROOT"
- if [ -d "$UNPACKED_ROOT/kernel/drv/sparcv9" ] ; then
- pack "$MEDIA/boot/sparc.miniroot"
- else
- pack "$MEDIA/boot/x86.miniroot"
- fi
-
- ;;
- unpackmedia)
- if [ -f "$MEDIA/boot/sparc.miniroot" ] ; then
- unpack "$MEDIA/boot/sparc.miniroot"
- else
- unpack "$MEDIA/boot/x86.miniroot"
- unpack "$MEDIA/boot/amd64/x86.miniroot"
- fi
- unpackmedia "$MEDIA" "$UNPACKED_ROOT"
- ;;
pack) pack "$MR"
;;
unpack) unpack "$MR"
diff --git a/usr/src/cmd/cmd-inet/etc/services b/usr/src/cmd/cmd-inet/etc/services
index 91523540a1..37514ac0a7 100644
--- a/usr/src/cmd/cmd-inet/etc/services
+++ b/usr/src/cmd/cmd-inet/etc/services
@@ -22,6 +22,7 @@
# CDDL HEADER END
#
# Network services, Internet style
+# Look at http://www.iana.org/assignments/port-numbers for more
#
tcpmux 1/tcp
echo 7/tcp
@@ -32,21 +33,33 @@ systat 11/tcp users
daytime 13/tcp
daytime 13/udp
netstat 15/tcp
+qotd 17/tcp # Quote of the Day
chargen 19/tcp ttytst source
chargen 19/udp ttytst source
ftp-data 20/tcp
ftp 21/tcp
+ftp 21/sctp
ssh 22/tcp # Secure Shell
+ssh 22/sctp
telnet 23/tcp
smtp 25/tcp mail
time 37/tcp timserver
time 37/udp timserver
+rlp 39/tcp # Resource Location Protocol
+rlp 39/udp # Resource Location Protocol
name 42/udp nameserver
whois 43/tcp nicname # usually to sri-nic
+tacacs 49/tcp
+tacacs 49/udp
domain 53/udp
domain 53/tcp
+tacacs-ds 65/tcp
+tacacs-ds 65/udp
bootps 67/udp # BOOTP/DHCP server
bootpc 68/udp # BOOTP/DHCP client
+http 80/tcp www www-http
+http 80/udp www www-http
+http 80/sctp
kerberos 88/udp kdc # Kerberos V5 KDC
kerberos 88/tcp kdc # Kerberos V5 KDC
hostnames 101/tcp hostname # usually to sri-nic
@@ -54,16 +67,89 @@ pop2 109/tcp pop-2 # Post Office Protocol - V2
pop3 110/tcp # Post Office Protocol - Version 3
sunrpc 111/udp rpcbind
sunrpc 111/tcp rpcbind
+sftp 115/tcp
imap 143/tcp imap2 # Internet Mail Access Protocol v2
+bgp 179/tcp # Border Gateway Protocol
+bgp 179/udp
+bgp 179/sctp
+irc 194/tcp
+irc 194/udp
+smux 199/tcp
+smux 199/udp
+imap3 220/tcp
+imap3 220/udp
+clearcase 371/tcp
+clearcase 371/udp
ldap 389/tcp # Lightweight Directory Access Protocol
ldap 389/udp # Lightweight Directory Access Protocol
+https 443/tcp
+https 443/udp
+https 443/sctp
+kpasswd 464/tcp
+kpasswd 464/udp
dhcpv6-client 546/udp dhcpv6c # DHCPv6 Client (RFC 3315)
+dhcpv6-client 546/tcp
dhcpv6-server 547/udp dhcpv6s # DHCPv6 Server (RFC 3315)
+dhcpv6-server 547/tcp
+rtsp 554/tcp
+rtsp 554/udp
+nntps 563/tcp snntp
+nntps 563/udp snntp
submission 587/tcp # Mail Message Submission
submission 587/udp # see RFC 2476
+ipp 631/tcp
+ipp 631/udp
ldaps 636/tcp # LDAP protocol over TLS/SSL (was sldap)
ldaps 636/udp # LDAP protocol over TLS/SSL (was sldap)
+silc 706/tcp
+silc 706/udp
+iscsi 860/tcp
+iscsi 860/udp
+rsync 873/tcp
+rsync 873/udp
+ftps-data 989/tcp
+ftps-data 989/udp
+ftps 990/tcp
+ftps 990/udp
+imaps 993/tcp
+imaps 993/udp
+pop3s 995/tcp
+pop3s 995/udp
+socks 1080/tcp
+socks 1080/udp
+openvpn 1194/tcp
+openvpn 1194/udp
icap 1344/tcp # Internet Content Adaptation Protocol
+wins 1512/tcp
+wins 1512/udp
+radius 1812/tcp
+radius 1812/udp
+radius-acct 1813/tcp
+radius-acct 1813/udp
+cvspserver 2401/tcp
+icpv2 3130/tcp
+icpv2 3130/udp
+iscsi-target 3260/tcp
+iscsi-target 3260/udp
+mysql 3306/tcp
+mysql 3306/udp
+nut 3493/tcp # Network UPS Tools
+svn 3690/tcp
+svn 3690/udp
+epmd 4369/tcp # Erlang Port Mapper Daemon
+epmd 4369/udp
+sip 5060/tcp
+sip 5060/udp
+sip-tls 5061/tcp
+sip-tls 5061/udp
+xmpp-client 5222/tcp
+xmpp-server 5269/tcp
+postgresql 5432/tcp postgres
+postgresql 5432/udp postgres
+http-alt 8080/tcp webcache # HTTP Alternate, webcache
+http-alt 8080/udp
+memcache 11211/tcp
+memcache 11211/udp
#
# Host specific functions
#
@@ -76,9 +162,8 @@ iso-tsap 102/tcp
x400 103/tcp # ISO Mail
x400-snd 104/tcp
csnet-ns 105/tcp
-pop-2 109/tcp # Post Office
uucp-path 117/tcp
-nntp 119/tcp usenet # Network News Transfer
+nntp 119/tcp usenet # Network News Transfer
ntp 123/tcp # Network Time Protocol
ntp 123/udp # Network Time Protocol
netbios-ns 137/tcp # NETBIOS Name Service
@@ -90,7 +175,7 @@ netbios-ssn 139/udp # NETBIOS Session Service
NeWS 144/tcp news # Window System
snmpd 161/udp snmp # Net-SNMP snmp daemon
slp 427/tcp slp # Service Location Protocol, V2
-slp 427/udp slp # Service Location Protocol, V2
+slp 427/udp slp # Service Location Protocol, V2
mobile-ip 434/udp mobile-ip # Mobile-IP
cvc_hostd 442/tcp # Network Console
microsoft-ds 445/tcp # Microsoft Directory Services
@@ -125,18 +210,19 @@ pcserver 600/tcp # ECD Integrated PC board srvr
sun-dr 665/tcp # Remote Dynamic Reconfiguration
kerberos-adm 749/tcp # Kerberos V5 Administration
kerberos-adm 749/udp # Kerberos V5 Administration
-kerberos-iv 750/udp # Kerberos V4 key server
+kerberos-iv 750/udp # Kerberos V4 key server
krb5_prop 754/tcp # Kerberos V5 KDC propogation
swat 901/tcp # Samba Web Adm.Tool
ufsd 1008/tcp ufsd # UFS-aware server
ufsd 1008/udp ufsd
cvc 1495/tcp # Network Console
-ingreslock 1524/tcp
+ingreslock 1524/tcp
www-ldap-gw 1760/tcp # HTTP to LDAP gateway
www-ldap-gw 1760/udp # HTTP to LDAP gateway
-listen 2766/tcp # System V listener port
+listen 2766/tcp # System V listener port
nfsd 2049/udp nfs # NFS server daemon (clts)
nfsd 2049/tcp nfs # NFS server daemon (cots)
+nfsd 2049/sctp nfs
eklogin 2105/tcp # Kerberos encrypted rlogin
lockd 4045/udp # NFS lock daemon/manager
lockd 4045/tcp
diff --git a/usr/src/cmd/cmd-inet/lib/nwamd/door_if.c b/usr/src/cmd/cmd-inet/lib/nwamd/door_if.c
index 5ac3cf4fcb..6f3c76b478 100644
--- a/usr/src/cmd/cmd-inet/lib/nwamd/door_if.c
+++ b/usr/src/cmd/cmd-inet/lib/nwamd/door_if.c
@@ -237,7 +237,8 @@ nwamd_door_req_wlan_set_key(nwamd_door_arg_t *req, ucred_t *ucr,
req->nwda_data.nwdad_wlan_info.nwdad_bssid);
return (nwamd_wlan_set_key
(req->nwda_data.nwdad_wlan_info.nwdad_name,
- req->nwda_data.nwdad_wlan_info.nwdad_essid, NULL,
+ req->nwda_data.nwdad_wlan_info.nwdad_essid,
+ req->nwda_data.nwdad_wlan_info.nwdad_bssid,
req->nwda_data.nwdad_wlan_info.nwdad_security_mode,
req->nwda_data.nwdad_wlan_info.nwdad_keyslot,
req->nwda_data.nwdad_wlan_info.nwdad_key));
diff --git a/usr/src/cmd/cmd-inet/lib/nwamd/known_wlans.c b/usr/src/cmd/cmd-inet/lib/nwamd/known_wlans.c
index 80531aa5cb..adc6020bdb 100644
--- a/usr/src/cmd/cmd-inet/lib/nwamd/known_wlans.c
+++ b/usr/src/cmd/cmd-inet/lib/nwamd/known_wlans.c
@@ -463,32 +463,6 @@ known_wlan_get_keyname(const char *essid, char *name)
return (err);
}
-nwam_error_t
-known_wlan_get_keyslot(const char *essid, uint_t *keyslotp)
-{
- nwam_known_wlan_handle_t kwh = NULL;
- nwam_value_t keyslotval = NULL;
- uint64_t slot;
- nwam_error_t err;
-
- if ((err = nwam_known_wlan_read(essid, 0, &kwh)) != NWAM_SUCCESS)
- return (err);
- if ((err = nwam_known_wlan_get_prop_value(kwh,
- NWAM_KNOWN_WLAN_PROP_KEYSLOT, &keyslotval)) == NWAM_SUCCESS &&
- (err = nwam_value_get_uint64(keyslotval, &slot)) == NWAM_SUCCESS) {
- *keyslotp = (uint_t)slot;
- } else {
- if (err == NWAM_ENTITY_NOT_FOUND)
- err = NWAM_SUCCESS;
- *keyslotp = 1;
- }
- if (keyslotval != NULL)
- nwam_value_free(keyslotval);
- if (kwh != NULL)
- nwam_known_wlan_free(kwh);
- return (err);
-}
-
/* Performs a scan on a wifi link NCU */
/* ARGSUSED */
static int
diff --git a/usr/src/cmd/cmd-inet/lib/nwamd/ncu_phys.c b/usr/src/cmd/cmd-inet/lib/nwamd/ncu_phys.c
index a5dc0fb9dd..ae1a6d979c 100644
--- a/usr/src/cmd/cmd-inet/lib/nwamd/ncu_phys.c
+++ b/usr/src/cmd/cmd-inet/lib/nwamd/ncu_phys.c
@@ -351,6 +351,44 @@ key_string_to_secobj_value(char *buf, uint8_t *obj_val, uint_t *obj_lenp,
}
/*
+ * Callback used on each known WLAN:
+ * return 1 if a secobj, linked with an existing kwown wlan, has the same name
+ * of the secobj that is being created.
+ */
+
+static int
+find_keyname_cb(nwam_known_wlan_handle_t kwh, void *new_keyname)
+{
+ nwam_error_t err;
+ nwam_value_t old_key;
+
+ char **old_keyname;
+ uint_t num_old_keyname, i;
+
+ if ((err = nwam_known_wlan_get_prop_value(kwh,
+ NWAM_KNOWN_WLAN_PROP_KEYNAME, &old_key)) != NWAM_SUCCESS) {
+ nlog(LOG_ERR, "find_keyname_cb: nwam_known_wlan_get_prop: %s",
+ nwam_strerror(err));
+ return (0);
+ }
+ if ((err = nwam_value_get_string_array(old_key, &old_keyname,
+ &num_old_keyname))
+ != NWAM_SUCCESS) {
+ nlog(LOG_ERR, "find_keyname_cb: nwam_value_get_string: %s",
+ nwam_strerror(err));
+ nwam_value_free(old_key);
+ return (0);
+ }
+ nwam_value_free(old_key);
+ for (i = 0; i < num_old_keyname; i++) {
+ if (strcmp(old_keyname[i], (const char *)new_keyname) == 0)
+ /* Found matching keyname so terminate walk */
+ return (1);
+ }
+ return (0);
+}
+
+/*
* Print the key name format into the appropriate field, then convert any ":"
* characters to ".", as ":[1-4]" is the slot indicator, which otherwise
* would trip us up. Invalid characters for secobj names are ignored.
@@ -403,9 +441,11 @@ nwamd_wlan_set_key(const char *linkname, const char *essid, const char *bssid,
nwamd_object_t ncu_obj;
nwamd_ncu_t *ncu;
nwamd_link_t *link;
+ int ret = 0;
uint8_t obj_val[DLADM_SECOBJ_VAL_MAX];
uint_t obj_len = sizeof (obj_val);
char obj_name[DLADM_SECOBJ_NAME_MAX];
+ char obj_tempname[DLADM_SECOBJ_NAME_MAX];
dladm_status_t status;
char errmsg[DLADM_STRSIZE];
dladm_secobj_class_t class;
@@ -419,14 +459,6 @@ nwamd_wlan_set_key(const char *linkname, const char *essid, const char *bssid,
ncu = ncu_obj->nwamd_object_data;
link = &ncu->ncu_link;
- nlog(LOG_DEBUG, "nwamd_wlan_set_key: running for link %s", linkname);
- /*
- * Name key object for this WLAN so it can be later retrieved
- * (name is unique for each ESSID/BSSID combination).
- */
- nwamd_set_key_name(essid, bssid, obj_name, sizeof (obj_name));
- nlog(LOG_DEBUG, "store_key: obj_name is %s", obj_name);
-
class = (security_mode == DLADM_WLAN_SECMODE_WEP ?
DLADM_SECOBJ_CLASS_WEP : DLADM_SECOBJ_CLASS_WPA);
if (key_string_to_secobj_value(raw_key, obj_val, &obj_len,
@@ -436,7 +468,38 @@ nwamd_wlan_set_key(const char *linkname, const char *essid, const char *bssid,
return (NWAM_ERROR_INTERNAL);
}
- /* we've validated the new key, so remove the old one */
+ nlog(LOG_DEBUG, "nwamd_wlan_set_key: running for link %s", linkname);
+ /*
+ * Name key object for this WLAN so it can be later retrieved.
+ * (bssid is appended if an object, with the same keyname,
+ * already exists and is associated to a known wlan)
+ */
+ nwamd_set_key_name(essid, NULL, obj_tempname, sizeof (obj_tempname));
+ (void) nwam_walk_known_wlans(find_keyname_cb, obj_tempname, 0, &ret);
+ /*
+ * We also check if the keyval is the same. The user might want
+ * to use the same key for more APs with the same ESSID.
+ * This can result in a known wlan with multiple BSSIDs
+ */
+ if (ret == 1) {
+ dladm_wlan_key_t *old_secobj = nwamd_wlan_get_key_named(
+ obj_tempname, security_mode);
+ nlog(LOG_DEBUG, "found existing obj_name %s", obj_tempname);
+ ret = memcmp((*old_secobj).wk_val, obj_val, obj_len);
+ nwamd_set_key_name(essid, ret ? bssid : NULL, obj_name,
+ sizeof (obj_name));
+ free(old_secobj);
+ } else {
+ nwamd_set_key_name(essid, NULL, obj_name,
+ sizeof (obj_name));
+ }
+ nlog(LOG_DEBUG, "store_key: obj_name is %s", obj_name);
+
+ /*
+ * We have validated the new key, so remove the old one.
+ * This will actually delete the keyobj only if the user had set
+ * a wrong key and is replacing it with a new one for the same AP.
+ */
status = dladm_unset_secobj(dld_handle, obj_name,
DLADM_OPT_ACTIVE | DLADM_OPT_PERSIST);
if (status != DLADM_STATUS_OK && status != DLADM_STATUS_NOTFOUND) {
@@ -755,8 +818,7 @@ nwamd_wlan_select(const char *linkname, const char *essid, const char *bssid,
nwamd_object_t ncu_obj;
nwamd_ncu_t *ncu;
nwamd_link_t *link;
- char key[DLADM_STRSIZE];
- boolean_t found_old_key = B_FALSE, found_key = B_FALSE;
+ boolean_t found_key = B_FALSE;
if ((ncu_obj = nwamd_ncu_object_find(NWAM_NCU_TYPE_LINK, linkname))
== NULL) {
@@ -799,55 +861,34 @@ nwamd_wlan_select(const char *linkname, const char *essid, const char *bssid,
/* does this WLAN require a key? If so go to NEED_KEY */
if (NEED_ENC(link->nwamd_link_wifi_security_mode)) {
/*
- * First, if a key name may have been specified for a
- * known WLAN. If so, use it. Otherwise, try both the
- * new nwamd key name format (ESSID) and old (ESSID/BSSID).
- * The user may have set the key without adding a known WLAN,
- * so we need to try all these options to save going to
- * NEED_KEY state.
+ * nwam secobjs can have two formats: nwam-ESSID-BSSID and
+ * nwam-ESSID. There is no reason for searching through known
+ * wlan keynames since this is only the selection process.
*/
- if (known_wlan_get_keyname(link->nwamd_link_wifi_essid,
- link->nwamd_link_wifi_keyname) == NWAM_SUCCESS &&
- (link->nwamd_link_wifi_key = nwamd_wlan_get_key_named
- (link->nwamd_link_wifi_keyname,
- link->nwamd_link_wifi_security_mode)) != NULL) {
- (void) known_wlan_get_keyslot
- (link->nwamd_link_wifi_essid,
- &link->nwamd_link_wifi_key->wk_idx);
- nlog(LOG_DEBUG, "nwamd_wlan_select: got known WLAN "
- "key %s, slot %d", link->nwamd_link_wifi_keyname,
- link->nwamd_link_wifi_key->wk_idx);
- found_key = B_TRUE;
- } else if ((link->nwamd_link_wifi_key = nwamd_wlan_get_key
- (link->nwamd_link_wifi_essid, NULL,
+ if ((link->nwamd_link_wifi_key = nwamd_wlan_get_key
+ (link->nwamd_link_wifi_essid, link->nwamd_link_wifi_bssid,
link->nwamd_link_wifi_security_mode)) != NULL) {
- nwamd_set_key_name(link->nwamd_link_wifi_essid, NULL,
+ /*
+ * Found old key format,
+ * known wlans with similar names might exist
+ */
+ nwamd_set_key_name(link->nwamd_link_wifi_essid,
+ link->nwamd_link_wifi_bssid,
link->nwamd_link_wifi_keyname,
DLADM_SECOBJ_NAME_MAX);
- nlog(LOG_DEBUG, "nwamd_wlan_select: got WLAN key %s",
+ nlog(LOG_DEBUG, "nwamd_wlan_select: got old format "
+ "WLAN key %s",
link->nwamd_link_wifi_keyname);
found_key = B_TRUE;
} else if ((link->nwamd_link_wifi_key = nwamd_wlan_get_key
- (link->nwamd_link_wifi_essid, link->nwamd_link_wifi_bssid,
+ (link->nwamd_link_wifi_essid, NULL,
link->nwamd_link_wifi_security_mode)) != NULL) {
- /*
- * Found old key format - prepare to save
- * it as new ESSID-only key, but don't
- * do it until we're released the object
- * lock (since nwamd_wlan_set_key()
- * takes the object lock).
- */
- (void) strlcpy(key,
- (char *)link->nwamd_link_wifi_key->wk_val,
- link->nwamd_link_wifi_key->wk_len + 1);
- found_old_key = B_TRUE;
- found_key = B_TRUE;
nwamd_set_key_name(link->nwamd_link_wifi_essid, NULL,
link->nwamd_link_wifi_keyname,
DLADM_SECOBJ_NAME_MAX);
- nlog(LOG_DEBUG, "nwamd_wlan_select: got old format "
- "WLAN key, converting to %s",
+ nlog(LOG_DEBUG, "nwamd_wlan_select: got WLAN key %s",
link->nwamd_link_wifi_keyname);
+ found_key = B_TRUE;
} else {
nlog(LOG_ERR, "nwamd_wlan_select: could not "
"find key for WLAN '%s'",
@@ -871,10 +912,6 @@ nwamd_wlan_select(const char *linkname, const char *essid, const char *bssid,
}
nwamd_object_release(ncu_obj);
- if (found_old_key) {
- (void) nwamd_wlan_set_key(linkname, essid, NULL, security_mode,
- 1, key);
- }
return (NWAM_SUCCESS);
}
@@ -882,28 +919,28 @@ nwamd_wlan_select(const char *linkname, const char *essid, const char *bssid,
* See if BSSID is in visited list of BSSIDs for known WLAN. Used for
* strict BSSID matching (depends on wireless_strict_bssid property value).
*/
-static boolean_t
-bssid_match(nwam_known_wlan_handle_t kwh, const char *bssid)
+static int
+bssid_match(nwam_known_wlan_handle_t kwh, void *bssid)
{
nwam_value_t bssidsval;
nwam_error_t err;
char **bssids;
uint_t nelem, i;
- boolean_t found = B_FALSE;
+ int found = 0;
if ((err = nwam_known_wlan_get_prop_value(kwh,
NWAM_KNOWN_WLAN_PROP_BSSIDS, &bssidsval)) != NWAM_SUCCESS) {
nlog(LOG_ERR, "bssid_match: %s", nwam_strerror(err));
- return (B_FALSE);
+ return (0);
}
if ((err = nwam_value_get_string_array(bssidsval, &bssids, &nelem))
!= NWAM_SUCCESS) {
nwam_value_free(bssidsval);
- return (B_FALSE);
+ return (0);
}
for (i = 0; i < nelem; i++) {
- if (strcmp(bssid, bssids[i]) == 0) {
- found = B_TRUE;
+ if (strcmp((const char *)bssid, bssids[i]) == 0) {
+ found = 1;
break;
}
}
@@ -951,7 +988,7 @@ find_best_wlan_cb(nwam_known_wlan_handle_t kwh, void *data)
for (i = 0; i < s->nwamd_wifi_scan_curr_num; i++) {
nwam_wlan_t *cur_wlan = &(s->nwamd_wifi_scan_curr[i]);
- boolean_t b_match = bssid_match(kwh, cur_wlan->nww_bssid);
+ int b_match = bssid_match(kwh, cur_wlan->nww_bssid);
/*
* We need to either match the scanned essid, or in the case
@@ -1332,6 +1369,22 @@ wlan_scan_thread(void *arg)
char keyname[NWAM_MAX_VALUE_LEN];
dladm_wlan_key_t *key = NULL;
+ /*
+ * If strict_bssid is true, we start checking for
+ * known wlans with the same BSSID.
+ * This would prevent the selection of secobjs
+ * that actually are referenced by different kwl
+ * with the same ESSID.
+ */
+ if (wireless_strict_bssid) {
+ int b_match = 0;
+ (void) nwam_walk_known_wlans(bssid_match,
+ s.nwamd_wifi_scan_curr[i].nww_bssid, 0,
+ &b_match);
+ if (b_match == 0)
+ continue;
+ }
+
if (known_wlan_get_keyname
(s.nwamd_wifi_scan_curr[i].nww_essid, keyname)
== NWAM_SUCCESS &&
@@ -1345,6 +1398,8 @@ wlan_scan_thread(void *arg)
nww_security_mode ==
DLADM_WLAN_SECMODE_WEP ?
key->wk_idx : 1;
+ nlog(LOG_DEBUG, "found matching keyname for \
+ %s", s.nwamd_wifi_scan_curr[i].nww_bssid);
free(key);
}
}
diff --git a/usr/src/cmd/cmd-inet/usr.bin/rcp.c b/usr/src/cmd/cmd-inet/usr.bin/rcp.c
index 0c0169cbbc..0bbcc2f2fb 100644
--- a/usr/src/cmd/cmd-inet/usr.bin/rcp.c
+++ b/usr/src/cmd/cmd-inet/usr.bin/rcp.c
@@ -1508,7 +1508,7 @@ sink(int argc, char *argv[])
error("%s\n", cp);
exit(1);
}
- SCREWUP("expected control record");
+ SCREWUP("expected control record")
}
mode = 0;
for (++cp; cp < buf + 5; cp++) {
diff --git a/usr/src/cmd/cmd-inet/usr.sbin/ipadm/ipadm.c b/usr/src/cmd/cmd-inet/usr.sbin/ipadm/ipadm.c
index e097ca6c23..5f86ebcc10 100644
--- a/usr/src/cmd/cmd-inet/usr.sbin/ipadm/ipadm.c
+++ b/usr/src/cmd/cmd-inet/usr.sbin/ipadm/ipadm.c
@@ -20,6 +20,7 @@
*/
/*
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright 2012 Nexenta Systems, Inc. All rights reserved.
*/
#include <arpa/inet.h>
#include <errno.h>
@@ -85,13 +86,11 @@ static cmd_t cmds[] = {
/* address management related sub-commands */
{ "create-addr", do_create_addr,
- "\tcreate-addr\t[-t] {-T static <static_args> |"
- " -T dhcp <dhcp_args> |\n"
- "\t\t\t-T addrconf <addrconf_args>} <addrobj>\n"
- "\t\t\tstatic_args = <[-d] -a {local|remote}=addr[/prefixlen]>\n"
- "\t\t\tdhcp_args = <[-w <seconds> | forever]>\n"
- "\t\t\taddrconf_args = <[-i interface-id]\n"
- "\t\t\t\t\t[-p {stateful|stateless}={yes|no}]>" },
+ "\tcreate-addr\t[-t] -T static [-d] "
+ "-a{local|remote}=addr[/prefixlen]\n\t\t\t<addrobj>\n"
+ "\tcreate-addr\t[-t] -T dhcp [-w <seconds> | forever] <addrobj>\n"
+ "\tcreate-addr\t[-t] -T addrconf [-i interface-id]\n"
+ "\t\t\t[-p {stateful|stateless}={yes|no}] <addrobj>" },
{ "down-addr", do_down_addr, "\tdown-addr\t[-t] <addrobj>" },
{ "up-addr", do_up_addr, "\tup-addr\t\t[-t] <addrobj>" },
{ "disable-addr", do_disable_addr, "\tdisable-addr\t-t <addrobj>" },
@@ -1194,6 +1193,8 @@ process_addrconf_addrargs(const char *use, char *addrarg)
case P_STATELESS:
if (stateless_arg)
die("Duplicate option");
+ if (val == NULL)
+ die("Invalid argument");
if (strcmp(val, "yes") == 0)
stateless = _B_TRUE;
else if (strcmp(val, "no") == 0)
@@ -1205,6 +1206,8 @@ process_addrconf_addrargs(const char *use, char *addrarg)
case P_STATEFUL:
if (stateful_arg)
die("Duplicate option");
+ if (val == NULL)
+ die("Invalid argument");
if (strcmp(val, "yes") == 0)
stateful = _B_TRUE;
else if (strcmp(val, "no") == 0)
diff --git a/usr/src/cmd/cmd-inet/usr.sbin/ipsecutils/ipsecalgs.xml b/usr/src/cmd/cmd-inet/usr.sbin/ipsecutils/ipsecalgs.xml
index 0963209ee5..cdf27133de 100644
--- a/usr/src/cmd/cmd-inet/usr.sbin/ipsecutils/ipsecalgs.xml
+++ b/usr/src/cmd/cmd-inet/usr.sbin/ipsecutils/ipsecalgs.xml
@@ -4,6 +4,8 @@
Copyright 2007 Sun Microsystems, Inc. All rights reserved.
Use is subject to license terms.
+ Copyright (c) 2012 DEY Storage Systems, Inc. All rights reserved.
+
CDDL HEADER START
The contents of this file are subject to the terms of the
@@ -23,8 +25,6 @@
CDDL HEADER END
- ident "%Z%%M% %I% %E% SMI"
-
NOTE: This service manifest is not editable; its contents will
be overwritten by package or patch operations, including
operating system upgrade. Make customizations in a different
@@ -59,6 +59,22 @@
<service_fmri value='file://localhost/etc/inet/ipsecalgs' />
</dependency>
+ <dependency
+ name='filesystem'
+ grouping='require_all'
+ type='service'
+ restart_on='error'>
+ <service_fmri value='svc:/system/filesystem/usr' />
+ </dependency>
+
+ <dependency
+ name='devices'
+ grouping='require_all'
+ type='service'
+ restart_on='none'>
+ <service_fmri value='svc:/system/device/local' />
+ </dependency>
+
<dependent
name='ipsecalgs-network'
grouping='optional_all'
diff --git a/usr/src/cmd/cmd-inet/usr.sbin/nwamadm/nwamadm.c b/usr/src/cmd/cmd-inet/usr.sbin/nwamadm/nwamadm.c
index a262c4e178..2489c678d8 100644
--- a/usr/src/cmd/cmd-inet/usr.sbin/nwamadm/nwamadm.c
+++ b/usr/src/cmd/cmd-inet/usr.sbin/nwamadm/nwamadm.c
@@ -1364,7 +1364,7 @@ select_wifi_func(int argc, char *argv[])
}
}
- err = nwam_wlan_set_key(linkname, essid, NULL, security_mode,
+ err = nwam_wlan_set_key(linkname, essid, bssid, security_mode,
keyslot, key);
if (err != NWAM_SUCCESS)
die_nwamerr(err, "could not set WiFi key");
diff --git a/usr/src/cmd/cmd-inet/usr.sbin/snoop/snoop_capture.c b/usr/src/cmd/cmd-inet/usr.sbin/snoop/snoop_capture.c
index a5cc971d73..ab6bc292ac 100644
--- a/usr/src/cmd/cmd-inet/usr.sbin/snoop/snoop_capture.c
+++ b/usr/src/cmd/cmd-inet/usr.sbin/snoop/snoop_capture.c
@@ -21,6 +21,7 @@
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
+ * Copyright 2012 Milan Jurik. All rights reserved.
*/
#include <stdio.h>
@@ -603,7 +604,8 @@ cap_open_read(const char *name)
{
struct stat st;
int cap_vers;
- int *word, device_mac_type;
+ int *word;
+ int device_mac_type = -1;
int capfile_in;
capfile_in = open(name, O_RDONLY);
diff --git a/usr/src/cmd/cmd-inet/usr.sbin/snoop/snoop_filter.c b/usr/src/cmd/cmd-inet/usr.sbin/snoop/snoop_filter.c
index e68e5f9ce7..16ea65e305 100644
--- a/usr/src/cmd/cmd-inet/usr.sbin/snoop/snoop_filter.c
+++ b/usr/src/cmd/cmd-inet/usr.sbin/snoop/snoop_filter.c
@@ -21,6 +21,7 @@
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
+ * Copyright 2012 Milan Jurik. All rights reserved.
*/
#include <stdio.h>
@@ -1049,10 +1050,8 @@ compare_value_mask(uint_t offset, uint_t len, uint_t val, int mask)
static void
compare_value_zone(uint_t offset, uint32_t val)
{
- int i;
-
- load_const(ntohl(((uint32_t *)&val)[i]));
- load_value(offset + i * 4, 4);
+ load_const(ntohl(val));
+ load_value(offset, 4);
emitop(OP_EQ);
}
@@ -1582,6 +1581,9 @@ ipaddr_match(enum direction which, char *hostname, int inet_type)
}
}
+ if (hp == NULL)
+ return;
+
switch (which) {
case TO:
addr4offset = IPV4_DSTADDR_OFFSET;
@@ -1600,7 +1602,7 @@ ipaddr_match(enum direction which, char *hostname, int inet_type)
/*
* The code below generates the filter.
*/
- if (hp != NULL && hp->h_addrtype == AF_INET) {
+ if (hp->h_addrtype == AF_INET) {
ethertype_match(interface->network_type_ip);
emitop(OP_BRFL);
n = chain(n);
diff --git a/usr/src/cmd/cmd-inet/usr.sbin/snoop/snoop_ip.c b/usr/src/cmd/cmd-inet/usr.sbin/snoop/snoop_ip.c
index e062411d66..af37d85d67 100644
--- a/usr/src/cmd/cmd-inet/usr.sbin/snoop/snoop_ip.c
+++ b/usr/src/cmd/cmd-inet/usr.sbin/snoop/snoop_ip.c
@@ -21,6 +21,7 @@
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
+ * Copyright 2012 Milan Jurik. All rights reserved.
*/
#include <stdio.h>
@@ -1205,7 +1206,7 @@ print_ripso(const uchar_t *opt)
* Display Classification Level
*/
ripso_class = get_pair_byval(ripso_class_tbl, (int)opt[2]);
- if (ripso_class != NULL)
+ if (ripso_class == NULL)
(void) snprintf(get_line(0, 0), get_line_remain(),
"Classification = Unknown (0x%02x)", opt[2]);
else
diff --git a/usr/src/cmd/cmd-inet/usr.sbin/snoop/snoop_pf.c b/usr/src/cmd/cmd-inet/usr.sbin/snoop/snoop_pf.c
index dc4a47b2d5..40faeb5b3e 100644
--- a/usr/src/cmd/cmd-inet/usr.sbin/snoop/snoop_pf.c
+++ b/usr/src/cmd/cmd-inet/usr.sbin/snoop/snoop_pf.c
@@ -21,6 +21,7 @@
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
+ * Copyright 2012 Milan Jurik. All rights reserved.
*/
#include <stdio.h>
@@ -688,6 +689,9 @@ pf_ipaddr_match(which, hostname, inet_type)
pr_err("unknown token type: %s", hostname);
}
+ if (hp == NULL)
+ return;
+
switch (which) {
case TO:
addr4offset = IPV4_DSTADDR_OFFSET;
@@ -703,7 +707,7 @@ pf_ipaddr_match(which, hostname, inet_type)
break;
}
- if (hp != NULL && hp->h_addrtype == AF_INET) {
+ if (hp->h_addrtype == AF_INET) {
pf_matchfn("ip");
if (dl.dl_type == DL_ETHER)
pf_check_vlan_tag(ENCAP_ETHERTYPE_OFF/2);
@@ -809,9 +813,7 @@ pf_ipaddr_match(which, hostname, inet_type)
}
}
- if (hp != NULL) {
- freehostent(hp);
- }
+ freehostent(hp);
}
diff --git a/usr/src/cmd/cmd-inet/usr.sbin/snoop/snoop_rpcsec.c b/usr/src/cmd/cmd-inet/usr.sbin/snoop/snoop_rpcsec.c
index ab6f1f6127..e3579dc4f4 100644
--- a/usr/src/cmd/cmd-inet/usr.sbin/snoop/snoop_rpcsec.c
+++ b/usr/src/cmd/cmd-inet/usr.sbin/snoop/snoop_rpcsec.c
@@ -22,10 +22,9 @@
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
+ * Copyright 2012 Milan Jurik. All rights reserved.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
#include <sys/types.h>
#include <sys/errno.h>
#include <sys/tiuser.h>
@@ -105,15 +104,15 @@ print_rpcsec_gss_cred(int xid, int authlen)
rpcsec_gss_service = getxdr_enum();
(void) sprintf(get_line(pos, getxdr_pos()),
- " version = %u", rpcsec_gss_ver);
+ " version = %u", rpcsec_gss_ver);
(void) sprintf(get_line(pos, getxdr_pos()),
- " gss control procedure = %u (%s)",
- rpcsec_gss_proc,
- rpcsec_gss_proc_to_string(rpcsec_gss_proc));
+ " gss control procedure = %u (%s)",
+ rpcsec_gss_proc,
+ rpcsec_gss_proc_to_string(rpcsec_gss_proc));
(void) sprintf(get_line(pos, getxdr_pos()),
- " sequence num = %u", seq_num);
+ " sequence num = %u", seq_num);
(void) sprintf(get_line(pos, getxdr_pos()),
" service = %d (%s)", rpcsec_gss_service,
@@ -123,7 +122,7 @@ print_rpcsec_gss_cred(int xid, int authlen)
handle = getxdr_hex(handle_len);
line = get_line(pos, getxdr_pos());
sprintf(line, " handle: length = %d, data = [%s]",
- handle_len, handle);
+ handle_len, handle);
x = find_xid(xid);
if (x) {
x->xid_gss_proc = rpcsec_gss_proc;
@@ -159,11 +158,11 @@ rpcsec_gss_pre_proto(int type, int flags, int xid,
seq = getxdr_u_long();
if (flags & F_ALLSUM) {
(void) sprintf(get_sum_line(), "%s %c seq_num = %u",
- "RPC RPCSEC_GSS", type == CALL ? 'C' : 'R',
- seq);
+ "RPC RPCSEC_GSS", type == CALL ? 'C' : 'R',
+ seq);
} else if (flags & F_DTAIL) {
sprintf(get_line(0, 0),
- "RPCSEC_GSS data seq_num = %u", seq);
+ "RPCSEC_GSS data seq_num = %u", seq);
show_space();
}
/* call args follow */
@@ -178,21 +177,21 @@ rpcsec_gss_pre_proto(int type, int flags, int xid,
}
if (flags & F_SUM || flags & F_ALLSUM) {
- (void) sprintf(get_sum_line(),
- "%s %c %s ver(%d) proc(%d) (data encrypted) ",
- "RPC RPCSEC_GSS", type == CALL ? 'C' : 'R',
- progname, vers, proc);
+ (void) sprintf(get_sum_line(),
+ "%s %c %s ver(%d) proc(%d) (data encrypted) ",
+ "RPC RPCSEC_GSS", type == CALL ? 'C' : 'R',
+ progname, vers, proc);
} else if (flags & F_DTAIL) {
- unsigned int args_len;
-
- args_len = getxdr_u_long();
- sprintf(get_line(0, 0),
- "RPCSEC_GSS %s ver(%d) proc(%d)",
- progname, vers, proc);
- sprintf(get_line(0, 0),
- "(%s args encrypted, len = %d bytes)",
- type == CALL ? "CALL" : "REPLY", args_len);
- show_space();
+ unsigned int args_len;
+
+ args_len = getxdr_u_long();
+ sprintf(get_line(0, 0),
+ "RPCSEC_GSS %s ver(%d) proc(%d)",
+ progname, vers, proc);
+ sprintf(get_line(0, 0),
+ "(%s args encrypted, len = %d bytes)",
+ type == CALL ? "CALL" : "REPLY", args_len);
+ show_space();
}
}
return (1);
@@ -238,7 +237,7 @@ rpcsec_gss_post_proto(int flags, int xid)
checksum_len = getxdr_u_long();
checksum = getxdr_hex(checksum_len);
sprintf(get_line(0, 0),
- "checksum: len = %d", checksum_len);
+ "checksum: len = %d", checksum_len);
sprintf(get_line(0, 0), "[%s]", checksum);
show_trailer();
}
@@ -266,10 +265,10 @@ rpcsec_gss_control_proc(int type, int flags, int xid)
if (flags & F_SUM) {
if (type == CALL) {
(void) sprintf(get_sum_line(), "%s %c %u (%s)",
- "RPC RPCSEC_GSS",
- type == CALL ? 'C' : 'R',
- x->xid_gss_proc,
- rpcsec_gss_proc_to_string(x->xid_gss_proc));
+ "RPC RPCSEC_GSS",
+ type == CALL ? 'C' : 'R',
+ x->xid_gss_proc,
+ rpcsec_gss_proc_to_string(x->xid_gss_proc));
}
} else if (flags & F_DTAIL) {
if (x->xid_gss_proc == RPCSEC_GSS_INIT ||
@@ -330,7 +329,7 @@ print_rpc_gss_init_arg(int flags, struct cache_struct *x)
char *token, *line;
unsigned int token_len;
- int pos;
+ int pos = 0;
/*
* see if we need to print out the rpc_gss_init_arg structure
@@ -338,21 +337,21 @@ print_rpc_gss_init_arg(int flags, struct cache_struct *x)
*/
if (x->xid_gss_proc != RPCSEC_GSS_INIT &&
- x->xid_gss_proc != RPCSEC_GSS_CONTINUE_INIT) {
+ x->xid_gss_proc != RPCSEC_GSS_CONTINUE_INIT) {
return;
}
/* print it */
(void) sprintf(get_line(pos, getxdr_pos()),
- "RPCSEC_GSS_INIT args:");
+ "RPCSEC_GSS_INIT args:");
pos = getxdr_pos();
token_len = getxdr_u_long();
token = getxdr_hex(token_len);
line = get_line(pos, getxdr_pos());
- sprintf(line, " gss token: length = %d, data = [%d bytes]",
- token_len, token_len);
+ sprintf(line, " gss token: length = %d, data = [%d bytes]",
+ token_len, token_len);
show_trailer();
}
@@ -368,7 +367,7 @@ print_rpc_gss_init_res(int flags)
unsigned int token_len, handle_len;
unsigned int major, minor, seq_window;
- int pos;
+ int pos = 0;
struct cache_struct *x;
/* print it */
@@ -380,25 +379,25 @@ print_rpc_gss_init_res(int flags)
handle = getxdr_hex(handle_len);
line = get_line(pos, getxdr_pos());
sprintf(line, " handle: length = %d, data = [%s]",
- handle_len, handle);
+ handle_len, handle);
pos = getxdr_pos();
major = getxdr_u_long();
minor = getxdr_u_long();
seq_window = getxdr_u_long();
(void) sprintf(get_line(pos, getxdr_pos()),
- " gss_major status = %u", major);
+ " gss_major status = %u", major);
(void) sprintf(get_line(pos, getxdr_pos()),
- " gss_minor status = %u", minor);
+ " gss_minor status = %u", minor);
(void) sprintf(get_line(pos, getxdr_pos()),
- " sequence window = %u", seq_window);
+ " sequence window = %u", seq_window);
pos = getxdr_pos();
token_len = getxdr_u_long();
token = getxdr_hex(token_len);
line = get_line(pos, getxdr_pos());
sprintf(line, " gss token: length = %d, data = [%d bytes]",
- token_len, token_len);
+ token_len, token_len);
show_trailer();
}
diff --git a/usr/src/cmd/dtrace/dtrace.c b/usr/src/cmd/dtrace/dtrace.c
index 81a6953b63..e74e3df690 100644
--- a/usr/src/cmd/dtrace/dtrace.c
+++ b/usr/src/cmd/dtrace/dtrace.c
@@ -23,8 +23,9 @@
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
-
-#pragma ident "%Z%%M% %I% %E% SMI"
+/*
+ * Copyright (c) 2012 by Delphix. All rights reserved.
+ */
#include <sys/types.h>
#include <sys/stat.h>
@@ -1339,6 +1340,7 @@ main(int argc, char *argv[])
(void) dtrace_setopt(g_dtp, "bufsize", "4m");
(void) dtrace_setopt(g_dtp, "aggsize", "4m");
+ (void) dtrace_setopt(g_dtp, "temporal", "yes");
/*
* If -G is specified, enable -xlink=dynamic and -xunodefs to permit
diff --git a/usr/src/cmd/dtrace/test/cmd/scripts/dtest.pl b/usr/src/cmd/dtrace/test/cmd/scripts/dtest.pl
index 6a42340b5b..0cda80bd0b 100644
--- a/usr/src/cmd/dtrace/test/cmd/scripts/dtest.pl
+++ b/usr/src/cmd/dtrace/test/cmd/scripts/dtest.pl
@@ -27,6 +27,7 @@
#
# Copyright (c) 2011, Joyent, Inc. All rights reserved.
+# Copyright (c) 2012 by Delphix. All rights reserved.
#
require 5.8.4;
@@ -612,6 +613,8 @@ if ($opt_x) {
die "$PNAME: failed to open $PNAME.$$.log: $!\n"
unless (!$opt_l || open(LOG, ">$PNAME.$$.log"));
+$ENV{'DTRACE_DEBUG_REGSET'} = 'true';
+
if ($opt_g) {
$ENV{'UMEM_DEBUG'} = 'default,verbose';
$ENV{'UMEM_LOGGING'} = 'fail,contents';
diff --git a/usr/src/cmd/dtrace/test/tst/common/aggs/tst.sizedkeys.d b/usr/src/cmd/dtrace/test/tst/common/aggs/tst.sizedkeys.d
new file mode 100644
index 0000000000..bb3ed4789b
--- /dev/null
+++ b/usr/src/cmd/dtrace/test/tst/common/aggs/tst.sizedkeys.d
@@ -0,0 +1,35 @@
+/*
+ * CDDL HEADER START
+ *
+ * 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.
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 2012 by Delphix. All rights reserved.
+ */
+
+#pragma D option quiet
+
+/*
+ * Make sure the sizes of compatible keys doesn't affect the sort order.
+ */
+
+BEGIN
+{
+ @[(int)1, 0] = sum(10);
+ @[(uint64_t)2, 0] = sum(20);
+ @[(int)3, 0] = sum(30);
+ @[(uint64_t)4, 0] = sum(40);
+ printa(@);
+
+ exit(0);
+}
diff --git a/usr/src/cmd/dtrace/test/tst/common/aggs/tst.sizedkeys.d.out b/usr/src/cmd/dtrace/test/tst/common/aggs/tst.sizedkeys.d.out
new file mode 100644
index 0000000000..83252ade53
--- /dev/null
+++ b/usr/src/cmd/dtrace/test/tst/common/aggs/tst.sizedkeys.d.out
@@ -0,0 +1,6 @@
+
+ 1 0 10
+ 2 0 20
+ 3 0 30
+ 4 0 40
+
diff --git a/usr/src/cmd/dtrace/test/tst/common/arithmetic/tst.basics.d.out b/usr/src/cmd/dtrace/test/tst/common/arithmetic/tst.basics.d.out
new file mode 100644
index 0000000000..d3b6af8131
--- /dev/null
+++ b/usr/src/cmd/dtrace/test/tst/common/arithmetic/tst.basics.d.out
@@ -0,0 +1,8 @@
+The value of i is 6
+The value of i is 18
+The value of i is 72
+The value of i is 25920
+The value of i is 935761216
+The value of i is -91738734
+The value of i is -91738729
+
diff --git a/usr/src/cmd/dtrace/test/tst/common/arithmetic/tst.compcast.d b/usr/src/cmd/dtrace/test/tst/common/arithmetic/tst.compcast.d
new file mode 100644
index 0000000000..714fbe373b
--- /dev/null
+++ b/usr/src/cmd/dtrace/test/tst/common/arithmetic/tst.compcast.d
@@ -0,0 +1,50 @@
+/*
+ * CDDL HEADER START
+ *
+ * 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.
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 2012 by Delphix. All rights reserved.
+ */
+
+/*
+ * Test compile-time casting between integer types of different size.
+ */
+
+#pragma D option quiet
+
+int64_t x;
+
+BEGIN
+{
+ x = (int32_t)(int16_t)0xfff0;
+ printf("%16x %20d %20u\n", x, x, x);
+ x = (int32_t)(uint16_t)0xfff0;
+ printf("%16x %20d %20u\n", x, x, x);
+ x = (uint32_t)(int16_t)0xfff0;
+ printf("%16x %20d %20u\n", x, x, x);
+ x = (uint32_t)(uint16_t)0xfff0;
+ printf("%16x %20d %20u\n", x, x, x);
+ printf("\n");
+
+ x = (int16_t)(int32_t)0xfff0;
+ printf("%16x %20d %20u\n", x, x, x);
+ x = (int16_t)(uint32_t)0xfff0;
+ printf("%16x %20d %20u\n", x, x, x);
+ x = (uint16_t)(int32_t)0xfff0;
+ printf("%16x %20d %20u\n", x, x, x);
+ x = (uint16_t)(uint32_t)0xfff0;
+ printf("%16x %20d %20u\n", x, x, x);
+
+ exit(0);
+}
diff --git a/usr/src/cmd/dtrace/test/tst/common/arithmetic/tst.compcast.d.out b/usr/src/cmd/dtrace/test/tst/common/arithmetic/tst.compcast.d.out
new file mode 100644
index 0000000000..d43df27d5d
--- /dev/null
+++ b/usr/src/cmd/dtrace/test/tst/common/arithmetic/tst.compcast.d.out
@@ -0,0 +1,10 @@
+fffffffffffffff0 -16 18446744073709551600
+ fff0 65520 65520
+ fffffff0 4294967280 4294967280
+ fff0 65520 65520
+
+fffffffffffffff0 -16 18446744073709551600
+fffffffffffffff0 -16 18446744073709551600
+ fff0 65520 65520
+ fff0 65520 65520
+
diff --git a/usr/src/cmd/dtrace/test/tst/common/arithmetic/tst.complex.d b/usr/src/cmd/dtrace/test/tst/common/arithmetic/tst.complex.d
deleted file mode 100644
index 2db1b6350b..0000000000
--- a/usr/src/cmd/dtrace/test/tst/common/arithmetic/tst.complex.d
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License (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 2006 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*
- * ASSERTION:
- * Complex expressions.
- * Call complex expressions and make sure test succeeds.
- * Match expected output in tst.complex.d.out
- *
- * SECTION: Types, Operators, and Expressions/Arithmetic Operators
- *
- */
-
-#pragma D option quiet
-
-BEGIN
-{
- i = 0;
- i = i++ + ++i;
- printf("The value of i is %d\n", i);
- i = i-- - --i;
- printf("The value of i is %d\n", i);
- i = i-- + ++i;
- printf("The value of i is %d\n", i);
- i += i++ + -- i + ++i - ++i * i ;
- printf("The value of i is %d\n", i);
- i -= i++ * 3;
- printf("The value of i is %d\n", i);
- i = i++/i--+i++-++i-++i;
- printf("The value of i is %d\n", i);
- exit (0);
-}
diff --git a/usr/src/cmd/dtrace/test/tst/common/arithmetic/tst.compnarrowassign.d b/usr/src/cmd/dtrace/test/tst/common/arithmetic/tst.compnarrowassign.d
new file mode 100644
index 0000000000..0589b721b4
--- /dev/null
+++ b/usr/src/cmd/dtrace/test/tst/common/arithmetic/tst.compnarrowassign.d
@@ -0,0 +1,36 @@
+/*
+ * CDDL HEADER START
+ *
+ * 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.
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 2012 by Delphix. All rights reserved.
+ */
+
+/*
+ * Test narrowing at assignment.
+ */
+
+#pragma D option quiet
+
+uint16_t x;
+uint32_t y;
+
+BEGIN
+{
+ x = 0xbeefcafe;
+ y = x;
+ printf("%x", y); /* where's the beef? */
+
+ exit(0);
+}
diff --git a/usr/src/cmd/dtrace/test/tst/common/arithmetic/tst.compnarrowassign.d.out b/usr/src/cmd/dtrace/test/tst/common/arithmetic/tst.compnarrowassign.d.out
new file mode 100644
index 0000000000..ea17b160d2
--- /dev/null
+++ b/usr/src/cmd/dtrace/test/tst/common/arithmetic/tst.compnarrowassign.d.out
@@ -0,0 +1 @@
+cafe
diff --git a/usr/src/cmd/dtrace/test/tst/common/arithmetic/tst.execcast.d b/usr/src/cmd/dtrace/test/tst/common/arithmetic/tst.execcast.d
new file mode 100644
index 0000000000..a7017bfee5
--- /dev/null
+++ b/usr/src/cmd/dtrace/test/tst/common/arithmetic/tst.execcast.d
@@ -0,0 +1,52 @@
+/*
+ * CDDL HEADER START
+ *
+ * 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.
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 2012 by Delphix. All rights reserved.
+ */
+
+/*
+ * Test execution-time casting between integer types of different size.
+ */
+
+#pragma D option quiet
+
+int64_t x;
+
+BEGIN
+{
+ z = 0xfff0;
+
+ x = (int32_t)(int16_t)z;
+ printf("%16x %20d %20u\n", x, x, x);
+ x = (int32_t)(uint16_t)z;
+ printf("%16x %20d %20u\n", x, x, x);
+ x = (uint32_t)(int16_t)z;
+ printf("%16x %20d %20u\n", x, x, x);
+ x = (uint32_t)(uint16_t)z;
+ printf("%16x %20d %20u\n", x, x, x);
+ printf("\n");
+
+ x = (int16_t)(int32_t)z;
+ printf("%16x %20d %20u\n", x, x, x);
+ x = (int16_t)(uint32_t)z;
+ printf("%16x %20d %20u\n", x, x, x);
+ x = (uint16_t)(int32_t)z;
+ printf("%16x %20d %20u\n", x, x, x);
+ x = (uint16_t)(uint32_t)z;
+ printf("%16x %20d %20u\n", x, x, x);
+
+ exit(0);
+}
diff --git a/usr/src/cmd/dtrace/test/tst/common/arithmetic/tst.execcast.d.out b/usr/src/cmd/dtrace/test/tst/common/arithmetic/tst.execcast.d.out
new file mode 100644
index 0000000000..d43df27d5d
--- /dev/null
+++ b/usr/src/cmd/dtrace/test/tst/common/arithmetic/tst.execcast.d.out
@@ -0,0 +1,10 @@
+fffffffffffffff0 -16 18446744073709551600
+ fff0 65520 65520
+ fffffff0 4294967280 4294967280
+ fff0 65520 65520
+
+fffffffffffffff0 -16 18446744073709551600
+fffffffffffffff0 -16 18446744073709551600
+ fff0 65520 65520
+ fff0 65520 65520
+
diff --git a/usr/src/cmd/dtrace/test/tst/common/buffering/tst.fill1.d b/usr/src/cmd/dtrace/test/tst/common/buffering/tst.fill1.d
index 143ed641f9..fffc7e3d55 100644
--- a/usr/src/cmd/dtrace/test/tst/common/buffering/tst.fill1.d
+++ b/usr/src/cmd/dtrace/test/tst/common/buffering/tst.fill1.d
@@ -23,26 +23,29 @@
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
-
-#pragma ident "%Z%%M% %I% %E% SMI"
+/*
+ * Copyright (c) 2012 by Delphix. All rights reserved.
+ */
/*
* ASSERTION:
* Positive test for fill buffer policy.
*
* SECTION: Buffers and Buffering/fill Policy;
- * Buffers and Buffering/Buffer Sizes;
+ * Buffers and Buffering/Buffer Sizes;
* Options and Tunables/bufsize;
* Options and Tunables/bufpolicy;
* Options and Tunables/statusrate
*/
/*
- * This is a brute-force way of testing fill buffers. We assume that each
- * printf() stores 8 bytes. Because each fill buffer is per-CPU, we must
- * fill up our buffer in one series of enablings on a single CPU.
+ * This is a brute-force way of testing fill buffers. We assume that
+ * each printf() stores 16 bytes (4x 32-bit words for EPID, timestamp
+ * lo, timestamp hi, and the variable i). Because each fill buffer is
+ * per-CPU, we must fill up our buffer in one series of enablings on a
+ * single CPU.
*/
#pragma D option bufpolicy=fill
-#pragma D option bufsize=64
+#pragma D option bufsize=128
#pragma D option statusrate=10ms
#pragma D option quiet
diff --git a/usr/src/cmd/dtrace/test/tst/common/buffering/tst.ring3.d b/usr/src/cmd/dtrace/test/tst/common/buffering/tst.ring3.d
index 68e35889ec..ea746948e5 100644
--- a/usr/src/cmd/dtrace/test/tst/common/buffering/tst.ring3.d
+++ b/usr/src/cmd/dtrace/test/tst/common/buffering/tst.ring3.d
@@ -23,8 +23,9 @@
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
-
-#pragma ident "%Z%%M% %I% %E% SMI"
+/*
+ * Copyright (c) 2012 by Delphix. All rights reserved.
+ */
/*
* ASSERTION:
@@ -37,19 +38,20 @@
*/
/*
- * We make some regrettable assumptions about the implementation in this test.
- * First, we assume that each entry for the printf() of an int takes _exactly_
- * eight bytes (four bytes for the EPID, four bytes for the payload). Second,
- * we assume that by allocating storage for n + 1 records, we will get exactly
- * n. Here is why: the final predicate that evaluates to false will reserve
- * space that it won't use. This act of reservation will advance the wrapped
- * offset. That record won't be subsequently used, but the wrapped offset has
- * advanced. (And in this case, that old record is clobbered by the exit()
- * anyway.) Thirdly: we rely on t_cpu/cpu_id. Finally: we rely on being
- * able to run on the CPU that we first ran on.
+ * We make some regrettable assumptions about the implementation in this
+ * test. First, we assume that each entry for the printf() of an int
+ * takes _exactly_ 16 bytes (4 bytes for the EPID, 8 bytes for the
+ * timestamp, 4 bytes for the payload). Second, we assume that by
+ * allocating storage for n + 1 records, we will get exactly n. Here is
+ * why: the final predicate that evaluates to false will reserve space
+ * that it won't use. This act of reservation will advance the wrapped
+ * offset. That record won't be subsequently used, but the wrapped
+ * offset has advanced. (And in this case, that old record is clobbered
+ * by the exit() anyway.) Thirdly: we rely on t_cpu/cpu_id. Finally:
+ * we rely on being able to run on the CPU that we first ran on.
*/
#pragma D option bufpolicy=ring
-#pragma D option bufsize=40
+#pragma D option bufsize=80
#pragma D option quiet
int n;
diff --git a/usr/src/cmd/dtrace/test/tst/common/cg/err.D_NOREG.noreg.d b/usr/src/cmd/dtrace/test/tst/common/cg/err.D_NOREG.noreg.d
new file mode 100644
index 0000000000..636e568643
--- /dev/null
+++ b/usr/src/cmd/dtrace/test/tst/common/cg/err.D_NOREG.noreg.d
@@ -0,0 +1,41 @@
+/*
+ * CDDL HEADER START
+ *
+ * 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.
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 2012 by Delphix. All rights reserved.
+ */
+
+/*
+ * Compile some code that requires exactly 9 registers. This should run out
+ * of registers.
+ *
+ * Changes to the code generator might cause this test to succeeed in which
+ * case the code should be changed to another sequence that exhausts the
+ * available internal registers.
+ *
+ * Note that this and err.baddif.d should be kept in sync.
+ */
+
+BEGIN
+{
+ a = 4;
+ trace((a + a) * ((a + a) * ((a + a) * ((a + a) * ((a + a) *
+ ((a + a) * (a + a)))))));
+}
+
+BEGIN
+{
+ exit(0);
+}
diff --git a/usr/src/cmd/dtrace/test/tst/common/cg/err.baddif.d b/usr/src/cmd/dtrace/test/tst/common/cg/err.baddif.d
new file mode 100644
index 0000000000..d849348233
--- /dev/null
+++ b/usr/src/cmd/dtrace/test/tst/common/cg/err.baddif.d
@@ -0,0 +1,44 @@
+/*
+ * CDDL HEADER START
+ *
+ * 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.
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 2012 by Delphix. All rights reserved.
+ */
+
+/*
+ * Compile some code that requires exactly 9 registers. This should generate
+ * invalid DIF because the kernel will flag the fact that we're using more
+ * registers than are available internally.
+ *
+ * Changes to the code generator might cause this test to succeeed in which
+ * case the code should be changed to another sequence that exhausts the
+ * available internal registers.
+ *
+ * Note that this and err.D_NOREG.noreg.d should be kept in sync.
+ */
+
+#pragma D option iregs=9
+
+BEGIN
+{
+ a = 4;
+ trace((a + a) * ((a + a) * ((a + a) * ((a + a) * ((a + a) *
+ ((a + a) * (a + a)))))));
+}
+
+BEGIN
+{
+ exit(0);
+}
diff --git a/usr/src/cmd/dtrace/test/tst/common/env/err.D_PRAGMA_OPTSET.setfromscript.d b/usr/src/cmd/dtrace/test/tst/common/env/err.D_PRAGMA_OPTSET.setfromscript.d
new file mode 100644
index 0000000000..ec4b4ee0b1
--- /dev/null
+++ b/usr/src/cmd/dtrace/test/tst/common/env/err.D_PRAGMA_OPTSET.setfromscript.d
@@ -0,0 +1,25 @@
+/*
+ * CDDL HEADER START
+ *
+ * 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.
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 2012 by Delphix. All rights reserved.
+ */
+
+#pragma D option setenv=balloon=something_bad_happens
+
+BEGIN
+{
+ exit(0);
+}
diff --git a/usr/src/cmd/dtrace/test/tst/common/env/err.D_PRAGMA_OPTSET.unsetfromscript.d b/usr/src/cmd/dtrace/test/tst/common/env/err.D_PRAGMA_OPTSET.unsetfromscript.d
new file mode 100644
index 0000000000..7adc77fe7e
--- /dev/null
+++ b/usr/src/cmd/dtrace/test/tst/common/env/err.D_PRAGMA_OPTSET.unsetfromscript.d
@@ -0,0 +1,25 @@
+/*
+ * CDDL HEADER START
+ *
+ * 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.
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 2012 by Delphix. All rights reserved.
+ */
+
+#pragma D option unsetenv=rectalexambot
+
+BEGIN
+{
+ exit(0);
+}
diff --git a/usr/src/cmd/dtrace/test/tst/common/env/tst.ld_nolazyload.ksh b/usr/src/cmd/dtrace/test/tst/common/env/tst.ld_nolazyload.ksh
new file mode 100644
index 0000000000..731a207e6a
--- /dev/null
+++ b/usr/src/cmd/dtrace/test/tst/common/env/tst.ld_nolazyload.ksh
@@ -0,0 +1,33 @@
+#
+# CDDL HEADER START
+#
+# 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.
+#
+# CDDL HEADER END
+#
+
+#
+# Copyright (c) 2012 by Delphix. All rights reserved.
+#
+
+#
+# Check that the LD_NOLAZYLOAD variable is set to 1 as expected.
+#
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+$dtrace -q -Z -n doogle -c 'printenv LD_NOLAZYLOAD'
+
+exit $?
diff --git a/usr/src/cmd/dtrace/test/tst/common/env/tst.ld_nolazyload.ksh.out b/usr/src/cmd/dtrace/test/tst/common/env/tst.ld_nolazyload.ksh.out
new file mode 100644
index 0000000000..d474e1b4d6
--- /dev/null
+++ b/usr/src/cmd/dtrace/test/tst/common/env/tst.ld_nolazyload.ksh.out
@@ -0,0 +1,2 @@
+1
+
diff --git a/usr/src/cmd/dtrace/test/tst/common/env/tst.setenv1.ksh b/usr/src/cmd/dtrace/test/tst/common/env/tst.setenv1.ksh
new file mode 100644
index 0000000000..b72b23d8a0
--- /dev/null
+++ b/usr/src/cmd/dtrace/test/tst/common/env/tst.setenv1.ksh
@@ -0,0 +1,33 @@
+#
+# CDDL HEADER START
+#
+# 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.
+#
+# CDDL HEADER END
+#
+
+#
+# Copyright (c) 2012 by Delphix. All rights reserved.
+#
+
+#
+# Reset an environment variable we already know to be set.
+#
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+$dtrace -q -Z -n doogle -xsetenv=LD_NOLAZYLOAD=0 -c 'printenv LD_NOLAZYLOAD'
+
+exit $?
diff --git a/usr/src/cmd/dtrace/test/tst/common/env/tst.setenv1.ksh.out b/usr/src/cmd/dtrace/test/tst/common/env/tst.setenv1.ksh.out
new file mode 100644
index 0000000000..77ac542d4f
--- /dev/null
+++ b/usr/src/cmd/dtrace/test/tst/common/env/tst.setenv1.ksh.out
@@ -0,0 +1,2 @@
+0
+
diff --git a/usr/src/cmd/dtrace/test/tst/common/env/tst.setenv2.ksh b/usr/src/cmd/dtrace/test/tst/common/env/tst.setenv2.ksh
new file mode 100644
index 0000000000..4e962a8126
--- /dev/null
+++ b/usr/src/cmd/dtrace/test/tst/common/env/tst.setenv2.ksh
@@ -0,0 +1,33 @@
+#
+# CDDL HEADER START
+#
+# 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.
+#
+# CDDL HEADER END
+#
+
+#
+# Copyright (c) 2012 by Delphix. All rights reserved.
+#
+
+#
+# Test setting a variable that we isn't already set.
+#
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+$dtrace -q -Z -n doogle -xsetenv=CORPORATIONS=PEOPLE -c 'printenv CORPORATIONS'
+
+exit $?
diff --git a/usr/src/cmd/dtrace/test/tst/common/env/tst.setenv2.ksh.out b/usr/src/cmd/dtrace/test/tst/common/env/tst.setenv2.ksh.out
new file mode 100644
index 0000000000..ca5c4ffdda
--- /dev/null
+++ b/usr/src/cmd/dtrace/test/tst/common/env/tst.setenv2.ksh.out
@@ -0,0 +1,2 @@
+PEOPLE
+
diff --git a/usr/src/cmd/dtrace/test/tst/common/env/tst.unsetenv1.ksh b/usr/src/cmd/dtrace/test/tst/common/env/tst.unsetenv1.ksh
new file mode 100644
index 0000000000..73e1297d23
--- /dev/null
+++ b/usr/src/cmd/dtrace/test/tst/common/env/tst.unsetenv1.ksh
@@ -0,0 +1,33 @@
+#
+# CDDL HEADER START
+#
+# 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.
+#
+# CDDL HEADER END
+#
+
+#
+# Copyright (c) 2012 by Delphix. All rights reserved.
+#
+
+#
+# Test unsetting a variable we know to be set.
+#
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+$dtrace -q -Z -n doogle -xunsetenv=LD_NOLAZYLOAD -c 'printenv LD_NOLAZYLOAD'
+
+exit $?
diff --git a/usr/src/cmd/dtrace/test/tst/common/env/tst.unsetenv1.ksh.out b/usr/src/cmd/dtrace/test/tst/common/env/tst.unsetenv1.ksh.out
new file mode 100644
index 0000000000..8b13789179
--- /dev/null
+++ b/usr/src/cmd/dtrace/test/tst/common/env/tst.unsetenv1.ksh.out
@@ -0,0 +1 @@
+
diff --git a/usr/src/cmd/dtrace/test/tst/common/env/tst.unsetenv2.ksh b/usr/src/cmd/dtrace/test/tst/common/env/tst.unsetenv2.ksh
new file mode 100644
index 0000000000..467c60d775
--- /dev/null
+++ b/usr/src/cmd/dtrace/test/tst/common/env/tst.unsetenv2.ksh
@@ -0,0 +1,35 @@
+#
+# CDDL HEADER START
+#
+# 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.
+#
+# CDDL HEADER END
+#
+
+#
+# Copyright (c) 2012 by Delphix. All rights reserved.
+#
+
+#
+# Test invalid syntax to the unsetenv option.
+#
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+$dtrace -q -Z -n doogle -xunsetenv=ed=screven -c 'true' 2>&1
+
+[[ $? -eq 1 ]] && exit 0
+
+exit 1
diff --git a/usr/src/cmd/dtrace/test/tst/common/env/tst.unsetenv2.ksh.out b/usr/src/cmd/dtrace/test/tst/common/env/tst.unsetenv2.ksh.out
new file mode 100644
index 0000000000..a2dd32a393
--- /dev/null
+++ b/usr/src/cmd/dtrace/test/tst/common/env/tst.unsetenv2.ksh.out
@@ -0,0 +1 @@
+dtrace: failed to set -x unsetenv: Invalid value for specified option
diff --git a/usr/src/cmd/dtrace/test/tst/common/pid/tst.newprobes.ksh b/usr/src/cmd/dtrace/test/tst/common/pid/tst.newprobes.ksh
index 35f0391ba8..25ae061ec0 100644
--- a/usr/src/cmd/dtrace/test/tst/common/pid/tst.newprobes.ksh
+++ b/usr/src/cmd/dtrace/test/tst/common/pid/tst.newprobes.ksh
@@ -24,7 +24,9 @@
# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
-# ident "%Z%%M% %I% %E% SMI"
+
+#
+# Copyright (c) 2012 by Delphix. All rights reserved.
#
if [ $# != 1 ]; then
@@ -49,13 +51,13 @@ tick-1s
tick-1s
/(i % 2) == 0/
{
- system("dtrace -c date -ln 'pid\$target::main:entry' >/dev/null");
+ system("dtrace -c date -n 'pid\$target::main:entry' >/dev/null");
}
tick-1s
/(i % 2) == 1/
{
- system("dtrace -c date -ln 'pid\$target::main:return' >/dev/null");
+ system("dtrace -c date -n 'pid\$target::main:return' >/dev/null");
}
EOF
diff --git a/usr/src/cmd/dtrace/test/tst/common/pointers/tst.assigncast1.d b/usr/src/cmd/dtrace/test/tst/common/pointers/tst.assigncast1.d
new file mode 100644
index 0000000000..0567123f3a
--- /dev/null
+++ b/usr/src/cmd/dtrace/test/tst/common/pointers/tst.assigncast1.d
@@ -0,0 +1,28 @@
+/*
+ * CDDL HEADER START
+ *
+ * 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.
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 2012 by Delphix. All rights reserved.
+ */
+
+BEGIN
+{
+ *((int *)alloca(4)) = 1;
+}
+
+BEGIN
+{
+ exit(0);
+}
diff --git a/usr/src/cmd/dtrace/test/tst/common/pointers/tst.assigncast2.d b/usr/src/cmd/dtrace/test/tst/common/pointers/tst.assigncast2.d
new file mode 100644
index 0000000000..6282e7ae15
--- /dev/null
+++ b/usr/src/cmd/dtrace/test/tst/common/pointers/tst.assigncast2.d
@@ -0,0 +1,29 @@
+/*
+ * CDDL HEADER START
+ *
+ * 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.
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 2012 by Delphix. All rights reserved.
+ */
+
+BEGIN
+{
+ this->a = alloca(4);
+ *((int *)this->a) = 1;
+}
+
+BEGIN
+{
+ exit(0);
+}
diff --git a/usr/src/cmd/dtrace/test/tst/common/pragma/tst.temporal.ksh b/usr/src/cmd/dtrace/test/tst/common/pragma/tst.temporal.ksh
new file mode 100644
index 0000000000..9a0aed0678
--- /dev/null
+++ b/usr/src/cmd/dtrace/test/tst/common/pragma/tst.temporal.ksh
@@ -0,0 +1,106 @@
+#!/bin/ksh -p
+#
+# CDDL HEADER START
+#
+# 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.
+#
+# CDDL HEADER END
+#
+
+#
+# Copyright (c) 2012 by Delphix. All rights reserved.
+#
+
+############################################################################
+# ASSERTION:
+# temporal option causes output to be sorted
+#
+# SECTION: Pragma
+#
+# NOTES: The temporal option has no effect on a single-CPU system, so
+# this needs to be run on a multi-CPU system to effectively test the
+# temporal option.
+#
+############################################################################
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+file=/tmp/out.$$
+
+rm -f $file
+
+$dtrace -o $file -c 'sleep 3' -s /dev/stdin <<EOF
+ #pragma D option quiet
+ #pragma D option temporal
+
+ BEGIN
+ {
+ @lines = count();
+ printf("0 begin\n");
+ }
+
+ END
+ {
+ /* Bump @lines every time we print a line. */
+ @lines = count();
+ printf("%u end\n", timestamp);
+ @lines = count();
+ printa("99999999999999999 lines %@u\n", @lines);
+ }
+
+ profile-97hz
+ {
+ @lines = count();
+ printf("%u\n", timestamp);
+ }
+EOF
+
+status=$?
+if [ "$status" -ne 0 ]; then
+ echo $tst: dtrace failed
+ exit $status
+fi
+
+# dtrace outputs a blank line at the end, which will sort to the beginning,
+# so use head to remove the blank line.
+head -n -1 $file > $file.2
+
+sort -n $file.2 | diff $file.2 -
+status=$?
+if [ "$status" -ne 0 ]; then
+ echo $tst: output is not sorted
+ exit $status
+fi
+
+head -n 1 $file.2 | grep begin >/dev/null
+status=$?
+if [ "$status" -ne 0 ]; then
+ echo $tst: begin probe did not fire
+ exit $status
+fi
+
+tail -n 2 $file.2 | grep end >/dev/null
+status=$?
+if [ "$status" -ne 0 ]; then
+ echo $tst: end probe did not fire
+ exit $status
+fi
+
+if [ $(tail -n 1 $file.2 | cut -f3 -d ' ') -ne \
+ $(wc -l $file.2) ]; then
+ echo $tst: incorrect number of lines output
+ exit 1
+fi
+
+exit $status
diff --git a/usr/src/cmd/dtrace/test/tst/common/pragma/tst.temporal2.ksh b/usr/src/cmd/dtrace/test/tst/common/pragma/tst.temporal2.ksh
new file mode 100644
index 0000000000..4e8d592d81
--- /dev/null
+++ b/usr/src/cmd/dtrace/test/tst/common/pragma/tst.temporal2.ksh
@@ -0,0 +1,102 @@
+#!/bin/ksh -p
+#
+# CDDL HEADER START
+#
+# 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.
+#
+# CDDL HEADER END
+#
+
+#
+# Copyright (c) 2012 by Delphix. All rights reserved.
+#
+
+############################################################################
+# ASSERTION:
+# temporal option causes output to be sorted, even when some
+# buffers are empty
+#
+# SECTION: Pragma
+#
+# NOTES: The temporal option has no effect on a single-CPU system, so
+# this needs to be run on a multi-CPU system to effectively test the
+# temporal option.
+#
+############################################################################
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+file=/tmp/out.$$
+
+rm -f $file
+
+$dtrace -o $file -s /dev/stdin <<EOF
+ #pragma D option quiet
+ #pragma D option destructive
+ #pragma D option temporal
+ #pragma D option switchrate=1000hz
+
+ /*
+ * Use two enablings of the same probe, so that cpu 0 will always
+ * record its data just a little bit before the other cpus.
+ * We don't want to use the chill() action in the same enabling
+ * that we record the timestamp, because chill() causes the
+ * timestamp to be re-read, and thus not match the timestamp
+ * which libdtrace uses to sort the records.
+ */
+
+ profile-401
+ /cpu == 0/
+ {
+ printf("%d\n", timestamp);
+ }
+
+ profile-401
+ /cpu != 0/
+ {
+ chill(1000); /* one microsecond */
+ }
+
+ profile-401
+ /cpu != 0/
+ {
+ printf("%d\n", timestamp);
+ }
+
+ tick-1s
+ /k++ == 10/
+ {
+ printf("%d\n", timestamp);
+ exit(0);
+ }
+EOF
+
+status=$?
+if [ "$status" -ne 0 ]; then
+ echo $tst: dtrace failed
+ exit $status
+fi
+
+# dtrace outputs a blank line at the end, which will sort to the beginning,
+# so use grep to remove the blank line.
+head -n -1 $file > $file.2
+
+sort -n $file.2 | diff $file.2 -
+status=$?
+if [ "$status" -ne 0 ]; then
+ echo $tst: output is not sorted
+ exit $status
+fi
+
+exit $status
diff --git a/usr/src/cmd/dtrace/test/tst/common/pragma/tst.temporal3.d b/usr/src/cmd/dtrace/test/tst/common/pragma/tst.temporal3.d
new file mode 100644
index 0000000000..b4c0e557be
--- /dev/null
+++ b/usr/src/cmd/dtrace/test/tst/common/pragma/tst.temporal3.d
@@ -0,0 +1,48 @@
+/*
+ * CDDL HEADER START
+ *
+ * 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.
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 2012 by Delphix. All rights reserved.
+ */
+
+/*
+ * This test excercises the "remnant" handling of the temporal option.
+ * At the end of one pass of retrieving and printing data from all CPUs,
+ * some unprocessed data will remain, because its timestamp is after the
+ * time covered by all CPUs' buffers. This unprocessed data is
+ * rearranged in a more space-efficient manner. If this is done
+ * incorrectly, an alignment error may occur. To test this, we use a
+ * high-frequency probe so that data will be recorded in subsequent
+ * CPU's buffers after the first CPU's buffer is obtained. The
+ * combination of data traced here (a 8-byte value and a 4-byte value)
+ * is effective to cause alignment problems with an incorrect
+ * implementation.
+ *
+ * This test needs to be run on a multi-CPU system to be effective.
+ */
+
+#pragma D option quiet
+#pragma D option temporal
+
+profile-4997
+{
+ printf("%u %u", 1ULL, 2);
+}
+
+tick-1
+/i++ == 10/
+{
+ exit(0);
+}
diff --git a/usr/src/cmd/dtrace/test/tst/common/predicates/tst.predcache.ksh b/usr/src/cmd/dtrace/test/tst/common/predicates/tst.predcache.ksh
deleted file mode 100644
index f06edcb5a4..0000000000
--- a/usr/src/cmd/dtrace/test/tst/common/predicates/tst.predcache.ksh
+++ /dev/null
@@ -1,197 +0,0 @@
-#
-# CDDL HEADER START
-#
-# The contents of this file are subject to the terms of the
-# Common Development and Distribution License (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 2007 Sun Microsystems, Inc. All rights reserved.
-# Use is subject to license terms.
-#
-# ident "%Z%%M% %I% %E% SMI"
-
-unload()
-{
- #
- # Get the list of services whose processes have USDT probes. Ideally
- # it would be possible to unload the fasttrap provider while USDT
- # probes exist -- once that fix is integrated, this hack can go away
- # We create two lists -- one of regular SMF services and one of legacy
- # services -- since each must be enabled and disabled using a specific
- # mechanism.
- #
- pids=$(dtrace -l | \
- perl -ne 'print "$1\n" if (/^\s*\S+\s+\S*\D(\d+)\s+/);' | \
- sort | uniq | tr '\n' ',')
-
- ctids=$(ps -p $pids -o ctid | tail +2 | sort | uniq)
- svcs=
- lrcs=
-
- for ct in $ctids
- do
- line=$(svcs -o fmri,ctid | grep " $ct\$")
- svc=$(echo $line | cut -d' ' -f1)
-
- if [[ $(svcs -Ho STA $svc) == "LRC" ]]; then
- lrc=$(svcs -Ho SVC $svc | tr _ '?')
- lrcs="$lrcs $lrc"
- else
- svcs="$svcs $svc"
- fi
- done
-
- for svc in $svcs
- do
- svcadm disable -ts $svc
- done
-
- for lrc in $lrcs
- do
- #
- # Does it seem a little paternalistic that lsvcrun requires
- # this environment variable to be set? I'd say so...
- #
- SMF_RESTARTER=svc:/system/svc/restarter:default \
- /lib/svc/bin/lsvcrun $lrc stop
- done
-
- modunload -i 0
- modunload -i 0
- modunload -i 0
- modinfo | grep dtrace
- success=$?
-
- for svc in $svcs
- do
- svcadm enable -ts $svc
- done
-
- for lrc in $lrcs
- do
- SMF_RESTARTER=svc:/system/svc/restarter:default \
- /lib/svc/bin/lsvcrun $lrc start
- done
-
- if [ ! $success ]; then
- echo $tst: could not unload dtrace
- exit 1
- fi
-}
-
-script1()
-{
- $dtrace -s /dev/stdin <<EOF
- syscall:::entry
- /pid != $ppid/
- {
- @a[probefunc] = count();
- }
-
- tick-1sec
- /i++ == 5/
- {
- exit(0);
- }
-EOF
-}
-
-script2()
-{
- $dtrace -s /dev/stdin <<EOF
-
- #pragma D option statusrate=1ms
-
- syscall:::entry
- /pid == $ppid/
- {
- ttl++;
- }
-
- tick-1sec
- /i++ == 5/
- {
- exit(2);
- }
-
- END
- /ttl/
- {
- printf("success; ttl is %d", ttl);
- exit(0);
- }
-
- END
- /ttl == 0/
- {
- printf("error -- total should be non-zero");
- exit(1);
- }
-EOF
-}
-
-if [ $# != 1 ]; then
- echo expected one argument: '<'dtrace-path'>'
- exit 2
-fi
-
-ppid=$$
-dtrace=$1
-
-unload
-script1 &
-child=$!
-
-let waited=0
-
-while [ "$waited" -lt 5 ]; do
- seconds=`date +%S`
-
- if [ "$seconds" -ne "$last" ]; then
- last=$seconds
- let waited=waited+1
- fi
-done
-
-wait $child
-status=$?
-
-if [ "$status" -ne 0 ]; then
- echo $tst: first dtrace failed
- exit $status
-fi
-
-unload
-script2 &
-child=$!
-
-let waited=0
-
-while [ "$waited" -lt 10 ]; do
- seconds=`date +%S`
-
- if [ "$seconds" -ne "$last" ]; then
- last=$seconds
- let waited=waited+1
- fi
-done
-
-wait $child
-status=$?
-
-exit $status
diff --git a/usr/src/cmd/dtrace/test/tst/common/print/tst.dyn.d b/usr/src/cmd/dtrace/test/tst/common/print/tst.dyn.d
new file mode 100644
index 0000000000..f17551facb
--- /dev/null
+++ b/usr/src/cmd/dtrace/test/tst/common/print/tst.dyn.d
@@ -0,0 +1,28 @@
+/*
+ * CDDL HEADER START
+ *
+ * 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.
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 2012 by Delphix. All rights reserved.
+ */
+
+BEGIN
+{
+ print(*curpsinfo);
+}
+
+BEGIN
+{
+ exit(0);
+}
diff --git a/usr/src/cmd/dtrace/test/tst/common/print/tst.xlate.d b/usr/src/cmd/dtrace/test/tst/common/print/tst.xlate.d
new file mode 100644
index 0000000000..e8125d4f5c
--- /dev/null
+++ b/usr/src/cmd/dtrace/test/tst/common/print/tst.xlate.d
@@ -0,0 +1,42 @@
+/*
+ * CDDL HEADER START
+ *
+ * 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.
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 2012 by Delphix. All rights reserved.
+ */
+
+#pragma D option quiet
+
+typedef struct pancakes {
+ int i;
+ string s;
+ timespec_t t;
+} pancakes_t;
+
+translator pancakes_t < void *V > {
+ i = 2 * 10;
+ s = strjoin("I like ", "pancakes");
+ t = *(timespec_t *)`dtrace_zero;
+};
+
+BEGIN
+{
+ print(*(xlate < pancakes_t * > ((void *)NULL)));
+}
+
+BEGIN
+{
+ exit(0);
+}
diff --git a/usr/src/cmd/dtrace/test/tst/common/print/tst.xlate.d.out b/usr/src/cmd/dtrace/test/tst/common/print/tst.xlate.d.out
new file mode 100644
index 0000000000..9b01402af3
--- /dev/null
+++ b/usr/src/cmd/dtrace/test/tst/common/print/tst.xlate.d.out
@@ -0,0 +1,8 @@
+pancakes_t {
+ int i = 0x14
+ string s = [ "I like pancakes" ]
+ timespec_t t = {
+ time_t tv_sec = 0
+ long tv_nsec = 0
+ }
+}
diff --git a/usr/src/cmd/dtrace/test/tst/common/printf/tst.ints.d.out b/usr/src/cmd/dtrace/test/tst/common/printf/tst.ints.d.out
index 4d2bb11207..bc7eaed0ec 100644
--- a/usr/src/cmd/dtrace/test/tst/common/printf/tst.ints.d.out
+++ b/usr/src/cmd/dtrace/test/tst/common/printf/tst.ints.d.out
@@ -1,6 +1,6 @@
-239
-52719
+-17
+-12817
-1867788817
1311768467294899695
diff --git a/usr/src/cmd/dtrace/test/tst/common/printf/tst.signs.d b/usr/src/cmd/dtrace/test/tst/common/printf/tst.signs.d
new file mode 100644
index 0000000000..64e565e267
--- /dev/null
+++ b/usr/src/cmd/dtrace/test/tst/common/printf/tst.signs.d
@@ -0,0 +1,38 @@
+/*
+ * CDDL HEADER START
+ *
+ * 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.
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 2012 by Delphix. All rights reserved.
+ */
+
+/*
+ * Check %d v. %i v. %u.
+ */
+
+#pragma D option quiet
+
+uint16_t x;
+int16_t y;
+
+BEGIN
+{
+ x = 0xffffffff;
+ y = 0xffffffff;
+
+ printf("%d %i %u\n", x, x, x);
+ printf("%d %i %u\n", y, y, y);
+
+ exit(0);
+}
diff --git a/usr/src/cmd/dtrace/test/tst/common/printf/tst.signs.d.out b/usr/src/cmd/dtrace/test/tst/common/printf/tst.signs.d.out
new file mode 100644
index 0000000000..169ac59b95
--- /dev/null
+++ b/usr/src/cmd/dtrace/test/tst/common/printf/tst.signs.d.out
@@ -0,0 +1,3 @@
+65535 -1 65535
+-1 -1 65535
+
diff --git a/usr/src/cmd/dtrace/test/tst/common/speculation/err.BufSizeVariations1.d b/usr/src/cmd/dtrace/test/tst/common/speculation/err.BufSizeVariations1.d
index e97506e110..c59ea3bee5 100644
--- a/usr/src/cmd/dtrace/test/tst/common/speculation/err.BufSizeVariations1.d
+++ b/usr/src/cmd/dtrace/test/tst/common/speculation/err.BufSizeVariations1.d
@@ -24,7 +24,10 @@
* Use is subject to license terms.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
+/*
+ * Copyright (c) 2012 by Delphix. All rights reserved.
+ */
+
/*
* ASSERTION:
@@ -35,17 +38,10 @@
*
* NOTES: This test behaves differently depending on the values
* assigned to bufsize.
- * 1. 0 > bufsize.
- * 2. 0 == bufsize.
- * 3. 0 < bufsize <= 7
- * 4. 8 <= bufsize <= 31
- * 5. 32 <= bufsize <= 47
- * 6. 48 <= bufsize <= 71
- * 7. 72 <= bufsize
*/
#pragma D option quiet
-#pragma D option bufsize=41
+#pragma D option bufsize=49
BEGIN
{
diff --git a/usr/src/cmd/dtrace/test/tst/common/speculation/tst.SpecSizeVariations3.d b/usr/src/cmd/dtrace/test/tst/common/speculation/tst.SpecSizeVariations3.d
index 6b91efd911..99539f903e 100644
--- a/usr/src/cmd/dtrace/test/tst/common/speculation/tst.SpecSizeVariations3.d
+++ b/usr/src/cmd/dtrace/test/tst/common/speculation/tst.SpecSizeVariations3.d
@@ -24,7 +24,10 @@
* Use is subject to license terms.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
+/*
+ * Copyright (c) 2012 by Delphix. All rights reserved.
+ */
+
/*
* ASSERTION:
* Verify the behavior of speculations with changes in specsize.
@@ -35,7 +38,7 @@
*/
#pragma D option quiet
-#pragma D option specsize=40
+#pragma D option specsize=48
BEGIN
{
diff --git a/usr/src/cmd/dtrace/test/tst/common/trace/err.D_TRACE_DYN.bad.d b/usr/src/cmd/dtrace/test/tst/common/trace/err.D_TRACE_DYN.bad.d
deleted file mode 100644
index 8436df6735..0000000000
--- a/usr/src/cmd/dtrace/test/tst/common/trace/err.D_TRACE_DYN.bad.d
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License (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) 2011 by Delphix. All rights reserved.
- */
-
-BEGIN
-{
- trace(*curpsinfo);
-}
diff --git a/usr/src/cmd/dtrace/test/tst/common/trace/tst.dyn.d b/usr/src/cmd/dtrace/test/tst/common/trace/tst.dyn.d
new file mode 100644
index 0000000000..24ad80fb46
--- /dev/null
+++ b/usr/src/cmd/dtrace/test/tst/common/trace/tst.dyn.d
@@ -0,0 +1,28 @@
+/*
+ * CDDL HEADER START
+ *
+ * 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.
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 2012 by Delphix. All rights reserved.
+ */
+
+BEGIN
+{
+ trace(*curpsinfo);
+}
+
+BEGIN
+{
+ exit(0);
+}
diff --git a/usr/src/cmd/dtrace/test/tst/common/translators/man.TestTransStability.d b/usr/src/cmd/dtrace/test/tst/common/translators/man.TestTransStability.d
deleted file mode 100644
index c664188f13..0000000000
--- a/usr/src/cmd/dtrace/test/tst/common/translators/man.TestTransStability.d
+++ /dev/null
@@ -1,61 +0,0 @@
-/*
- * CDDL HEADER START
- *
- * The contents of this file are subject to the terms of the
- * Common Development and Distribution License (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 2006 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*
- * ASSERTION:
- * The D inline translation mechanism can be used to facilitate stable
- * translations.
- *
- * SECTION: Translators/ Translator Declarations
- * SECTION: Translators/ Translate Operator
- * SECTION: Translators/Stable Translations
- *
- * NOTES: Uncomment the pragma that explicitly resets the attributes of
- * myinfo identifier to Stable/Stable/Common from Private/Private/Unknown.
- * Run the program with and without the comments as:
- * /usr/sbin/dtrace -vs man.TestTransStability.d
- */
-
-#pragma D option quiet
-
-inline lwpsinfo_t *myinfo = xlate < lwpsinfo_t *> (curthread);
-
-/*
-#pragma D attributes Stable/Stable/Common myinfo
-*/
-
-BEGIN
-{
- trace(myinfo->pr_flag);
- exit(0);
-}
-
-ERROR
-{
- exit(1);
-}
diff --git a/usr/src/cmd/dtrace/test/tst/common/translators/tst.TestTransStability1.ksh b/usr/src/cmd/dtrace/test/tst/common/translators/tst.TestTransStability1.ksh
new file mode 100644
index 0000000000..16eeda3291
--- /dev/null
+++ b/usr/src/cmd/dtrace/test/tst/common/translators/tst.TestTransStability1.ksh
@@ -0,0 +1,62 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+#
+# Copyright (c) 2012 by Delphix. All rights reserved.
+#
+
+#
+# Test the output for stable translations.
+#
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+$dtrace -v -s /dev/stdin <<EOF
+
+#pragma D option quiet
+
+inline lwpsinfo_t *myinfo = xlate < lwpsinfo_t *> (curthread);
+
+#pragma D attributes Stable/Stable/Common myinfo
+
+BEGIN
+{
+ this->a = myinfo->pr_flag;
+ exit(0);
+}
+
+BEGIN
+{
+ exit(1);
+}
+EOF
+
+exit $?
diff --git a/usr/src/cmd/dtrace/test/tst/common/translators/tst.TestTransStability1.ksh.out b/usr/src/cmd/dtrace/test/tst/common/translators/tst.TestTransStability1.ksh.out
new file mode 100644
index 0000000000..43c1adb1a5
--- /dev/null
+++ b/usr/src/cmd/dtrace/test/tst/common/translators/tst.TestTransStability1.ksh.out
@@ -0,0 +1,14 @@
+
+Stability attributes for script /dev/stdin:
+
+ Minimum Probe Description Attributes
+ Identifier Names: Unstable
+ Data Semantics: Unstable
+ Dependency Class: Common
+
+ Minimum Statement Attributes
+ Identifier Names: Stable
+ Data Semantics: Stable
+ Dependency Class: Common
+
+
diff --git a/usr/src/cmd/dtrace/test/tst/common/translators/tst.TestTransStability2.ksh b/usr/src/cmd/dtrace/test/tst/common/translators/tst.TestTransStability2.ksh
new file mode 100644
index 0000000000..82070cde92
--- /dev/null
+++ b/usr/src/cmd/dtrace/test/tst/common/translators/tst.TestTransStability2.ksh
@@ -0,0 +1,60 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (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 2006 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+#
+# Copyright (c) 2012 by Delphix. All rights reserved.
+#
+
+#
+# Test the output of unstable translations.
+#
+
+if [ $# != 1 ]; then
+ echo expected one argument: '<'dtrace-path'>'
+ exit 2
+fi
+
+dtrace=$1
+
+$dtrace -v -s /dev/stdin <<EOF
+
+#pragma D option quiet
+
+inline lwpsinfo_t *myinfo = xlate < lwpsinfo_t *> (curthread);
+
+BEGIN
+{
+ this->a = myinfo->pr_flag;
+ exit(0);
+}
+
+BEGIN
+{
+ exit(1);
+}
+EOF
+
+exit $?
diff --git a/usr/src/cmd/dtrace/test/tst/common/translators/tst.TestTransStability2.ksh.out b/usr/src/cmd/dtrace/test/tst/common/translators/tst.TestTransStability2.ksh.out
new file mode 100644
index 0000000000..f4b70f9573
--- /dev/null
+++ b/usr/src/cmd/dtrace/test/tst/common/translators/tst.TestTransStability2.ksh.out
@@ -0,0 +1,14 @@
+
+Stability attributes for script /dev/stdin:
+
+ Minimum Probe Description Attributes
+ Identifier Names: Unstable
+ Data Semantics: Unstable
+ Dependency Class: Common
+
+ Minimum Statement Attributes
+ Identifier Names: Private
+ Data Semantics: Private
+ Dependency Class: Unknown
+
+
diff --git a/usr/src/cmd/file/magic b/usr/src/cmd/file/magic
index bf73432cbf..f6e945b8c3 100644
--- a/usr/src/cmd/file/magic
+++ b/usr/src/cmd/file/magic
@@ -617,3 +617,5 @@
>8 string jpx JPEG 2000 w/ extensions (.JPX) [ISO 15444-2]
>8 string mp42 v2 [ISO 14496-14]
4 string moov QuickTime MOV file
+
+0 string \375\067\172\130\132\000 xz compressed data
diff --git a/usr/src/cmd/format/menu_command.c b/usr/src/cmd/format/menu_command.c
index 29f95af78b..6c77b086cf 100644
--- a/usr/src/cmd/format/menu_command.c
+++ b/usr/src/cmd/format/menu_command.c
@@ -1563,20 +1563,24 @@ c_label()
fmt_print("[1] EFI Label\n");
ioparam.io_bounds.lower = 0;
ioparam.io_bounds.upper = 1;
- if (cur_label == L_TYPE_SOLARIS)
- deflt = 0;
+ if ((cur_label == L_TYPE_SOLARIS) &&
+ (cur_disk->fdisk_part.systid != EFI_PMBR))
+ deflt = L_TYPE_SOLARIS;
else
- deflt = 1;
+ deflt = L_TYPE_EFI;
defltptr = &deflt;
choice = input(FIO_INT, "Specify Label type", ':',
&ioparam, defltptr, DATA_INPUT);
- if ((choice == 0) && (cur_label == L_TYPE_SOLARIS)) {
+ if ((choice == L_TYPE_SOLARIS) &&
+ (cur_label == L_TYPE_SOLARIS) &&
+ (cur_disk->fdisk_part.systid != EFI_PMBR)) {
goto expert_end;
- } else if ((choice == 1) && (cur_label == L_TYPE_EFI)) {
+ } else if ((choice == L_TYPE_EFI) &&
+ (cur_label == L_TYPE_EFI)) {
goto expert_end;
}
switch (choice) {
- case 0:
+ case L_TYPE_SOLARIS:
/*
* EFI label to SMI label
*/
@@ -1648,17 +1652,19 @@ c_label()
}
- case 1:
+ case L_TYPE_EFI:
/*
* SMI label to EFI label
*/
-
- fmt_print("Warning: This disk has an SMI label. Changing to "
- "EFI label will erase all\ncurrent partitions.\n");
-
- if (check("Continue")) {
- return (-1);
+ if ((cur_disk->fdisk_part.systid == SUNIXOS) ||
+ (cur_disk->fdisk_part.systid == SUNIXOS2)) {
+ fmt_print("Warning: This disk has an SMI label. "
+ "Changing to EFI label will erase all\ncurrent "
+ "partitions.\n");
+ if (check("Continue")) {
+ return (-1);
+ }
}
if (get_disk_info(cur_file, &efinfo) != 0) {
diff --git a/usr/src/cmd/fs.d/hsfs/fstyp/fstyp.c b/usr/src/cmd/fs.d/hsfs/fstyp/fstyp.c
index c49f74fa25..c1f400f86b 100644
--- a/usr/src/cmd/fs.d/hsfs/fstyp/fstyp.c
+++ b/usr/src/cmd/fs.d/hsfs/fstyp/fstyp.c
@@ -23,8 +23,6 @@
* Use is subject to license terms.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
/*
* libfstyp module for hsfs
*/
@@ -42,9 +40,9 @@
#include <sys/dkio.h>
#include <libnvpair.h>
#include <libfstyp_module.h>
-#include "hsfs_spec.h"
-#include "iso_spec.h"
-#include "iso_impl.h"
+
+#include <sys/fs/hsfs_spec.h>
+#include <sys/fs/hsfs_isospec.h>
typedef struct fstyp_hsfs {
int fd;
diff --git a/usr/src/cmd/fs.d/hsfs/fstyp/hsfs_spec.h b/usr/src/cmd/fs.d/hsfs/fstyp/hsfs_spec.h
deleted file mode 100644
index 0ae3042996..0000000000
--- a/usr/src/cmd/fs.d/hsfs/fstyp/hsfs_spec.h
+++ /dev/null
@@ -1,268 +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
- */
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*
- * High Sierra filesystem specification
- * Copyright (c) 1989 by Sun Microsystem, Inc.
- */
-
-#ifndef _HSFS_SPEC_H_
-#define _HSFS_SPEC_H_
-
-#include <sys/isa_defs.h> /* for ENDIAN defines */
-
-/* routines required for date parsing */
-extern void hs_parse_dirdate(); /* parse date in directory */
-extern void hs_parse_longdate(); /* parse date in volume id */
-
-/* macros to parse binary integers */
-#define ZERO(x) (u_int) (((u_char *)(x))[0])
-#define ONE(x) (u_int) (((u_char *)(x))[1])
-#define TWO(x) (u_int) (((u_char *)(x))[2])
-#define THREE(x) (u_int) (((u_char *)(x))[3])
-
-#define MSB_INT(x) \
- ((((((ZERO(x) << 8) | ONE(x)) << 8) | TWO(x)) << 8) | THREE(x))
-#define LSB_INT(x) \
- ((((((THREE(x) << 8) | TWO(x)) << 8) | ONE(x)) << 8) | ZERO(x))
-#define MSB_SHORT(x) ((ZERO(x) << 8) | ONE(x))
-#define LSB_SHORT(x) ((ONE(x) << 8) | ZERO(x))
-
-#if defined(_LITTLE_ENDIAN)
-#define BOTH_SHORT(x) (short) *((short *)x)
-#define BOTH_INT(x) (int) *((int *)x)
-#endif
-
-/*
- * The following describes actual on-disk structures.
- * To achieve portability, all structures are #defines
- * rather than a structure definition. Macros are provided
- * to get either the data or address of individual fields.
- */
-
-/* Overall High Sierra disk structure */
-#define HS_SECTOR_SIZE 2048 /* bytes per logical sector */
-#define HS_SECTOR_SHIFT 11 /* sector<->byte shift count */
-#define HS_SEC_PER_PAGE (PAGESIZE/HS_SECTOR_SIZE) /* sectors per page */
-#define HS_SYSAREA_SEC 0 /* 1st sector of system area */
-#define HS_VOLDESC_SEC 16 /* 1st sector of volume descriptors */
-#define MAXHSOFFSET (HS_SECTOR_SIZE - 1)
-#define MAXHSMASK (~MAXHSOFFSET)
-
-/* Standard File Structure Volume Descriptor */
-
-enum hs_voldesc_type {
- VD_BOOT=0, VD_SFS=1, VD_CCFS=2, VD_UNSPEC=3, VD_EOV=255
-};
-#define HSV_ID_STRING "CDROM" /* HSV_std_id field */
-#define HSV_ID_STRLEN 5 /* HSV_std_id field length */
-#define HSV_ID_VER 1 /* HSV_std_ver field */
-#define HSV_FILE_STRUCT_ID_VER 1 /* HSV_file_struct_ver field */
-#define HSV_SYS_ID_STRLEN 32 /* HSV_sys_id field length */
-#define HSV_VOL_ID_STRLEN 32 /* HSV_vol_id field length */
-#define HSV_VOL_SET_ID_STRLEN 128 /* HSV_vol_set_id field length */
-#define HSV_PUB_ID_STRLEN 128 /* HSV_pub_id field length */
-#define HSV_PREP_ID_STRLEN 128 /* HSV_prep_id field length */
-#define HSV_APPL_ID_STRLEN 128 /* HSV_appl_id field length */
-#define HSV_COPYR_ID_STRLEN 32 /* HSV_copyr_id field length */
-#define HSV_ABSTR_ID_STRLEN 32 /* HSV_abstr_id field length */
-#define HSV_DATE_LEN 16 /* HSV date filed length */
-
-/* macros to get the address of each field */
-#define HSV_desc_lbn(x) (&((u_char *)x)[0])
-#define HSV_desc_type(x) (&((u_char *)x)[8])
-#define HSV_std_id(x) (&((u_char *)x)[9])
-#define HSV_std_ver(x) (&((u_char *)x)[14])
-#define HSV_sys_id(x) (&((u_char *)x)[16])
-#define HSV_vol_id(x) (&((u_char *)x)[48])
-#define HSV_vol_size(x) (&((u_char *)x)[88])
-#define HSV_set_size(x) (&((u_char *)x)[128])
-#define HSV_set_seq(x) (&((u_char *)x)[132])
-#define HSV_blk_size(x) (&((u_char *)x)[136])
-#define HSV_ptbl_size(x) (&((u_char *)x)[140])
-#define HSV_ptbl_man_ls(x) (&((u_char *)x)[148])
-#define HSV_ptbl_opt_ls1(x) (&((u_char *)x)[152])
-#define HSV_ptbl_opt_ls2(x) (&((u_char *)x)[156])
-#define HSV_ptbl_opt_ls3(x) (&((u_char *)x)[160])
-#define HSV_ptbl_man_ms(x) (&((u_char *)x)[164])
-#define HSV_ptbl_opt_ms1(x) (&((u_char *)x)[168])
-#define HSV_ptbl_opt_ms2(x) (&((u_char *)x)[172])
-#define HSV_ptbl_opt_ms3(x) (&((u_char *)x)[176])
-#define HSV_root_dir(x) (&((u_char *)x)[180])
-#define HSV_vol_set_id(x) (&((u_char *)x)[214])
-#define HSV_pub_id(x) (&((u_char *)x)[342])
-#define HSV_prep_id(x) (&((u_char *)x)[470])
-#define HSV_appl_id(x) (&((u_char *)x)[598])
-#define HSV_copyr_id(x) (&((u_char *)x)[726])
-#define HSV_abstr_id(x) (&((u_char *)x)[758])
-#define HSV_cre_date(x) (&((u_char *)x)[790])
-#define HSV_mod_date(x) (&((u_char *)x)[806])
-#define HSV_exp_date(x) (&((u_char *)x)[822])
-#define HSV_eff_date(x) (&((u_char *)x)[838])
-#define HSV_file_struct_ver(x) (&((u_char *)x)[854])
-
-/* macros to get the values of each field (strings are returned as ptrs) */
-#define HSV_DESC_LBN(x) BOTH_INT(HSV_desc_lbn(x))
-#define HSV_DESC_TYPE(x) ((enum hs_voldesc_type)*(HSV_desc_type(x)))
-#define HSV_STD_ID(x) HSV_std_id(x)
-#define HSV_STD_VER(x) *(HSV_std_ver(x))
-#define HSV_SYS_ID(x) HSV_sys_id(x)
-#define HSV_VOL_ID(x) HSV_vol_id(x)
-#define HSV_VOL_SIZE(x) BOTH_INT(HSV_vol_size(x))
-#define HSV_SET_SIZE(x) BOTH_SHORT(HSV_set_size(x))
-#define HSV_SET_SEQ(x) BOTH_SHORT(HSV_set_seq(x))
-#define HSV_BLK_SIZE(x) BOTH_SHORT(HSV_blk_size(x))
-#define HSV_PTBL_SIZE(x) BOTH_INT(HSV_ptbl_size(x))
-#define HSV_PTBL_MAN_LS(x) LSB_INT(HSV_ptbl_man_ls(x))
-#define HSV_PTBL_OPT_LS1(x) LSB_INT(HSV_ptbl_opt_ls1(x))
-#define HSV_PTBL_OPT_LS2(x) LSB_INT(HSV_ptbl_opt_ls2(x))
-#define HSV_PTBL_OPT_LS3(x) LSB_INT(HSV_ptbl_opt_ls3(x))
-#define HSV_PTBL_MAN_MS(x) MSB_INT(HSV_ptbl_man_ms(x))
-#define HSV_PTBL_OPT_MS1(x) MSB_INT(HSV_ptbl_opt_ms1(x))
-#define HSV_PTBL_OPT_MS2(x) MSB_INT(HSV_ptbl_opt_ms2(x))
-#define HSV_PTBL_OPT_MS3(x) MSB_INT(HSV_ptbl_opt_ms3(x))
-#define HSV_ROOT_DIR(x) HSV_root_dir(x)
-#define HSV_VOL_SET_ID(x) HSV_vol_set_id(x)
-#define HSV_PUB_ID(x) HSV_pub_id(x)
-#define HSV_PREP_ID(x) HSV_prep_id(x)
-#define HSV_APPL_ID(x) HSV_appl_id(x)
-#define HSV_COPYR_ID(x) HSV_copyr_id(x)
-#define HSV_ABSTR_ID(x) HSV_abstr_id(x)
-#define HSV_CRE_DATE(x) HSV_cre_date(x)
-#define HSV_MOD_DATE(x) HSV_mod_date(x)
-#define HSV_EXP_DATE(x) HSV_exp_date(x)
-#define HSV_EFF_DATE(x) HSV_eff_date(x)
-#define HSV_FILE_STRUCT_VER(x) *(HSV_file_struct_ver(x))
-
-/* Standard File Structure Volume Descriptor date fields */
-#define HSV_DATE_2DIG(x) ( (((x)[0] - '0') * 10) + \
- ((x)[1] - '0') )
-#define HSV_DATE_4DIG(x) ( (((x)[0] - '0') * 1000) + \
- (((x)[1] - '0') * 100) + \
- (((x)[2] - '0') * 10) + \
- ((x)[3] - '0') )
-#define HSV_DATE_YEAR(x) HSV_DATE_4DIG(&((u_char *)x)[0])
-#define HSV_DATE_MONTH(x) HSV_DATE_2DIG(&((u_char *)x)[4])
-#define HSV_DATE_DAY(x) HSV_DATE_2DIG(&((u_char *)x)[6])
-#define HSV_DATE_HOUR(x) HSV_DATE_2DIG(&((u_char *)x)[8])
-#define HSV_DATE_MIN(x) HSV_DATE_2DIG(&((u_char *)x)[10])
-#define HSV_DATE_SEC(x) HSV_DATE_2DIG(&((u_char *)x)[12])
-#define HSV_DATE_HSEC(x) HSV_DATE_2DIG(&((u_char *)x)[14])
-
-/* Path table enry */
-/* fix size of path table entry */
-#define HPE_FPESIZE 8
-/* macros to get the address of each field */
-#define HPE_ext_lbn(x) (&((u_char *)x)[0])
-#define HPE_xar_len(x) (&((u_char *)x)[4])
-#define HPE_name_len(x) (&((u_char *)x)[5])
-#define HPE_parent_no(x) (&((u_char *)x)[6])
-#define HPE_name(x) (&((u_char *)x)[8])
-
-/* macros to get the values of each field */
-#if sun4
-#define HPE_EXT_LBN(x) (MSB_INT(HPE_ext_lbn(x)))
-#else
-#define HPE_EXT_LBN(x) *(int *)(HPE_ext_lbn(x))
-#endif
-#define HPE_XAR_LEN(x) *(HPE_xar_len(x))
-#define HPE_NAME_LEN(x) *(HPE_name_len(x))
-#define HPE_PARENT_NO(x) *(short *)(HPE_parent_no(x))
-#define HPE_NAME(x) HPE_name(x)
-
-/* root record */
-#define HDE_ROOT_DIR_REC_SIZE 34 /* size of root directory record */
-#define HDE_FDESIZE 33 /* fixed size for hsfs directory area */
-#define HDE_FUSIZE 12 /* fixed size for unix areaa */
- /* max size of a name */
-#define HDE_MAX_NAME_LEN (255 - HDE_FDESIZE - HDE_FUSIZE)
-
-/* Directory Entry (Directory Record) */
-
-#define UNIX_TO_HDE_DATE(t,p) parse_unixdate(t, p) /* return val at p */
-
-/* macros to get the address of each field */
-#define HDE_dir_len(x) (&((u_char *)x)[0])
-#define HDE_xar_len(x) (&((u_char *)x)[1])
-#define HDE_ext_lbn(x) (&((u_char *)x)[2])
-#define HDE_ext_size(x) (&((u_char *)x)[10])
-#define HDE_cdate(x) (&((u_char *)x)[18])
-#define HDE_flags(x) (&((u_char *)x)[24])
-#define HDE_reserved(x) (&((u_char *)x)[25])
-#define HDE_intrlv_size(x) (&((u_char *)x)[26])
-#define HDE_intrlv_skip(x) (&((u_char *)x)[27])
-#define HDE_vol_set(x) (&((u_char *)x)[28])
-#define HDE_name_len(x) (&((u_char *)x)[32])
-#define HDE_name(x) (&((u_char *)x)[33])
-
-/***UNIX extension****/
-#define HDE_mode(x) (&((u_char *)x)[0])
-#define HDE_uid(x) (&((u_char *)x)[4])
-#define HDE_gid(x) (&((u_char *)x)[8])
-
-/* macros to get the values of each field (strings are returned as ptrs) */
-#define HDE_DIR_LEN(x) *(HDE_dir_len(x))
-#define HDE_XAR_LEN(x) *(HDE_xar_len(x))
-#define HDE_EXT_LBN(x) BOTH_INT(HDE_ext_lbn(x))
-#define HDE_EXT_SIZE(x) BOTH_INT(HDE_ext_size(x))
-#define HDE_CDATE(x) HDE_cdate(x)
-#define HDE_FLAGS(x) *(HDE_flags(x))
-#define HDE_RESERVED(x) *(HDE_reserved(x))
-#define HDE_INTRLV_SIZE(x) *(HDE_intrlv_size(x))
-#define HDE_INTRLV_SKIP(x) *(HDE_intrlv_skip(x))
-#define HDE_VOL_SET(x) BOTH_SHORT(HDE_vol_set(x))
-#define HDE_NAME_LEN(x) *(HDE_name_len(x))
-#define HDE_NAME(x) HDE_name(x)
-
-/***UNIX EXTENSION*****/
-#define HDE_MODE(x) *(HDE_mode(x))
-#define HDE_UID(x) *(HDE_uid(x))
-#define HDE_GID(x) *(HDE_gid(x))
-
-/* mask bits for HDE_FLAGS */
-#define HDE_EXISTENCE 0x01 /* zero if file exists */
-#define HDE_DIRECTORY 0x02 /* zero if file is not a directory */
-#define HDE_ASSOCIATED 0x04 /* zero if file is not Associated */
-#define HDE_RECORD 0x08 /* zero if no record attributes */
-#define HDE_PROTECTION 0x10 /* zero if no protection attributes */
-#define HDE_UNUSED_FLAGS 0x60
-#define HDE_LAST_EXTENT 0x80 /* zero if last extent in file */
-#define HDE_PROHIBITED (HDE_DIRECTORY | HDE_ASSOCIATED | HDE_RECORD | \
- HDE_LAST_EXTENT | HDE_UNUSED_FLAGS)
-
-/* Directory Record date fields */
-#define HDE_DATE_YEAR(x) (((u_char *)x)[0] + 1900)
-#define HDE_DATE_MONTH(x) (((u_char *)x)[1])
-#define HDE_DATE_DAY(x) (((u_char *)x)[2])
-#define HDE_DATE_HOUR(x) (((u_char *)x)[3])
-#define HDE_DATE_MIN(x) (((u_char *)x)[4])
-#define HDE_DATE_SEC(x) (((u_char *)x)[5])
-
-/* tests for Interchange Levels 1 & 2 file types */
-#define HDE_REGULAR_FILE(x) (((x) & HDE_PROHIBITED) == 0)
-#define HDE_REGULAR_DIR(x) (((x) & HDE_PROHIBITED) == HDE_DIRECTORY)
-
-#define HS_DIR_NAMELEN 31 /* max length of a directory name */
-#define HS_FILE_NAMELEN 31 /* max length of a filename */
-
-#endif /*!_HSFS_SPEC_H_*/
diff --git a/usr/src/cmd/fs.d/hsfs/fstyp/iso_impl.h b/usr/src/cmd/fs.d/hsfs/fstyp/iso_impl.h
deleted file mode 100644
index 7d2ccd2537..0000000000
--- a/usr/src/cmd/fs.d/hsfs/fstyp/iso_impl.h
+++ /dev/null
@@ -1,137 +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 2000 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-/**************************************************************************
- *
- * iso_impl.h internal macros for /usr/etc/fs/HSFS/mkproto
- *
- ***************************************************************************/
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*
- * Macros for counting and rounding.
- */
-#ifdef howmany
-#undef howmany
-#endif
-
-#if defined(sun386) || defined(i386)
-#define howmany(x, y) ((((u_int)(x))+(((u_int)(y))-1))/((u_int)(y)))
-#define roundup(x, y) ((((u_int)(x)+((u_int)(y)-1))/(u_int)(y))*(u_int)(y))
-#else
-#define howmany(x, y) (((x)+((y)-1))/(y))
-#define roundup(x, y) ((((x)+((y)-1))/(y))*(y))
-#endif
-
-extern int cdout;
-extern int set_size;
-extern int set_seq;
-extern int blk_size;
-extern int nlbn_per_sec;
-extern char u[], v[];
-extern long unix_voldesc_sec;
-extern int prototype;
-
-#define PUTSECTOR(buf, secno, nosec) (putdisk(buf, (secno)*ISO_SECTOR_SIZE, \
- (nosec)*ISO_SECTOR_SIZE))
-#define GETSECTOR(buf, secno, nosec) (getdisk(buf, (secno)*ISO_SECTOR_SIZE, \
- (nosec)*ISO_SECTOR_SIZE))
-#define PUTLBN(buf, secno, nosec) (putdisk(buf, (secno)*blk_size, \
- (nosec)*blk_size))
-#define GETLBN(buf, lbn, nolbn) (getdisk(buf, (lbn)*blk_size, \
- (nolbn)*blk_size))
-#define LBN_TO_SEC(lbn) ((lbn)/nlbn_per_sec)
-#define SEC_TO_LBN(sec) ((sec)*nlbn_per_sec)
-#define LBN_TO_BYTE(lbn) ((lbn)*blk_size)
-#define BYTE_TO_SEC(byte) (byte/ISO_SECTOR_SIZE)
-
-#define CD_UNIX 0
-#define CD_ISO 1
-
-#define CD_MSB 0
-#define CD_LSB 1
-
-#define CD_REGULAR 1
-#define CD_FILE 2
-#define CD_DIRECTORY 4
-#define CD_DOT 8
-#define CD_DOTDOT 16
-
-#define UNIX_VOLDESC_SEC ISO_VOLDESC_SEC+1
-
-/* internal data structure */
-/* unix file info - to be copied to a cd-rom image */
-struct ufname {
- int fsize; /* size of file in byte */
- char fname[1]; /* file name, should be longer */
-};
-
-/* dlist - individual element of a directory tree */
-struct dlist {
- struct dlist *dnext; /* point to next */
- struct dlist *pdp; /* point to parent */
- struct dlist *cdp; /* point to child */
- struct dlist *ucdp; /* point to first unix child */
- struct dlist *icdp; /* point to first iso child */
- struct dlist *unext; /* pointer to next in UNIX fname order */
- struct dlist *inext; /* pointer to next in ISO fname order */
- struct dlist *idirnext; /* pointer to next dir in iso, breadth first order */
- struct dlist *udirnext; /* pointer to next dir in unix, breadth first order */
- int idno; /* directory number in iso, in breadth first order */
- int udno; /* directory number in unix, in breadth first order */
- int ipoffset; /* offset in iso path table - directory only */
- int upoffset; /* offset in unix path table - directory only */
- int idlbn; /* lbn of parent in iso directory */
- int idoffset; /* offset of parent in iso directory */
- int udlbn; /* lbn of parent in unix directory */
- int udoffset; /* offset of parent in unix directory */
- int idextlbn; /* lbn of extent in iso */
- int udextlbn; /* lbn of extent in unix */
- int idsize; /* iso directory size */
- int udsize; /* unix directory size */
- int extlbn; /* location of the data */
- int fsize; /* size of the data */
- time_t mtime; /* las modification time */
- long duid; /* owner's user id */
- long dgid; /* owner's group id */
- long dmode; /* mode and type of file */
- long nlink; /* no. of links */
- struct ufname *ufnp; /* pointer to the corresponding UNIX file */
- char isofname[32]; /* iso file name */
- char unixfname[1]; /* unix file name, should be longer */
-};
-
-void update_pvd();
-void update_uvd();
-void update_pvd_ptbl();
-void update_uvd_ptbl();
-
-struct dlist * mkdlist();
-struct dlist * mkdlist_proto();
-struct dlist * mkdlist_path();
-void sortdlist();
-
-
diff --git a/usr/src/cmd/fs.d/hsfs/fstyp/iso_spec.h b/usr/src/cmd/fs.d/hsfs/fstyp/iso_spec.h
deleted file mode 100644
index 6aa72cb1b1..0000000000
--- a/usr/src/cmd/fs.d/hsfs/fstyp/iso_spec.h
+++ /dev/null
@@ -1,359 +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 2000 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*
- * ISO 9660 filesystem specification
- */
-
-#ifndef _ISO_SPEC_H_
-#define _ISO_SPEC_H_
-
-#include <sys/isa_defs.h>
-
-/* routines required for date parsing */
-extern struct timeval iso_parse_dirdate(); /* parse date in directory */
-extern struct timeval iso__parse_longdate(); /* parse date in volume id */
-
-/* macros to parse binary integers */
-#define ZERO(x) (u_int) (((u_char *)(x))[0])
-#define ONE(x) (u_int) (((u_char *)(x))[1])
-#define TWO(x) (u_int) (((u_char *)(x))[2])
-#define THREE(x) (u_int) (((u_char *)(x))[3])
-
-#define MSB_INT(x) \
- ((((((ZERO(x) << 8) | ONE(x)) << 8) | TWO(x)) << 8) | THREE(x))
-#define LSB_INT(x) \
- ((((((THREE(x) << 8) | TWO(x)) << 8) | ONE(x)) << 8) | ZERO(x))
-#define MSB_SHORT(x) ((ZERO(x) << 8) | ONE(x))
-#define LSB_SHORT(x) ((ONE(x) << 8) | ZERO(x))
-
-#if defined(sparc)
-/*
- * Sparc machines requires that integer must
- * be in a full word boundary. CD-ROM data aligns
- * to even word boundary only. Because of this mismatch,
- * we have to move integer data from CD-ROM to memory one
- * byte at a time. LSB data starts first. We therefore
- * use this to do byte by byte copying.
- */
-#define BOTH_SHORT(x) LSB_SHORT(x)
-#define BOTH_INT(x) LSB_INT(x)
-
-#elif defined(_LITTLE_ENDIAN)
-#define BOTH_SHORT(x) (short) *((short *)x)
-#define BOTH_INT(x) (int) *((int *)x)
-
-#elif defined(_BIG_ENDIAN)
-#define BOTH_SHORT(x) (short) *((short *)x + 1)
-#define BOTH_INT(x) (int) *((int *)x + 1)
-#else
-#error One of _BIG_ENDIAN and _LITTLE_ENDIAN must be defined
-#endif
-
-/*
- * conversions to/from little endian format
- */
-#if defined(_LITTLE_ENDIAN)
-/* little endian machines */
-#define ltohs(S) (S)
-#define ltohl(L) (L)
-#define htols(S) (S)
-#define htoll(L) (L)
-#else
-/* big endian machines */
-#define ltohs(S) LSB_SHORT((char *) (S))
-#define ltohl(L) LSB_INT((char *) (L))
-#define htols(S) LSB_SHORT((char *) (S))
-#define htoll(L) LSB_INT((char *) (L))
-#endif
-
-/*
- * The following describes actual on-disk structures.
- * To achieve portability, all structures are #defines
- * rather than a structure definition. Macros are provided
- * to get either the data or address of individual fields.
- */
-
-/* Overall High Sierra disk structure */
-#define ISO_SECTOR_SIZE 2048 /* bytes per logical sector */
-#define ISO_SECTOR_SHIFT 11 /* sector<->byte shift count */
-#define ISO_SEC_PER_PAGE (PAGESIZE/HS_SECTOR_SIZE) /* sectors per page */
-#define ISO_SYSAREA_SEC 0 /* 1st sector of system area */
-#define ISO_VOLDESC_SEC 16 /* 1st sector of volume descriptors */
-#define MAXISOOFFSET (ISO_SECTOR_SIZE - 1)
-#define MAXISOMASK (~MAXISOOFFSET)
-
-
-/* Standard File Structure Volume Descriptor */
-
-enum iso_voldesc_type {
- ISO_VD_BOOT=0, ISO_VD_PVD=1, ISO_VD_SVD=2, ISO_VD_VPD=3,
- ISO_VD_UNIX=4, /* UNIX extension */
- ISO_VD_EOV=255
-};
-#define ISO_ID_STRING "CD001" /* ISO_std_id field */
-#define ISO_ID_STRLEN 5 /* ISO_std_id field length */
-#define ISO_ID_VER 1 /* ISO_std_ver field */
-#define ISO_FILE_STRUCT_ID_VER 1 /* ISO_file structure version field */
-#define ISO_DATE_TO_UNIX(x) iso_parse_longdate(x) /* returns a timeval */
-#define ISO_SYS_ID_STRLEN 32
-#define ISO_VOL_ID_STRLEN 32
-#define ISO_VOL_SET_ID_STRLEN 128
-#define ISO_PUB_ID_STRLEN 128
-#define ISO_PREP_ID_STRLEN 128
-#define ISO_APPL_ID_STRLEN 128
-#define ISO_COPYR_ID_STRLEN 37
-#define ISO_ABSTR_ID_STRLEN 37
-#define ISO_DATE_LEN 17
-
-
-
-/* macros to get the address of each field */
-#define ISO_desc_type(x) (&((u_char *)x)[0])
-#define ISO_std_id(x) (&((u_char *)x)[1])
-#define ISO_std_ver(x) (&((u_char *)x)[6])
-#define ISO_sys_id(x) (&((u_char *)x)[8])
-#define ISO_vol_id(x) (&((u_char *)x)[40])
-#define ISO_vol_size(x) (&((u_char *)x)[80])
-#define ISO_set_size(x) (&((u_char *)x)[120])
-#define ISO_set_seq(x) (&((u_char *)x)[124])
-#define ISO_blk_size(x) (&((u_char *)x)[128])
-#define ISO_ptbl_size(x) (&((u_char *)x)[132])
-#define ISO_ptbl_man_ls(x) (&((u_char *)x)[140])
-#define ISO_ptbl_opt_ls1(x) (&((u_char *)x)[144])
-#define ISO_ptbl_man_ms(x) (&((u_char *)x)[148])
-#define ISO_ptbl_opt_ms1(x) (&((u_char *)x)[152])
-#define ISO_root_dir(x) (&((u_char *)x)[156])
-#define ISO_vol_set_id(x) (&((u_char *)x)[190])
-#define ISO_pub_id(x) (&((u_char *)x)[318])
-#define ISO_prep_id(x) (&((u_char *)x)[446])
-#define ISO_appl_id(x) (&((u_char *)x)[574])
-#define ISO_copyr_id(x) (&((u_char *)x)[702])
-#define ISO_abstr_id(x) (&((u_char *)x)[739])
-#define ISO_bibli_id(x) (&((u_char *)x)[776])
-#define ISO_cre_date(x) (&((u_char *)x)[813])
-#define ISO_mod_date(x) (&((u_char *)x)[830])
-#define ISO_exp_date(x) (&((u_char *)x)[847])
-#define ISO_eff_date(x) (&((u_char *)x)[864])
-#define ISO_file_struct_ver(x) (&((u_char *)x)[881])
-
-/* macros to get the values of each field (strings are returned as ptrs) */
-#define ISO_DESC_TYPE(x) ((enum hs_voldesc_type)*(ISO_desc_type(x)))
-#define ISO_STD_ID(x) ISO_std_id(x)
-#define ISO_STD_VER(x) *(ISO_std_ver(x))
-#define ISO_SYS_ID(x) ISO_sys_id(x)
-#define ISO_VOL_ID(x) ISO_vol_id(x)
-#define ISO_VOL_SIZE(x) BOTH_INT(ISO_vol_size(x))
-#define ISO_SET_SIZE(x) BOTH_SHORT(ISO_set_size(x))
-#define ISO_SET_SEQ(x) BOTH_SHORT(ISO_set_seq(x))
-#define ISO_BLK_SIZE(x) BOTH_SHORT(ISO_blk_size(x))
-#define ISO_PTBL_SIZE(x) BOTH_INT(ISO_ptbl_size(x))
-#define ISO_PTBL_MAN_LS(x) LSB_INT(ISO_ptbl_man_ls(x))
-#define ISO_PTBL_OPT_LS1(x) LSB_INT(ISO_ptbl_opt_ls1(x))
-#define ISO_PTBL_MAN_MS(x) MSB_INT(ISO_ptbl_man_ms(x))
-#define ISO_PTBL_OPT_MS1(x) MSB_INT(ISO_ptbl_opt_ms1(x))
-#define ISO_ROOT_DIR(x) ISO_root_dir(x)
-#define ISO_VOL_SET_ID(x) ISO_vol_set_id(x)
-#define ISO_PUB_ID(x) ISO_pub_id(x)
-#define ISO_PREP_ID(x) ISO_prep_id(x)
-#define ISO_APPL_ID(x) ISO_appl_id(x)
-#define ISO_COPYR_ID(x) ISO_copyr_id(x)
-#define ISO_ABSTR_ID(x) ISO_abstr_id(x)
-#define ISO_BIBLI_ID(x) ISO_bibli_id(x)
-#define ISO_CRE_DATE(x) ISO_DATE_TO_UNIX(HSV_cre_date(x))
-#define ISO_MOD_DATE(x) ISO_DATE_TO_UNIX(HSV_mod_date(x))
-#define ISO_EXP_DATE(x) ISO_DATE_TO_UNIX(HSV_exp_date(x))
-#define ISO_EFF_DATE(x) ISO_DATE_TO_UNIX(HSV_eff_date(x))
-#define ISO_FILE_STRUCT_VER(x) *(ISO_file_struct_ver(x))
-
-/* Standard File Structure Volume Descriptor date fields */
-#define ISO_DATE_2DIG(x) ( (((x)[0] - '0') * 10) + \
- ((x)[1] - '0') )
-#define ISO_DATE_4DIG(x) ( (((x)[0] - '0') * 1000) + \
- (((x)[1] - '0') * 100) + \
- (((x)[2] - '0') * 10) + \
- ((x)[3] - '0') )
-#define ISO_DATE_YEAR(x) ISO_DATE_4DIG(&((u_char *)x)[0])
-#define ISO_DATE_MONTH(x) ISO_DATE_2DIG(&((u_char *)x)[4])
-#define ISO_DATE_DAY(x) ISO_DATE_2DIG(&((u_char *)x)[6])
-#define ISO_DATE_HOUR(x) ISO_DATE_2DIG(&((u_char *)x)[8])
-#define ISO_DATE_MIN(x) ISO_DATE_2DIG(&((u_char *)x)[10])
-#define ISO_DATE_SEC(x) ISO_DATE_2DIG(&((u_char *)x)[12])
-#define ISO_DATE_HSEC(x) ISO_DATE_2DIG(&((u_char *)x)[14])
-
-
-
-/* Directory Entry (Directory Record) */
-#define IDE_ROOT_DIR_REC_SIZE 34 /* size of root directory record */
-#define IDE_FDESIZE 33 /* fixed size for hsfs directory area */
- /* max size of a name */
-#define IDE_MAX_NAME_LEN (255 - IDE_FDESIZE)
-
-
-#define IDE_DATE_TO_UNIX(x) iso_parse_dirdate(x) /* returns a timeval */
-
-/* macros to get the address of each field */
-#define IDE_dir_len(x) (&((u_char *)x)[0])
-#define IDE_xar_len(x) (&((u_char *)x)[1])
-#define IDE_ext_lbn(x) (&((u_char *)x)[2])
-#define IDE_ext_size(x) (&((u_char *)x)[10])
-#define IDE_cdate(x) (&((u_char *)x)[18])
-#define IDE_flags(x) (&((u_char *)x)[25])
-#define IDE_intrlv_size(x) (&((u_char *)x)[26])
-#define IDE_intrlv_skip(x) (&((u_char *)x)[27])
-#define IDE_vol_set(x) (&((u_char *)x)[28])
-#define IDE_name_len(x) (&((u_char *)x)[32])
-#define IDE_name(x) (&((u_char *)x)[33])
-
-/* macros to get the values of each field (strings are returned as ptrs) */
-#define IDE_DIR_LEN(x) *(IDE_dir_len(x))
-#define IDE_XAR_LEN(x) *(IDE_xar_len(x))
-#define IDE_EXT_LBN(x) BOTH_INT(IDE_ext_lbn(x))
-#define IDE_EXT_SIZE(x) BOTH_INT(IDE_ext_size(x))
-#define IDE_CDATE(x) IDE_DATE_TO_UNIX(HDE_cdate(x))
-#define IDE_FLAGS(x) *(IDE_flags(x))
-#define IDE_INTRLV_SIZE(x) *(IDE_intrlv_size(x))
-#define IDE_INTRLV_SKIP(x) *(IDE_intrlv_skip(x))
-#define IDE_VOL_SET(x) BOTH_SHORT(IDE_vol_set(x))
-#define IDE_NAME_LEN(x) *(IDE_name_len(x))
-#define IDE_NAME(x) IDE_name(x)
-
-/* mask bits for IDE_FLAGS */
-#define IDE_EXISTENCE 0x01 /* zero if file exists */
-#define IDE_DIRECTORY 0x02 /* zero if file is not a directory */
-#define IDE_ASSOCIATED 0x04 /* zero if file is not Associated */
-#define IDE_RECORD 0x08 /* zero if no record attributes */
-#define IDE_PROTECTION 0x10 /* zero if no protection attributes */
-#define IDE_UNUSED_FLAGS 0x60
-#define IDE_LAST_EXTENT 0x80 /* zero if last extent in file */
-#define IDE_PROHIBITED (IDE_DIRECTORY | HDE_ASSOCIATED | HDE_RECORD | \
- IDE_LAST_EXTENT | IDE_UNUSED_FLAGS)
-
-/* Directory Record date fields */
-#define IDE_DATE_YEAR(x) (((u_char *)x)[0] + 1900)
-#define IDE_DATE_MONTH(x) (((u_char *)x)[1])
-#define IDE_DATE_DAY(x) (((u_char *)x)[2])
-#define IDE_DATE_HOUR(x) (((u_char *)x)[3])
-#define IDE_DATE_MIN(x) (((u_char *)x)[4])
-#define IDE_DATE_SEC(x) (((u_char *)x)[5])
-
-/* tests for Interchange Levels 1 & 2 file types */
-#define IDE_REGULAR_FILE(x) (((x) & IDE_PROHIBITED) == 0)
-#define IDE_REGULAR_DIR(x) (((x) & IDE_PROHIBITED) == IDE_DIRECTORY)
-
-#define ISO_DIR_NAMELEN 31 /* max length of a directory name */
-#define ISO_FILE_NAMELEN 31 /* max length of a filename */
-
-/* Path table enry */
-/* fix size of path table entry */
-#define IPE_FPESIZE 8
-/* macros to get the address of each field */
-#define IPE_name_len(x) (&((u_char *)x)[0])
-#define IPE_xar_len(x) (&((u_char *)x)[1])
-#define IPE_ext_lbn(x) (&((u_char *)x)[2])
-#define IPE_parent_no(x) (&((u_char *)x)[6])
-#define IPE_name(x) (&((u_char *)x)[8])
-
-/* macros to get the values of each field */
-#define IPE_EXT_LBN(x) (MSB_INT(IPE_ext_lbn(x)))
-#define IPE_XAR_LEN(x) *(IPE_xar_len(x))
-#define IPE_NAME_LEN(x) *(IPE_name_len(x))
-#define IPE_PARENT_NO(x) *(short *)(IPE_parent_no(x))
-#define IPE_NAME(x) IPE_name(x)
-
-/* cdrom UNIX extension */
-/* UNIX Volume Descriptor */
-#define ISO_UNIX_ID_STRING "UNIXCD01" /* ISO_UNIX_std_id field */
-#define ISO_UNIX_ID_STRLEN 8 /* ISO_UNIX_std_id length */
-#define ISO_UNIX_FEATURE_SYMLNK 0x01 /* CD-ROM supports symbolic links */
-#define ISO_UNIX_FEATURE_LONGFN 0x02 /* CD-ROM supports long BSD file names */
-
-#define ISO_UNIX_feature(x) (&((u_char *)x)[7])
-#define ISO_UNIX_root_dir(x) (&((u_char *)x)[1395])
-#define ISO_UNIX_signature(x) (&((u_char *)x)[2040])
-
-#define ISO_UNIX_FEATURE(x) *(ISO_UNIX_feature(x))
-#define ISO_UNIX_ROOT_DIR(x) ISO_UNIX_root_dir(x)
-#define ISO_UNIX_SIGNATURE(x) ISO_UNIX_signature(x)
-
-/* UNIX extension to path table entry */
-/* fix size of path table entry */
-#define IPE_UNIX_FPESIZE 20
-
-#define IPE_UNIX_mode(x) (&((u_char *)x)[0])
-#define IPE_UNIX_uid(x) (&((u_char *)x)[4])
-#define IPE_UNIX_gid(x) (&((u_char *)x)[8])
-
-/* macros to get the values of each field */
-#define IPE_UNIX_MODE(x) (MSB_INT(IPE_UNIX_mode(x)))
-#define IPE_UNIX_UID(x) (MSB_INT(IPE_UNIX_uid(x)))
-#define IPE_UNIX_GID(x) (MSB_INT(IPE_UNIX_gid(x)))
-
-/* UNIX extension to directory entry */
-#define IDE_UNIX_SIG_UX "UX" /* UNIX extension signature */
-#define IDE_UNIX_SIG_TI "TI" /* UNIX extension signature for time */
-#define IDE_UNIX_USE_ID_VER 1 /* UNIX extension sys use id */
-#define IDE_UNIX_UX_LEN 36 /* length of UX */
-#define IDE_UNIX_TI_LEN 40 /* length of TI */
-
-#define IDE_UNIX_signature(x) (&((u_char *)x)[0])
-#define IDE_UNIX_ext_len(x) (&((u_char *)x)[2])
-#define IDE_UNIX_use_id(x) (&((u_char *)x)[3])
-#define IDE_UNIX_mode(x) (&((u_char *)x)[4])
-#define IDE_UNIX_nlink(x) (&((u_char *)x)[12])
-#define IDE_UNIX_uid(x) (&((u_char *)x)[20])
-#define IDE_UNIX_gid(x) (&((u_char *)x)[28])
-
-
-#define IDE_UNIX_cre_date(x) (&((u_char *)x)[4])
-#define IDE_UNIX_mod_date(x) (&((u_char *)x)[11])
-#define IDE_UNIX_exp_date(x) (&((u_char *)x)[18])
-#define IDE_UNIX_eff_date(x) (&((u_char *)x)[25])
-#define IDE_UNIX_acc_date(x) (&((u_char *)x)[32])
-#define IDE_UNIX_reserved(x) (&((u_char *)x)[39])
-
-#define IDE_UNIX_SIGNATURE(x) IDE_UNIX_signature(x)
-#define IDE_UNIX_EXT_LEN(x) *(IDE_UNIX_ext_len(x))
-#define IDE_UNIX_USE_ID(x) *(IDE_UNIX_use_id(x))
-#define IDE_UNIX_MODE(x) BOTH_INT(IDE_UNIX_mode(x))
-#define IDE_UNIX_NLINK(x) BOTH_INT(IDE_UNIX_nlink(x))
-#define IDE_UNIX_UID(x) BOTH_INT(IDE_UNIX_uid(x))
-#define IDE_UNIX_GID(x) BOTH_INT(IDE_UNIX_gid(x))
-
-#define IDE_UNIX_CRE_DATE(x) IDE_UNIX_cre_date(x)
-#define IDE_UNIX_MOD_DATE(x) IDE_UNIX_mod_date(x)
-#define IDE_UNIX_EXP_DATE(x) IDE_UNIX_exp_date(x)
-#define IDE_UNIX_EFF_DATE(x) IDE_UNIX_eff_date(x)
-#define IDE_UNIX_ACC_DATE(x) IDE_UNIX_acc_date(x)
-#define IDE_UNIX_RESERVED(x) *(IDE_UNIX_reserved(x))
-
-/* root record */
-/* size of root directory record */
-#define IDE_UNIX_ROOT_DIR_REC_SIZE 34+IDE_UNIX_UX_LEN
-#define IDE_UNIX_MAX_NAME_LEN IDE_MAX_NAME_LEN - IDE_UNIX_UX_LEN
-
-#endif /*!_ISO_SPEC_H_*/
diff --git a/usr/src/cmd/fs.d/hsfs/labelit/hsfs_spec.h b/usr/src/cmd/fs.d/hsfs/labelit/hsfs_spec.h
deleted file mode 100644
index 077e40ca5a..0000000000
--- a/usr/src/cmd/fs.d/hsfs/labelit/hsfs_spec.h
+++ /dev/null
@@ -1,269 +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
- */
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*
- * High Sierra filesystem specification
- * Copyright (c) 1989 by Sun Microsystem, Inc.
- */
-
-#ifndef _HSFS_SPEC_H_
-#define _HSFS_SPEC_H_
-
-#include <sys/isa_defs.h> /* for ENDIAN defines */
-
-/* routines required for date parsing */
-extern void hs_parse_dirdate(); /* parse date in directory */
-extern void hs_parse_longdate(); /* parse date in volume id */
-
-/* macros to parse binary integers */
-#define ZERO(x) (u_int) (((u_char *)(x))[0])
-#define ONE(x) (u_int) (((u_char *)(x))[1])
-#define TWO(x) (u_int) (((u_char *)(x))[2])
-#define THREE(x) (u_int) (((u_char *)(x))[3])
-
-#define MSB_INT(x) \
- ((((((ZERO(x) << 8) | ONE(x)) << 8) | TWO(x)) << 8) | THREE(x))
-#define LSB_INT(x) \
- ((((((THREE(x) << 8) | TWO(x)) << 8) | ONE(x)) << 8) | ZERO(x))
-#define MSB_SHORT(x) ((ZERO(x) << 8) | ONE(x))
-#define LSB_SHORT(x) ((ONE(x) << 8) | ZERO(x))
-
-/* for sun 3 only */
-#if defined(_LITTLE_ENDIAN)
-#define BOTH_SHORT(x) (short) *((short *)x)
-#define BOTH_INT(x) (int) *((int *)x)
-#endif
-
-/*
- * The following describes actual on-disk structures.
- * To achieve portability, all structures are #defines
- * rather than a structure definition. Macros are provided
- * to get either the data or address of individual fields.
- */
-
-/* Overall High Sierra disk structure */
-#define HS_SECTOR_SIZE 2048 /* bytes per logical sector */
-#define HS_SECTOR_SHIFT 11 /* sector<->byte shift count */
-#define HS_SEC_PER_PAGE (PAGESIZE/HS_SECTOR_SIZE) /* sectors per page */
-#define HS_SYSAREA_SEC 0 /* 1st sector of system area */
-#define HS_VOLDESC_SEC 16 /* 1st sector of volume descriptors */
-#define MAXHSOFFSET (HS_SECTOR_SIZE - 1)
-#define MAXHSMASK (~MAXHSOFFSET)
-
-/* Standard File Structure Volume Descriptor */
-
-enum hs_voldesc_type {
- VD_BOOT=0, VD_SFS=1, VD_CCFS=2, VD_UNSPEC=3, VD_EOV=255
-};
-#define HSV_ID_STRING "CDROM" /* HSV_std_id field */
-#define HSV_ID_STRLEN 5 /* HSV_std_id field length */
-#define HSV_ID_VER 1 /* HSV_std_ver field */
-#define HSV_FILE_STRUCT_ID_VER 1 /* HSV_file_struct_ver field */
-#define HSV_SYS_ID_STRLEN 32 /* HSV_sys_id field length */
-#define HSV_VOL_ID_STRLEN 32 /* HSV_vol_id field length */
-#define HSV_VOL_SET_ID_STRLEN 128 /* HSV_vol_set_id field length */
-#define HSV_PUB_ID_STRLEN 128 /* HSV_pub_id field length */
-#define HSV_PREP_ID_STRLEN 128 /* HSV_prep_id field length */
-#define HSV_APPL_ID_STRLEN 128 /* HSV_appl_id field length */
-#define HSV_COPYR_ID_STRLEN 32 /* HSV_copyr_id field length */
-#define HSV_ABSTR_ID_STRLEN 32 /* HSV_abstr_id field length */
-#define HSV_DATE_LEN 16 /* HSV date filed length */
-
-/* macros to get the address of each field */
-#define HSV_desc_lbn(x) (&((u_char *)x)[0])
-#define HSV_desc_type(x) (&((u_char *)x)[8])
-#define HSV_std_id(x) (&((u_char *)x)[9])
-#define HSV_std_ver(x) (&((u_char *)x)[14])
-#define HSV_sys_id(x) (&((u_char *)x)[16])
-#define HSV_vol_id(x) (&((u_char *)x)[48])
-#define HSV_vol_size(x) (&((u_char *)x)[88])
-#define HSV_set_size(x) (&((u_char *)x)[128])
-#define HSV_set_seq(x) (&((u_char *)x)[132])
-#define HSV_blk_size(x) (&((u_char *)x)[136])
-#define HSV_ptbl_size(x) (&((u_char *)x)[140])
-#define HSV_ptbl_man_ls(x) (&((u_char *)x)[148])
-#define HSV_ptbl_opt_ls1(x) (&((u_char *)x)[152])
-#define HSV_ptbl_opt_ls2(x) (&((u_char *)x)[156])
-#define HSV_ptbl_opt_ls3(x) (&((u_char *)x)[160])
-#define HSV_ptbl_man_ms(x) (&((u_char *)x)[164])
-#define HSV_ptbl_opt_ms1(x) (&((u_char *)x)[168])
-#define HSV_ptbl_opt_ms2(x) (&((u_char *)x)[172])
-#define HSV_ptbl_opt_ms3(x) (&((u_char *)x)[176])
-#define HSV_root_dir(x) (&((u_char *)x)[180])
-#define HSV_vol_set_id(x) (&((u_char *)x)[214])
-#define HSV_pub_id(x) (&((u_char *)x)[342])
-#define HSV_prep_id(x) (&((u_char *)x)[470])
-#define HSV_appl_id(x) (&((u_char *)x)[598])
-#define HSV_copyr_id(x) (&((u_char *)x)[726])
-#define HSV_abstr_id(x) (&((u_char *)x)[758])
-#define HSV_cre_date(x) (&((u_char *)x)[790])
-#define HSV_mod_date(x) (&((u_char *)x)[806])
-#define HSV_exp_date(x) (&((u_char *)x)[822])
-#define HSV_eff_date(x) (&((u_char *)x)[838])
-#define HSV_file_struct_ver(x) (&((u_char *)x)[854])
-
-/* macros to get the values of each field (strings are returned as ptrs) */
-#define HSV_DESC_LBN(x) BOTH_INT(HSV_desc_lbn(x))
-#define HSV_DESC_TYPE(x) ((enum hs_voldesc_type)*(HSV_desc_type(x)))
-#define HSV_STD_ID(x) HSV_std_id(x)
-#define HSV_STD_VER(x) *(HSV_std_ver(x))
-#define HSV_SYS_ID(x) HSV_sys_id(x)
-#define HSV_VOL_ID(x) HSV_vol_id(x)
-#define HSV_VOL_SIZE(x) BOTH_INT(HSV_vol_size(x))
-#define HSV_SET_SIZE(x) BOTH_SHORT(HSV_set_size(x))
-#define HSV_SET_SEQ(x) BOTH_SHORT(HSV_set_seq(x))
-#define HSV_BLK_SIZE(x) BOTH_SHORT(HSV_blk_size(x))
-#define HSV_PTBL_SIZE(x) BOTH_INT(HSV_ptbl_size(x))
-#define HSV_PTBL_MAN_LS(x) LSB_INT(HSV_ptbl_man_ls(x))
-#define HSV_PTBL_OPT_LS1(x) LSB_INT(HSV_ptbl_opt_ls1(x))
-#define HSV_PTBL_OPT_LS2(x) LSB_INT(HSV_ptbl_opt_ls2(x))
-#define HSV_PTBL_OPT_LS3(x) LSB_INT(HSV_ptbl_opt_ls3(x))
-#define HSV_PTBL_MAN_MS(x) MSB_INT(HSV_ptbl_man_ms(x))
-#define HSV_PTBL_OPT_MS1(x) MSB_INT(HSV_ptbl_opt_ms1(x))
-#define HSV_PTBL_OPT_MS2(x) MSB_INT(HSV_ptbl_opt_ms2(x))
-#define HSV_PTBL_OPT_MS3(x) MSB_INT(HSV_ptbl_opt_ms3(x))
-#define HSV_ROOT_DIR(x) HSV_root_dir(x)
-#define HSV_VOL_SET_ID(x) HSV_vol_set_id(x)
-#define HSV_PUB_ID(x) HSV_pub_id(x)
-#define HSV_PREP_ID(x) HSV_prep_id(x)
-#define HSV_APPL_ID(x) HSV_appl_id(x)
-#define HSV_COPYR_ID(x) HSV_copyr_id(x)
-#define HSV_ABSTR_ID(x) HSV_abstr_id(x)
-#define HSV_CRE_DATE(x) HSV_cre_date(x)
-#define HSV_MOD_DATE(x) HSV_mod_date(x)
-#define HSV_EXP_DATE(x) HSV_exp_date(x)
-#define HSV_EFF_DATE(x) HSV_eff_date(x)
-#define HSV_FILE_STRUCT_VER(x) *(HSV_file_struct_ver(x))
-
-/* Standard File Structure Volume Descriptor date fields */
-#define HSV_DATE_2DIG(x) ( (((x)[0] - '0') * 10) + \
- ((x)[1] - '0') )
-#define HSV_DATE_4DIG(x) ( (((x)[0] - '0') * 1000) + \
- (((x)[1] - '0') * 100) + \
- (((x)[2] - '0') * 10) + \
- ((x)[3] - '0') )
-#define HSV_DATE_YEAR(x) HSV_DATE_4DIG(&((u_char *)x)[0])
-#define HSV_DATE_MONTH(x) HSV_DATE_2DIG(&((u_char *)x)[4])
-#define HSV_DATE_DAY(x) HSV_DATE_2DIG(&((u_char *)x)[6])
-#define HSV_DATE_HOUR(x) HSV_DATE_2DIG(&((u_char *)x)[8])
-#define HSV_DATE_MIN(x) HSV_DATE_2DIG(&((u_char *)x)[10])
-#define HSV_DATE_SEC(x) HSV_DATE_2DIG(&((u_char *)x)[12])
-#define HSV_DATE_HSEC(x) HSV_DATE_2DIG(&((u_char *)x)[14])
-
-/* Path table enry */
-/* fix size of path table entry */
-#define HPE_FPESIZE 8
-/* macros to get the address of each field */
-#define HPE_ext_lbn(x) (&((u_char *)x)[0])
-#define HPE_xar_len(x) (&((u_char *)x)[4])
-#define HPE_name_len(x) (&((u_char *)x)[5])
-#define HPE_parent_no(x) (&((u_char *)x)[6])
-#define HPE_name(x) (&((u_char *)x)[8])
-
-/* macros to get the values of each field */
-#if sun4
-#define HPE_EXT_LBN(x) (MSB_INT(HPE_ext_lbn(x)))
-#else
-#define HPE_EXT_LBN(x) *(int *)(HPE_ext_lbn(x))
-#endif
-#define HPE_XAR_LEN(x) *(HPE_xar_len(x))
-#define HPE_NAME_LEN(x) *(HPE_name_len(x))
-#define HPE_PARENT_NO(x) *(short *)(HPE_parent_no(x))
-#define HPE_NAME(x) HPE_name(x)
-
-/* root record */
-#define HDE_ROOT_DIR_REC_SIZE 34 /* size of root directory record */
-#define HDE_FDESIZE 33 /* fixed size for hsfs directory area */
-#define HDE_FUSIZE 12 /* fixed size for unix areaa */
- /* max size of a name */
-#define HDE_MAX_NAME_LEN (255 - HDE_FDESIZE - HDE_FUSIZE)
-
-/* Directory Entry (Directory Record) */
-
-#define UNIX_TO_HDE_DATE(t,p) parse_unixdate(t, p) /* return val at p */
-
-/* macros to get the address of each field */
-#define HDE_dir_len(x) (&((u_char *)x)[0])
-#define HDE_xar_len(x) (&((u_char *)x)[1])
-#define HDE_ext_lbn(x) (&((u_char *)x)[2])
-#define HDE_ext_size(x) (&((u_char *)x)[10])
-#define HDE_cdate(x) (&((u_char *)x)[18])
-#define HDE_flags(x) (&((u_char *)x)[24])
-#define HDE_reserved(x) (&((u_char *)x)[25])
-#define HDE_intrlv_size(x) (&((u_char *)x)[26])
-#define HDE_intrlv_skip(x) (&((u_char *)x)[27])
-#define HDE_vol_set(x) (&((u_char *)x)[28])
-#define HDE_name_len(x) (&((u_char *)x)[32])
-#define HDE_name(x) (&((u_char *)x)[33])
-
-/***UNIX extension****/
-#define HDE_mode(x) (&((u_char *)x)[0])
-#define HDE_uid(x) (&((u_char *)x)[4])
-#define HDE_gid(x) (&((u_char *)x)[8])
-
-/* macros to get the values of each field (strings are returned as ptrs) */
-#define HDE_DIR_LEN(x) *(HDE_dir_len(x))
-#define HDE_XAR_LEN(x) *(HDE_xar_len(x))
-#define HDE_EXT_LBN(x) BOTH_INT(HDE_ext_lbn(x))
-#define HDE_EXT_SIZE(x) BOTH_INT(HDE_ext_size(x))
-#define HDE_CDATE(x) HDE_cdate(x)
-#define HDE_FLAGS(x) *(HDE_flags(x))
-#define HDE_RESERVED(x) *(HDE_reserved(x))
-#define HDE_INTRLV_SIZE(x) *(HDE_intrlv_size(x))
-#define HDE_INTRLV_SKIP(x) *(HDE_intrlv_skip(x))
-#define HDE_VOL_SET(x) BOTH_SHORT(HDE_vol_set(x))
-#define HDE_NAME_LEN(x) *(HDE_name_len(x))
-#define HDE_NAME(x) HDE_name(x)
-
-/***UNIX EXTENSION*****/
-#define HDE_MODE(x) *(HDE_mode(x))
-#define HDE_UID(x) *(HDE_uid(x))
-#define HDE_GID(x) *(HDE_gid(x))
-
-/* mask bits for HDE_FLAGS */
-#define HDE_EXISTENCE 0x01 /* zero if file exists */
-#define HDE_DIRECTORY 0x02 /* zero if file is not a directory */
-#define HDE_ASSOCIATED 0x04 /* zero if file is not Associated */
-#define HDE_RECORD 0x08 /* zero if no record attributes */
-#define HDE_PROTECTION 0x10 /* zero if no protection attributes */
-#define HDE_UNUSED_FLAGS 0x60
-#define HDE_LAST_EXTENT 0x80 /* zero if last extent in file */
-#define HDE_PROHIBITED (HDE_DIRECTORY | HDE_ASSOCIATED | HDE_RECORD | \
- HDE_LAST_EXTENT | HDE_UNUSED_FLAGS)
-
-/* Directory Record date fields */
-#define HDE_DATE_YEAR(x) (((u_char *)x)[0] + 1900)
-#define HDE_DATE_MONTH(x) (((u_char *)x)[1])
-#define HDE_DATE_DAY(x) (((u_char *)x)[2])
-#define HDE_DATE_HOUR(x) (((u_char *)x)[3])
-#define HDE_DATE_MIN(x) (((u_char *)x)[4])
-#define HDE_DATE_SEC(x) (((u_char *)x)[5])
-
-/* tests for Interchange Levels 1 & 2 file types */
-#define HDE_REGULAR_FILE(x) (((x) & HDE_PROHIBITED) == 0)
-#define HDE_REGULAR_DIR(x) (((x) & HDE_PROHIBITED) == HDE_DIRECTORY)
-
-#define HS_DIR_NAMELEN 31 /* max length of a directory name */
-#define HS_FILE_NAMELEN 31 /* max length of a filename */
-
-#endif /*!_HSFS_SPEC_H_*/
diff --git a/usr/src/cmd/fs.d/hsfs/labelit/iso_impl.h b/usr/src/cmd/fs.d/hsfs/labelit/iso_impl.h
deleted file mode 100644
index 7d2ccd2537..0000000000
--- a/usr/src/cmd/fs.d/hsfs/labelit/iso_impl.h
+++ /dev/null
@@ -1,137 +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 2000 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-/**************************************************************************
- *
- * iso_impl.h internal macros for /usr/etc/fs/HSFS/mkproto
- *
- ***************************************************************************/
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*
- * Macros for counting and rounding.
- */
-#ifdef howmany
-#undef howmany
-#endif
-
-#if defined(sun386) || defined(i386)
-#define howmany(x, y) ((((u_int)(x))+(((u_int)(y))-1))/((u_int)(y)))
-#define roundup(x, y) ((((u_int)(x)+((u_int)(y)-1))/(u_int)(y))*(u_int)(y))
-#else
-#define howmany(x, y) (((x)+((y)-1))/(y))
-#define roundup(x, y) ((((x)+((y)-1))/(y))*(y))
-#endif
-
-extern int cdout;
-extern int set_size;
-extern int set_seq;
-extern int blk_size;
-extern int nlbn_per_sec;
-extern char u[], v[];
-extern long unix_voldesc_sec;
-extern int prototype;
-
-#define PUTSECTOR(buf, secno, nosec) (putdisk(buf, (secno)*ISO_SECTOR_SIZE, \
- (nosec)*ISO_SECTOR_SIZE))
-#define GETSECTOR(buf, secno, nosec) (getdisk(buf, (secno)*ISO_SECTOR_SIZE, \
- (nosec)*ISO_SECTOR_SIZE))
-#define PUTLBN(buf, secno, nosec) (putdisk(buf, (secno)*blk_size, \
- (nosec)*blk_size))
-#define GETLBN(buf, lbn, nolbn) (getdisk(buf, (lbn)*blk_size, \
- (nolbn)*blk_size))
-#define LBN_TO_SEC(lbn) ((lbn)/nlbn_per_sec)
-#define SEC_TO_LBN(sec) ((sec)*nlbn_per_sec)
-#define LBN_TO_BYTE(lbn) ((lbn)*blk_size)
-#define BYTE_TO_SEC(byte) (byte/ISO_SECTOR_SIZE)
-
-#define CD_UNIX 0
-#define CD_ISO 1
-
-#define CD_MSB 0
-#define CD_LSB 1
-
-#define CD_REGULAR 1
-#define CD_FILE 2
-#define CD_DIRECTORY 4
-#define CD_DOT 8
-#define CD_DOTDOT 16
-
-#define UNIX_VOLDESC_SEC ISO_VOLDESC_SEC+1
-
-/* internal data structure */
-/* unix file info - to be copied to a cd-rom image */
-struct ufname {
- int fsize; /* size of file in byte */
- char fname[1]; /* file name, should be longer */
-};
-
-/* dlist - individual element of a directory tree */
-struct dlist {
- struct dlist *dnext; /* point to next */
- struct dlist *pdp; /* point to parent */
- struct dlist *cdp; /* point to child */
- struct dlist *ucdp; /* point to first unix child */
- struct dlist *icdp; /* point to first iso child */
- struct dlist *unext; /* pointer to next in UNIX fname order */
- struct dlist *inext; /* pointer to next in ISO fname order */
- struct dlist *idirnext; /* pointer to next dir in iso, breadth first order */
- struct dlist *udirnext; /* pointer to next dir in unix, breadth first order */
- int idno; /* directory number in iso, in breadth first order */
- int udno; /* directory number in unix, in breadth first order */
- int ipoffset; /* offset in iso path table - directory only */
- int upoffset; /* offset in unix path table - directory only */
- int idlbn; /* lbn of parent in iso directory */
- int idoffset; /* offset of parent in iso directory */
- int udlbn; /* lbn of parent in unix directory */
- int udoffset; /* offset of parent in unix directory */
- int idextlbn; /* lbn of extent in iso */
- int udextlbn; /* lbn of extent in unix */
- int idsize; /* iso directory size */
- int udsize; /* unix directory size */
- int extlbn; /* location of the data */
- int fsize; /* size of the data */
- time_t mtime; /* las modification time */
- long duid; /* owner's user id */
- long dgid; /* owner's group id */
- long dmode; /* mode and type of file */
- long nlink; /* no. of links */
- struct ufname *ufnp; /* pointer to the corresponding UNIX file */
- char isofname[32]; /* iso file name */
- char unixfname[1]; /* unix file name, should be longer */
-};
-
-void update_pvd();
-void update_uvd();
-void update_pvd_ptbl();
-void update_uvd_ptbl();
-
-struct dlist * mkdlist();
-struct dlist * mkdlist_proto();
-struct dlist * mkdlist_path();
-void sortdlist();
-
-
diff --git a/usr/src/cmd/fs.d/hsfs/labelit/iso_spec.h b/usr/src/cmd/fs.d/hsfs/labelit/iso_spec.h
deleted file mode 100644
index 4619e611bf..0000000000
--- a/usr/src/cmd/fs.d/hsfs/labelit/iso_spec.h
+++ /dev/null
@@ -1,359 +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 2005 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*
- * ISO 9660 filesystem specification
- */
-
-#ifndef _ISO_SPEC_H_
-#define _ISO_SPEC_H_
-
-#include <sys/isa_defs.h>
-
-/* routines required for date parsing */
-extern struct timeval iso_parse_dirdate(); /* parse date in directory */
-extern struct timeval iso__parse_longdate(); /* parse date in volume id */
-
-/* macros to parse binary integers */
-#define ZERO(x) (u_int) (((u_char *)(x))[0])
-#define ONE(x) (u_int) (((u_char *)(x))[1])
-#define TWO(x) (u_int) (((u_char *)(x))[2])
-#define THREE(x) (u_int) (((u_char *)(x))[3])
-
-#define MSB_INT(x) \
- ((((((ZERO(x) << 8) | ONE(x)) << 8) | TWO(x)) << 8) | THREE(x))
-#define LSB_INT(x) \
- ((((((THREE(x) << 8) | TWO(x)) << 8) | ONE(x)) << 8) | ZERO(x))
-#define MSB_SHORT(x) ((ZERO(x) << 8) | ONE(x))
-#define LSB_SHORT(x) ((ONE(x) << 8) | ZERO(x))
-
-#if defined(sparc)
-/*
- * Sparc machines requires that integer must
- * be in a full word boundary. CD-ROM data aligns
- * to even word boundary only. Because of this mismatch,
- * we have to move integer data from CD-ROM to memory one
- * byte at a time. LSB data starts first. We therefore
- * use this to do byte by byte copying.
- */
-#define BOTH_SHORT(x) LSB_SHORT(x)
-#define BOTH_INT(x) LSB_INT(x)
-
-#elif defined(_LITTLE_ENDIAN)
-#define BOTH_SHORT(x) (short) *((short *)x)
-#define BOTH_INT(x) (int) *((int *)x)
-
-#elif defined(_BIG_ENDIAN)
-#define BOTH_SHORT(x) (short) *((short *)x + 1)
-#define BOTH_INT(x) (int) *((int *)x + 1)
-#else
-#error One of _BIG_ENDIAN and _LITTLE_ENDIAN must be defined
-#endif
-
-/*
- * conversions to/from little endian format
- */
-#if defined(_LITTLE_ENDIAN)
-/* little endian machines */
-#define ltohs(S) (S)
-#define ltohl(L) (L)
-#define htols(S) (S)
-#define htoll(L) (L)
-#else
-/* big endian machines */
-#define ltohs(S) LSB_SHORT((char *) (S))
-#define ltohl(L) LSB_INT((char *) (L))
-#define htols(S) LSB_SHORT((char *) (S))
-#define htoll(L) LSB_INT((char *) (L))
-#endif
-
-/*
- * The following describes actual on-disk structures.
- * To achieve portability, all structures are #defines
- * rather than a structure definition. Macros are provided
- * to get either the data or address of individual fields.
- */
-
-/* Overall High Sierra disk structure */
-#define ISO_SECTOR_SIZE 2048 /* bytes per logical sector */
-#define ISO_SECTOR_SHIFT 11 /* sector<->byte shift count */
-#define ISO_SEC_PER_PAGE (PAGESIZE/HS_SECTOR_SIZE) /* sectors per page */
-#define ISO_SYSAREA_SEC 0 /* 1st sector of system area */
-#define ISO_VOLDESC_SEC 16 /* 1st sector of volume descriptors */
-#define MAXISOOFFSET (ISO_SECTOR_SIZE - 1)
-#define MAXISOMASK (~MAXISOOFFSET)
-
-
-/* Standard File Structure Volume Descriptor */
-
-enum iso_voldesc_type {
- ISO_VD_BOOT=0, ISO_VD_PVD=1, ISO_VD_SVD=2, ISO_VD_VPD=3,
- ISO_VD_UNIX=4, /* UNIX extension */
- ISO_VD_EOV=255
-};
-#define ISO_ID_STRING "CD001" /* ISO_std_id field */
-#define ISO_ID_STRLEN 5 /* ISO_std_id field length */
-#define ISO_ID_VER 1 /* ISO_std_ver field */
-#define ISO_FILE_STRUCT_ID_VER 1 /* ISO_file structure version field */
-#define ISO_DATE_TO_UNIX(x) iso_parse_longdate(x) /* returns a timeval */
-#define ISO_SYS_ID_STRLEN 32
-#define ISO_VOL_ID_STRLEN 32
-#define ISO_VOL_SET_ID_STRLEN 128
-#define ISO_PUB_ID_STRLEN 128
-#define ISO_PREP_ID_STRLEN 128
-#define ISO_APPL_ID_STRLEN 128
-#define ISO_COPYR_ID_STRLEN 37
-#define ISO_ABSTR_ID_STRLEN 37
-#define ISO_DATE_LEN 17
-
-
-
-/* macros to get the address of each field */
-#define ISO_desc_type(x) (&((u_char *)x)[0])
-#define ISO_std_id(x) (&((u_char *)x)[1])
-#define ISO_std_ver(x) (&((u_char *)x)[6])
-#define ISO_sys_id(x) (&((u_char *)x)[8])
-#define ISO_vol_id(x) (&((u_char *)x)[40])
-#define ISO_vol_size(x) (&((u_char *)x)[80])
-#define ISO_set_size(x) (&((u_char *)x)[120])
-#define ISO_set_seq(x) (&((u_char *)x)[124])
-#define ISO_blk_size(x) (&((u_char *)x)[128])
-#define ISO_ptbl_size(x) (&((u_char *)x)[132])
-#define ISO_ptbl_man_ls(x) (&((u_char *)x)[140])
-#define ISO_ptbl_opt_ls1(x) (&((u_char *)x)[144])
-#define ISO_ptbl_man_ms(x) (&((u_char *)x)[148])
-#define ISO_ptbl_opt_ms1(x) (&((u_char *)x)[152])
-#define ISO_root_dir(x) (&((u_char *)x)[156])
-#define ISO_vol_set_id(x) (&((u_char *)x)[190])
-#define ISO_pub_id(x) (&((u_char *)x)[318])
-#define ISO_prep_id(x) (&((u_char *)x)[446])
-#define ISO_appl_id(x) (&((u_char *)x)[574])
-#define ISO_copyr_id(x) (&((u_char *)x)[702])
-#define ISO_abstr_id(x) (&((u_char *)x)[739])
-#define ISO_bibli_id(x) (&((u_char *)x)[776])
-#define ISO_cre_date(x) (&((u_char *)x)[813])
-#define ISO_mod_date(x) (&((u_char *)x)[830])
-#define ISO_exp_date(x) (&((u_char *)x)[847])
-#define ISO_eff_date(x) (&((u_char *)x)[864])
-#define ISO_file_struct_ver(x) (&((u_char *)x)[881])
-
-/* macros to get the values of each field (strings are returned as ptrs) */
-#define ISO_DESC_TYPE(x) ((enum hs_voldesc_type)*(ISO_desc_type(x)))
-#define ISO_STD_ID(x) ISO_std_id(x)
-#define ISO_STD_VER(x) *(ISO_std_ver(x))
-#define ISO_SYS_ID(x) ISO_sys_id(x)
-#define ISO_VOL_ID(x) ISO_vol_id(x)
-#define ISO_VOL_SIZE(x) BOTH_INT(ISO_vol_size(x))
-#define ISO_SET_SIZE(x) BOTH_SHORT(ISO_set_size(x))
-#define ISO_SET_SEQ(x) BOTH_SHORT(ISO_set_seq(x))
-#define ISO_BLK_SIZE(x) BOTH_SHORT(ISO_blk_size(x))
-#define ISO_PTBL_SIZE(x) BOTH_INT(ISO_ptbl_size(x))
-#define ISO_PTBL_MAN_LS(x) LSB_INT(ISO_ptbl_man_ls(x))
-#define ISO_PTBL_OPT_LS1(x) LSB_INT(ISO_ptbl_opt_ls1(x))
-#define ISO_PTBL_MAN_MS(x) MSB_INT(ISO_ptbl_man_ms(x))
-#define ISO_PTBL_OPT_MS1(x) MSB_INT(ISO_ptbl_opt_ms1(x))
-#define ISO_ROOT_DIR(x) ISO_root_dir(x)
-#define ISO_VOL_SET_ID(x) ISO_vol_set_id(x)
-#define ISO_PUB_ID(x) ISO_pub_id(x)
-#define ISO_PREP_ID(x) ISO_prep_id(x)
-#define ISO_APPL_ID(x) ISO_appl_id(x)
-#define ISO_COPYR_ID(x) ISO_copyr_id(x)
-#define ISO_ABSTR_ID(x) ISO_abstr_id(x)
-#define ISO_BIBLI_ID(x) ISO_bibli_id(x)
-#define ISO_CRE_DATE(x) ISO_DATE_TO_UNIX(HSV_cre_date(x))
-#define ISO_MOD_DATE(x) ISO_DATE_TO_UNIX(HSV_mod_date(x))
-#define ISO_EXP_DATE(x) ISO_DATE_TO_UNIX(HSV_exp_date(x))
-#define ISO_EFF_DATE(x) ISO_DATE_TO_UNIX(HSV_eff_date(x))
-#define ISO_FILE_STRUCT_VER(x) *(ISO_file_struct_ver(x))
-
-/* Standard File Structure Volume Descriptor date fields */
-#define ISO_DATE_2DIG(x) ( (((x)[0] - '0') * 10) + \
- ((x)[1] - '0') )
-#define ISO_DATE_4DIG(x) ( (((x)[0] - '0') * 1000) + \
- (((x)[1] - '0') * 100) + \
- (((x)[2] - '0') * 10) + \
- ((x)[3] - '0') )
-#define ISO_DATE_YEAR(x) ISO_DATE_4DIG(&((u_char *)x)[0])
-#define ISO_DATE_MONTH(x) ISO_DATE_2DIG(&((u_char *)x)[4])
-#define ISO_DATE_DAY(x) ISO_DATE_2DIG(&((u_char *)x)[6])
-#define ISO_DATE_HOUR(x) ISO_DATE_2DIG(&((u_char *)x)[8])
-#define ISO_DATE_MIN(x) ISO_DATE_2DIG(&((u_char *)x)[10])
-#define ISO_DATE_SEC(x) ISO_DATE_2DIG(&((u_char *)x)[12])
-#define ISO_DATE_HSEC(x) ISO_DATE_2DIG(&((u_char *)x)[14])
-
-
-
-/* Directory Entry (Directory Record) */
-#define IDE_ROOT_DIR_REC_SIZE 34 /* size of root directory record */
-#define IDE_FDESIZE 33 /* fixed size for hsfs directory area */
- /* max size of a name */
-#define IDE_MAX_NAME_LEN (255 - IDE_FDESIZE)
-
-
-#define IDE_DATE_TO_UNIX(x) iso_parse_dirdate(x) /* returns a timeval */
-
-/* macros to get the address of each field */
-#define IDE_dir_len(x) (&((u_char *)x)[0])
-#define IDE_xar_len(x) (&((u_char *)x)[1])
-#define IDE_ext_lbn(x) (&((u_char *)x)[2])
-#define IDE_ext_size(x) (&((u_char *)x)[10])
-#define IDE_cdate(x) (&((u_char *)x)[18])
-#define IDE_flags(x) (&((u_char *)x)[25])
-#define IDE_intrlv_size(x) (&((u_char *)x)[26])
-#define IDE_intrlv_skip(x) (&((u_char *)x)[27])
-#define IDE_vol_set(x) (&((u_char *)x)[28])
-#define IDE_name_len(x) (&((u_char *)x)[32])
-#define IDE_name(x) (&((u_char *)x)[33])
-
-/* macros to get the values of each field (strings are returned as ptrs) */
-#define IDE_DIR_LEN(x) *(IDE_dir_len(x))
-#define IDE_XAR_LEN(x) *(IDE_xar_len(x))
-#define IDE_EXT_LBN(x) BOTH_INT(IDE_ext_lbn(x))
-#define IDE_EXT_SIZE(x) BOTH_INT(IDE_ext_size(x))
-#define IDE_CDATE(x) IDE_DATE_TO_UNIX(HDE_cdate(x))
-#define IDE_FLAGS(x) *(IDE_flags(x))
-#define IDE_INTRLV_SIZE(x) *(IDE_intrlv_size(x))
-#define IDE_INTRLV_SKIP(x) *(IDE_intrlv_skip(x))
-#define IDE_VOL_SET(x) BOTH_SHORT(IDE_vol_set(x))
-#define IDE_NAME_LEN(x) *(IDE_name_len(x))
-#define IDE_NAME(x) IDE_name(x)
-
-/* mask bits for IDE_FLAGS */
-#define IDE_EXISTENCE 0x01 /* zero if file exists */
-#define IDE_DIRECTORY 0x02 /* zero if file is not a directory */
-#define IDE_ASSOCIATED 0x04 /* zero if file is not Associated */
-#define IDE_RECORD 0x08 /* zero if no record attributes */
-#define IDE_PROTECTION 0x10 /* zero if no protection attributes */
-#define IDE_UNUSED_FLAGS 0x60
-#define IDE_LAST_EXTENT 0x80 /* zero if last extent in file */
-#define IDE_PROHIBITED (IDE_DIRECTORY | HDE_ASSOCIATED | HDE_RECORD | \
- IDE_LAST_EXTENT | IDE_UNUSED_FLAGS)
-
-/* Directory Record date fields */
-#define IDE_DATE_YEAR(x) (((u_char *)x)[0] + 1900)
-#define IDE_DATE_MONTH(x) (((u_char *)x)[1])
-#define IDE_DATE_DAY(x) (((u_char *)x)[2])
-#define IDE_DATE_HOUR(x) (((u_char *)x)[3])
-#define IDE_DATE_MIN(x) (((u_char *)x)[4])
-#define IDE_DATE_SEC(x) (((u_char *)x)[5])
-
-/* tests for Interchange Levels 1 & 2 file types */
-#define IDE_REGULAR_FILE(x) (((x) & IDE_PROHIBITED) == 0)
-#define IDE_REGULAR_DIR(x) (((x) & IDE_PROHIBITED) == IDE_DIRECTORY)
-
-#define ISO_DIR_NAMELEN 31 /* max length of a directory name */
-#define ISO_FILE_NAMELEN 31 /* max length of a filename */
-
-/* Path table enry */
-/* fix size of path table entry */
-#define IPE_FPESIZE 8
-/* macros to get the address of each field */
-#define IPE_name_len(x) (&((u_char *)x)[0])
-#define IPE_xar_len(x) (&((u_char *)x)[1])
-#define IPE_ext_lbn(x) (&((u_char *)x)[2])
-#define IPE_parent_no(x) (&((u_char *)x)[6])
-#define IPE_name(x) (&((u_char *)x)[8])
-
-/* macros to get the values of each field */
-#define IPE_EXT_LBN(x) (MSB_INT(IPE_ext_lbn(x)))
-#define IPE_XAR_LEN(x) *(IPE_xar_len(x))
-#define IPE_NAME_LEN(x) *(IPE_name_len(x))
-#define IPE_PARENT_NO(x) *(short *)(IPE_parent_no(x))
-#define IPE_NAME(x) IPE_name(x)
-
-/* cdrom UNIX extension */
-/* UNIX Volume Descriptor */
-#define ISO_UNIX_ID_STRING "UNIXCD01" /* ISO_UNIX_std_id field */
-#define ISO_UNIX_ID_STRLEN 8 /* ISO_UNIX_std_id length */
-#define ISO_UNIX_FEATURE_SYMLNK 0x01 /* CD-ROM supports symbolic links */
-#define ISO_UNIX_FEATURE_LONGFN 0x02 /* CD-ROM supports long BSD file names */
-
-#define ISO_UNIX_feature(x) (&((u_char *)x)[7])
-#define ISO_UNIX_root_dir(x) (&((u_char *)x)[1395])
-#define ISO_UNIX_signature(x) (&((u_char *)x)[2040])
-
-#define ISO_UNIX_FEATURE(x) *(ISO_UNIX_feature(x))
-#define ISO_UNIX_ROOT_DIR(x) ISO_UNIX_root_dir(x)
-#define ISO_UNIX_SIGNATURE(x) ISO_UNIX_signature(x)
-
-/* UNIX extension to path table entry */
-/* fix size of path table entry */
-#define IPE_UNIX_FPESIZE 20
-
-#define IPE_UNIX_mode(x) (&((u_char *)x)[0])
-#define IPE_UNIX_uid(x) (&((u_char *)x)[4])
-#define IPE_UNIX_gid(x) (&((u_char *)x)[8])
-
-/* macros to get the values of each field */
-#define IPE_UNIX_MODE(x) (MSB_INT(IPE_UNIX_mode(x)))
-#define IPE_UNIX_UID(x) (MSB_INT(IPE_UNIX_uid(x)))
-#define IPE_UNIX_GID(x) (MSB_INT(IPE_UNIX_gid(x)))
-
-/* UNIX extension to directory entry */
-#define IDE_UNIX_SIG_UX "UX" /* UNIX extension signature */
-#define IDE_UNIX_SIG_TI "TI" /* UNIX extension signature for time */
-#define IDE_UNIX_USE_ID_VER 1 /* UNIX extension sys use id */
-#define IDE_UNIX_UX_LEN 36 /* length of UX */
-#define IDE_UNIX_TI_LEN 40 /* length of TI */
-
-#define IDE_UNIX_signature(x) (&((u_char *)x)[0])
-#define IDE_UNIX_ext_len(x) (&((u_char *)x)[2])
-#define IDE_UNIX_use_id(x) (&((u_char *)x)[3])
-#define IDE_UNIX_mode(x) (&((u_char *)x)[4])
-#define IDE_UNIX_nlink(x) (&((u_char *)x)[12])
-#define IDE_UNIX_uid(x) (&((u_char *)x)[20])
-#define IDE_UNIX_gid(x) (&((u_char *)x)[28])
-
-
-#define IDE_UNIX_cre_date(x) (&((u_char *)x)[4])
-#define IDE_UNIX_mod_date(x) (&((u_char *)x)[11])
-#define IDE_UNIX_exp_date(x) (&((u_char *)x)[18])
-#define IDE_UNIX_eff_date(x) (&((u_char *)x)[25])
-#define IDE_UNIX_acc_date(x) (&((u_char *)x)[32])
-#define IDE_UNIX_reserved(x) (&((u_char *)x)[39])
-
-#define IDE_UNIX_SIGNATURE(x) IDE_UNIX_signature(x)
-#define IDE_UNIX_EXT_LEN(x) *(IDE_UNIX_ext_len(x))
-#define IDE_UNIX_USE_ID(x) *(IDE_UNIX_use_id(x))
-#define IDE_UNIX_MODE(x) BOTH_INT(IDE_UNIX_mode(x))
-#define IDE_UNIX_NLINK(x) BOTH_INT(IDE_UNIX_nlink(x))
-#define IDE_UNIX_UID(x) BOTH_INT(IDE_UNIX_uid(x))
-#define IDE_UNIX_GID(x) BOTH_INT(IDE_UNIX_gid(x))
-
-#define IDE_UNIX_CRE_DATE(x) IDE_UNIX_cre_date(x)
-#define IDE_UNIX_MOD_DATE(x) IDE_UNIX_mod_date(x)
-#define IDE_UNIX_EXP_DATE(x) IDE_UNIX_exp_date(x)
-#define IDE_UNIX_EFF_DATE(x) IDE_UNIX_eff_date(x)
-#define IDE_UNIX_ACC_DATE(x) IDE_UNIX_acc_date(x)
-#define IDE_UNIX_RESERVED(x) *(IDE_UNIX_reserved(x))
-
-/* root record */
-/* size of root directory record */
-#define IDE_UNIX_ROOT_DIR_REC_SIZE 34+IDE_UNIX_UX_LEN
-#define IDE_UNIX_MAX_NAME_LEN IDE_MAX_NAME_LEN - IDE_UNIX_UX_LEN
-
-#endif /*!_ISO_SPEC_H_*/
diff --git a/usr/src/cmd/fs.d/hsfs/labelit/labelit.c b/usr/src/cmd/fs.d/hsfs/labelit/labelit.c
index dea4facc33..51f1507e64 100644
--- a/usr/src/cmd/fs.d/hsfs/labelit/labelit.c
+++ b/usr/src/cmd/fs.d/hsfs/labelit/labelit.c
@@ -38,9 +38,6 @@
* bibfile: bibliographic file identifier (d-charcters, 37 max)
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-
#include <fcntl.h>
#include <stdio.h>
#include <sys/param.h>
@@ -49,9 +46,9 @@
#include <sys/types.h>
#include <sys/file.h>
#include <dirent.h>
-#include "hsfs_spec.h"
-#include "iso_spec.h"
-#include "iso_impl.h"
+
+#include <sys/fs/hsfs_isospec.h>
+#include <sys/fs/hsfs_spec.h>
#define PUTSECTOR(buf, secno, nosec) (putdisk(buf, (secno)*ISO_SECTOR_SIZE, \
(nosec)*ISO_SECTOR_SIZE))
@@ -157,7 +154,9 @@ main(int argc, char **argv)
if ((cdfd = open(argv[c], openopt)) < 0) {
if (strchr(argv[c], '=') ||
- strchr(argv[c], '-')) usage();
+ strchr(argv[c], '-')) {
+ usage();
+ }
sprintf(errstrng, "%s: main: open(): ", callname);
perror(errstrng);
exit(32);
@@ -185,7 +184,7 @@ static void
usage(void)
{
fprintf(stderr, "usage: %s [-F ufs] [option=value ...] cdimage\n",
- callname);
+ callname);
exit(32);
}
diff --git a/usr/src/cmd/fs.d/nfs/svc/Makefile b/usr/src/cmd/fs.d/nfs/svc/Makefile
index 5a19370fcf..91a5fad7e0 100644
--- a/usr/src/cmd/fs.d/nfs/svc/Makefile
+++ b/usr/src/cmd/fs.d/nfs/svc/Makefile
@@ -22,11 +22,13 @@
# Copyright 2006 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
-# ident "%Z%%M% %I% %E% SMI"
+# Copyright 2012 Nexenta Systems, Inc. All rights reserved.
+
+#
#
MANIFEST= server.xml client.xml rquota.xml mapid.xml nlockmgr.xml \
- status.xml cbd.xml
+ status.xml cbd.xml nfslogd.xml
SVCMETHOD= nfs-server nfs-client nlockmgr
include $(SRC)/cmd/Makefile.cmd
diff --git a/usr/src/cmd/fs.d/nfs/svc/nfs-server b/usr/src/cmd/fs.d/nfs/svc/nfs-server
index 271f79c483..8542ce9b9f 100644
--- a/usr/src/cmd/fs.d/nfs/svc/nfs-server
+++ b/usr/src/cmd/fs.d/nfs/svc/nfs-server
@@ -21,6 +21,7 @@
#
#
# Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright 2012 Nexenta Systems, Inc. All rights reserved.
#
# Start/stop processes required for server NFS
@@ -132,26 +133,6 @@ case "$1" in
/usr/sbin/sharemgr stop -P nfs -a
- #
- # Wait up to 10 seconds for nfslogd to gracefully handle SIGHUP
- #
- /usr/bin/pkill -HUP -x -u 0 -z $zone nfslogd
- wtime=10
-
- while [ $wtime -gt 0 ]; do
- /usr/bin/pgrep -x -u 0 -z $zone nfslogd >/dev/null || break
- wtime=`expr $wtime - 1`
- sleep 1
- done
-
- #
- # Kill nfslogd more forcefully if it did not shutdown during
- # the grace period
- #
- if [ $wtime -eq 0 ]; then
- /usr/bin/pkill -TERM -x -u 0 -z $zone nfslogd
- fi
-
# Kill any processes left in service contract
smf_kill_contract $2 TERM 1
[ $? -ne 0 ] && exit 1
diff --git a/usr/src/cmd/fs.d/nfs/svc/nfslogd.xml b/usr/src/cmd/fs.d/nfs/svc/nfslogd.xml
new file mode 100644
index 0000000000..fa168a6660
--- /dev/null
+++ b/usr/src/cmd/fs.d/nfs/svc/nfslogd.xml
@@ -0,0 +1,68 @@
+<?xml version="1.0"?>
+<!DOCTYPE service_bundle SYSTEM "/usr/share/lib/xml/dtd/service_bundle.dtd.1">
+<!--
+ 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 2012 Nexenta Systems, Inc. All rights reserved.
+-->
+
+<service_bundle type='manifest' name='SUNWnfssr:nfslogd'>
+
+<service
+ name='network/nfs/log'
+ type='service'
+ version='1'>
+
+ <dependency name='nfs-server'
+ grouping='require_all'
+ restart_on='refresh'
+ type='service'>
+ <service_fmri value='svc:/network/nfs/server' />
+ </dependency>
+
+ <dependency name='filesystem-minimal'
+ grouping='require_all'
+ restart_on='error'
+ type='service'>
+ <service_fmri value='svc:/system/filesystem/minimal' />
+ </dependency>
+
+ <exec_method
+ type='method'
+ name='start'
+ exec='/usr/lib/nfs/nfslogd'
+ timeout_seconds='60' />
+
+ <exec_method
+ type='method'
+ name='stop'
+ exec=':kill -TERM'
+ timeout_seconds='10' />
+
+ <instance name='default' enabled='false'>
+ </instance>
+
+ <stability value='Stable' />
+
+ <template>
+ <common_name>
+ <loctext xml:lang='C'>
+ NFS log daemon
+ </loctext>
+ </common_name>
+ <documentation>
+ <manpage title='nfslogd' section='1M'
+ manpath='/usr/share/man' />
+ </documentation>
+ </template>
+</service>
+
+</service_bundle>
diff --git a/usr/src/cmd/genmsg/genmsg.l b/usr/src/cmd/genmsg/genmsg.l
index e4f382f95d..12072628e0 100644
--- a/usr/src/cmd/genmsg/genmsg.l
+++ b/usr/src/cmd/genmsg/genmsg.l
@@ -24,8 +24,6 @@
* Use is subject to license terms.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
#include <stdio.h>
#include <stdlib.h>
#include <limits.h>
@@ -322,7 +320,7 @@ catgets {
-((([ \t]+)1)|1) { /* -1 */
if (end_of_cat == FALSE) {
- REJECT;
+ REJECT
} else if (IsActiveMode(ReplaceMode)) {
if (IsActiveMode(PreProcessMode)) {
int id = get_linemsgid(lineno);
diff --git a/usr/src/cmd/hal/hald-runner/main.c b/usr/src/cmd/hal/hald-runner/main.c
index cd2b866eda..accb65d875 100644
--- a/usr/src/cmd/hal/hald-runner/main.c
+++ b/usr/src/cmd/hal/hald-runner/main.c
@@ -4,6 +4,7 @@
* main.c - Main dbus interface of the hald runner
*
* Copyright (C) 2006 Sjoerd Simons, <sjoerd@luon.net>
+ * Copyright (C) 2007 Codethink Ltd. Author Rob Taylor <rob.taylor@codethink.co.uk>
*
* Licensed under the Academic Free License version 2.1
*
@@ -31,24 +32,46 @@
#include "utils.h"
#include "runner.h"
+#ifndef __GNUC__
+#define __attribute__(x)
+#endif
+
static gboolean
-parse_first_part(run_request *r, DBusMessage *msg, DBusMessageIter *iter)
+parse_udi (run_request *r, DBusMessage *msg, DBusMessageIter *iter)
{
- DBusMessageIter sub_iter;
char *tmpstr;
- /* First should be the device UDI */
+ /* Should be the device UDI */
if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_STRING)
goto malformed;
dbus_message_iter_get_basic(iter, &tmpstr);
r->udi = g_strdup(tmpstr);
- /* Then the environment array */
- if (!dbus_message_iter_next(iter) || dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_ARRAY)
+ if (!dbus_message_iter_next(iter))
+ goto malformed;
+
+ return TRUE;
+
+malformed:
+ return FALSE;
+}
+
+static gboolean
+parse_environment(run_request *r, DBusMessage *msg, DBusMessageIter *iter)
+{
+ DBusMessageIter sub_iter;
+ char *tmpstr;
+
+ /* The environment array */
+ if (dbus_message_iter_get_arg_type(iter) != DBUS_TYPE_ARRAY)
goto malformed;
dbus_message_iter_recurse(iter, &sub_iter);
/* Add default path for the programs we start */
+#if defined(__FreeBSD__)
+ tmpstr = g_strdup_printf("PATH=/sbin:/usr/sbin:/bin:/usr/bin:/usr/local/sbin:/usr/X11R6/sbin:/bin:/usr/bin:/usr/local/bin:/usr/X11R6/bin:%s", getenv("PATH"));
+#else
tmpstr = g_strdup_printf("PATH=/sbin:/usr/sbin:/bin:/usr/bin:%s", getenv("PATH"));
+#endif
r->environment = get_string_array(&sub_iter, tmpstr);
/* Then argv */
@@ -74,7 +97,10 @@ handle_run(DBusConnection *con, DBusMessage *msg)
r = new_run_request();
g_assert(dbus_message_iter_init(msg, &iter));
- if (!parse_first_part(r, msg, &iter))
+ if (!parse_udi(r, msg, &iter))
+ goto malformed;
+
+ if (!parse_environment(r, msg, &iter))
goto malformed;
/* Next a string of what should be written to stdin */
@@ -106,25 +132,36 @@ malformed:
}
static void
-handle_start(DBusConnection *con, DBusMessage *msg)
+handle_start(DBusConnection *con, DBusMessage *msg, gboolean is_singleton)
{
DBusMessage *reply;
DBusMessageIter iter;
run_request *r;
GPid pid;
- dbus_int64_t pid64;
r = new_run_request();
+ r->is_singleton = is_singleton;
+
g_assert(dbus_message_iter_init(msg, &iter));
- if (!dbus_message_iter_init(msg, &iter) || !parse_first_part(r, msg, &iter))
+ if (!dbus_message_iter_init(msg, &iter))
goto malformed;
+ if (!is_singleton && !parse_udi(r, msg, &iter)) {
+ fprintf(stderr, "error parsing udi");
+ goto malformed;
+ }
+
+ if (!parse_environment(r, msg, &iter)) {
+ fprintf(stderr, "error parsing environment");
+ goto malformed;
+ }
+
if (run_request_run(r, con, NULL, &pid)) {
- pid64 = pid;
+ gint64 ppid = pid;
reply = dbus_message_new_method_return(msg);
dbus_message_append_args (reply,
- DBUS_TYPE_INT64, &pid64,
+ DBUS_TYPE_INT64, &ppid,
DBUS_TYPE_INVALID);
} else {
@@ -177,11 +214,18 @@ filter(DBusConnection *con, DBusMessage *msg, void *user_data)
handle_run(con, msg);
return DBUS_HANDLER_RESULT_HANDLED;
} else if (dbus_message_is_method_call(msg, "org.freedesktop.HalRunner", "Start")) {
- handle_start(con, msg);
+ handle_start(con, msg, FALSE);
+ return DBUS_HANDLER_RESULT_HANDLED;
+ } else if (dbus_message_is_method_call(msg, "org.freedesktop.HalRunner", "StartSingleton")) {
+ handle_start(con, msg, TRUE);
return DBUS_HANDLER_RESULT_HANDLED;
} else if (dbus_message_is_method_call(msg, "org.freedesktop.HalRunner", "Kill")) {
handle_kill(con, msg);
return DBUS_HANDLER_RESULT_HANDLED;
+ } else if (dbus_message_is_method_call(msg, "org.freedesktop.HalRunner", "Shutdown")) {
+ run_kill_all ();
+ exit (0);
+ return DBUS_HANDLER_RESULT_HANDLED;
} else if (dbus_message_is_method_call(msg, "org.freedesktop.HalRunner", "KillAll")) {
run_kill_all();
/* alwasy successfull */
diff --git a/usr/src/cmd/hal/hald-runner/runner.c b/usr/src/cmd/hal/hald-runner/runner.c
index a4a9aafd69..2d0f858b66 100644
--- a/usr/src/cmd/hal/hald-runner/runner.c
+++ b/usr/src/cmd/hal/hald-runner/runner.c
@@ -4,6 +4,7 @@
* runner.c - Process running code
*
* Copyright (C) 2006 Sjoerd Simons, <sjoerd@luon.net>
+ * Copyright (C) 2007 Codethink Ltd. Author Rob Taylor <rob.taylor@codethink.co.uk>
*
* Licensed under the Academic Free License version 2.1
*
@@ -48,6 +49,7 @@
#define HALD_RUN_KILLED 0x4
GHashTable *udi_hash = NULL;
+GList *singletons = NULL;
typedef struct {
run_request *r;
@@ -128,15 +130,19 @@ send_reply(DBusConnection *con, DBusMessage *msg, guint32 exit_type, gint32 retu
}
static void
-remove_from_hash_table(run_data *rd)
+remove_run_data(run_data *rd)
{
GList *list;
- /* Remove to the hashtable */
- list = (GList *)g_hash_table_lookup(udi_hash, rd->r->udi);
- list = g_list_remove(list, rd);
- /* The hash table will take care to not leak the dupped string */
- g_hash_table_insert(udi_hash, g_strdup(rd->r->udi), list);
+ if (rd->r->is_singleton) {
+ singletons = g_list_remove(singletons, rd);
+ } else {
+ /* Remove to the hashtable */
+ list = (GList *)g_hash_table_lookup(udi_hash, rd->r->udi);
+ list = g_list_remove(list, rd);
+ /* The hash table will take care to not leak the dupped string */
+ g_hash_table_insert(udi_hash, g_strdup(rd->r->udi), list);
+ }
}
static void
@@ -145,7 +151,8 @@ run_exited(GPid pid, gint status, gpointer data)
run_data *rd = (run_data *)data;
char **error = NULL;
- printf("%s exited\n", rd->r->argv[0]);
+ printf("pid %d: rc=%d signaled=%d: %s\n",
+ pid, WEXITSTATUS(status), WIFSIGNALED(status), rd->r->argv[0]);
rd->watch = 0;
if (rd->sent_kill == TRUE) {
/* We send it a kill, so ignore */
@@ -170,18 +177,17 @@ run_exited(GPid pid, gint status, gpointer data)
free_string_array(error);
out:
- remove_from_hash_table(rd);
+ remove_run_data (rd);
/* emit a signal that this PID exited */
if(rd->con != NULL && rd->emit_pid_exited) {
DBusMessage *signal;
- dbus_int64_t pid64;
+ gint64 ppid = rd->pid;
signal = dbus_message_new_signal ("/org/freedesktop/HalRunner",
"org.freedesktop.HalRunner",
"StartedProcessExited");
- pid64 = rd->pid;
dbus_message_append_args (signal,
- DBUS_TYPE_INT64, &pid64,
+ DBUS_TYPE_INT64, &(ppid),
DBUS_TYPE_INVALID);
dbus_connection_send(rd->con, signal, NULL);
}
@@ -202,7 +208,7 @@ run_timedout(gpointer data) {
rd->sent_kill = TRUE;
send_reply(rd->con, rd->msg, HALD_RUN_TIMEOUT, 0, NULL);
- remove_from_hash_table(rd);
+ remove_run_data (rd);
return FALSE;
}
@@ -246,7 +252,7 @@ run_request_run (run_request *r, DBusConnection *con, DBusMessage *msg, GPid *ou
char *program_dir = NULL;
GList *list;
- printf("Run started %s (%d) (%d) \n!", r->argv[0], r->timeout,
+ printf("Run started %s (%u) (%d) \n!", r->argv[0], r->timeout,
r->error_on_stderr);
if (r->input != NULL) {
stdin_p = &stdin_v;
@@ -277,7 +283,7 @@ run_request_run (run_request *r, DBusConnection *con, DBusMessage *msg, GPid *ou
if (r->input) {
if (write(stdin_v, r->input, strlen(r->input)) != (ssize_t) strlen(r->input))
- printf("Warning: Error while wite r->input (%s) to stdin_v.\n", r->input);
+ printf("Warning: Error while writing r->input (%s) to stdin_v.\n", r->input);
close(stdin_v);
}
@@ -302,12 +308,16 @@ run_request_run (run_request *r, DBusConnection *con, DBusMessage *msg, GPid *ou
else
rd->timeout = 0;
- /* Add to the hashtable */
- list = (GList *)g_hash_table_lookup(udi_hash, r->udi);
- list = g_list_prepend(list, rd);
+ if (r->is_singleton) {
+ singletons = g_list_prepend(singletons, rd);
+ } else {
+ /* Add to the hashtable */
+ list = (GList *)g_hash_table_lookup(udi_hash, r->udi);
+ list = g_list_prepend(list, rd);
- /* The hash table will take care to not leak the dupped string */
- g_hash_table_insert(udi_hash, g_strdup(r->udi), list);
+ /* The hash table will take care to not leak the dupped string */
+ g_hash_table_insert(udi_hash, g_strdup(r->udi), list);
+ }
/* send back PID if requested.. and only emit StartedProcessExited in this case */
if (out_pid != NULL) {
@@ -365,6 +375,7 @@ void
run_kill_all()
{
g_hash_table_foreach_remove(udi_hash, hash_kill_udi, NULL);
+ g_list_foreach(singletons, kill_rd, NULL);
}
void
diff --git a/usr/src/cmd/hal/hald-runner/runner.h b/usr/src/cmd/hal/hald-runner/runner.h
index 2a18f941e3..d063784639 100644
--- a/usr/src/cmd/hal/hald-runner/runner.h
+++ b/usr/src/cmd/hal/hald-runner/runner.h
@@ -36,6 +36,7 @@ typedef struct {
gchar **argv;
gchar *input;
gboolean error_on_stderr;
+ gboolean is_singleton;
guint32 timeout;
} run_request;
@@ -49,9 +50,9 @@ gboolean run_request_run(run_request *r, DBusConnection *con, DBusMessage *msg,
void run_kill_udi(gchar *udi);
/* Kill all running request*/
-void run_kill_all();
+void run_kill_all(void);
/* initialise the actual runner data */
-void run_init();
+void run_init(void);
#endif /* RUNNER_H */
diff --git a/usr/src/cmd/isns/isnsd/Makefile b/usr/src/cmd/isns/isnsd/Makefile
index b46f7dd15b..054beb31d4 100644
--- a/usr/src/cmd/isns/isnsd/Makefile
+++ b/usr/src/cmd/isns/isnsd/Makefile
@@ -23,6 +23,10 @@
# Use is subject to license terms.
#
+#
+# Copyright (c) 2012 by Delphix. All rights reserved.
+#
+
PROG = isns
DSRC = isns_provider.d
@@ -68,14 +72,14 @@ $(PROG): $(OBJS)
$(POST_PROCESS)
%.h: %.d
- $(DTRACE) -xnolibs -h -s $< -o $@
+ $(DTRACE) -h -s $< -o $@
%.o: %.c $(DTRACE_HEADER)
$(COMPILE.c) $<
$(POST_PROCESS_O)
%.o: %.d $(COBJS)
- $(COMPILE.d) -xnolibs -s $< $(COBJS)
+ $(COMPILE.d) -s $< $(COBJS)
$(POST_PROCESS_O)
clean:
diff --git a/usr/src/cmd/itutools/Makefile b/usr/src/cmd/itutools/Makefile
deleted file mode 100644
index e472c7ce34..0000000000
--- a/usr/src/cmd/itutools/Makefile
+++ /dev/null
@@ -1,88 +0,0 @@
-#
-# CDDL HEADER START
-#
-# The contents of this file are subject to the terms of the
-# Common Development and Distribution License (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 2008 Sun Microsystems, Inc. All rights reserved.
-# Use is subject to license terms.
-#
-
-include $(SRC)/Makefile.master
-include $(SRC)/cmd/Makefile.cmd
-
-
-.KEEP_STATE:
-.SUFFIXES: .ksh
-
-
-SCRIPTS = mkbootmedia.ksh
-SCRIPTS += updatemedia.ksh
-SCRIPTS += pkg2du.ksh
-SCRIPTS += itu.ksh
-ROOTUSR= $(ROOT)/usr
-ROOTUSRBIN= $(ROOTUSR)/bin
-
-POFILES= $(SCRIPTS:%.ksh=%.po)
-POFILE= ituutils.po
-PROGS= $(SCRIPTS:%.ksh=%)
-XGETFLAGS= -a
-
-all: $(PROGS) FRC
-
-clean: FRC
- $(RM) $(PROGS) $(POFILE) $(POFILES)
-
-clobber: clean
-
-msg _msg: $(POFILE) FRC
-
-FRC:
-
-
-# Default rule for building ksh scripts.
-.ksh:
- $(RM) $@
- cat $< > $@
- chmod +x $@
-
-# we use the $SRC/Makefile.master sed script to generate the messages catalogs
-$(POFILE): $(POFILES)
- $(RM) $@
- cat $(POFILES) > $@
-
-
-# installation rules
-$(ROOTUSR):
- $(INS.dir)
-
-$(ROOTUSRBIN): $(ROOTUSR)
- $(INS.dir)
-
-$(ROOTUSRBIN)/%: %
- $(INS.file)
-
-install: all \
- $(ROOTUSRBIN)/itu \
- $(ROOTUSRBIN)/mkbootmedia \
- $(ROOTUSRBIN)/updatemedia \
- $(ROOTUSRBIN)/pkg2du
-
-
-include ../Makefile.targ
diff --git a/usr/src/cmd/itutools/itu.ksh b/usr/src/cmd/itutools/itu.ksh
deleted file mode 100644
index 33cea621dd..0000000000
--- a/usr/src/cmd/itutools/itu.ksh
+++ /dev/null
@@ -1,1245 +0,0 @@
-#!/bin/ksh93 -p
-#
-# CDDL HEADER START
-#
-# The contents of this file are subject to the terms of the
-# Common Development and Distribution License (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 2009 Sun Microsystems, Inc. All rights reserved.
-# Use is subject to license terms.
-#
-
-#
-# itu - converts packages to Driver Update format and patches Solaris install
-# media for Install Time Update (ITU).
-#
-
-readonly PROG=$0
-readonly ORIGPWD=$PWD
-
-# Must-have utilities
-readonly CPIO=/usr/bin/cpio
-readonly GZIP=/usr/bin/gzip
-readonly MKISOFS=/usr/bin/mkisofs
-readonly PATCHADD=/usr/sbin/patchadd
-readonly PKGTRANS=/usr/bin/pkgtrans
-readonly PKGADD=/usr/sbin/pkgadd
-readonly LOFIADM=/usr/sbin/lofiadm
-readonly MKDIR=/usr/bin/mkdir
-readonly RM=/usr/bin/rm
-readonly CP=/usr/bin/cp
-readonly HEAD=/usr/bin/head
-readonly SORT=/usr/bin/sort
-readonly MKBOOTMEDIA=/usr/bin/mkbootmedia
-readonly PKG2DU=/usr/bin/pkg2du
-readonly TOUCH=/usr/bin/touch
-readonly NAWK=/usr/bin/nawk
-readonly CHMOD=/usr/bin/chmod
-readonly GREP=/usr/bin/grep
-readonly LS=/usr/bin/ls
-readonly LN=/usr/bin/ln
-readonly SED=/usr/bin/sed
-readonly CAT=/usr/bin/cat
-readonly FIND=/usr/bin/find
-readonly UNAME=/usr/bin/uname
-readonly MACH=`$UNAME -p`
-
-ROOT_ARCHIVE=/usr/sbin/root_archive
-BOOTBLOCK=
-MINIROOT=
-# Relative to a Solaris media root.
-if [ "$MACH" = "sparc" ]; then
- BOOTBLOCK=boot/hsfs.bootblock
- MINIROOT=$MEDIA_ROOT/boot/sparc.miniroot
-else
- # x86/x64
- BOOTBLOCK=boot/grub/stage2_eltorito
- MINIROOT=$MEDIA_ROOT/boot/x86.miniroot
-fi
-
-readonly TMP_DIR=${TMPDIR:-/tmp}/${PROG##*/}.$$
-readonly LOGFILE=${TMPDIR:-/tmp}/${PROG##*/}-log.$$
-
-# Paths we need.
-export PATH=/usr/bin:/usr/sbin:/sbin:/boot/solaris/bin:$PATH
-
-# for gettext
-TEXTDOMAIN=SUNW_OST_OSCMD
-export TEXTDOMAIN
-
-
-function cleanup
-{
- $RM -rf "$TMP_DIR"
-}
-
-
-function usage_long
-{
- usage_short
- print -u2
- usage_options
-}
-
-
-function usage_short
-{
- gettext "Usage:\n"
- gettext "${PROG##*/} makedu -r solaris_release [-v] [-f] [-d output_dir]\n [-o iso_file] [-l iso_label] package [package ...]\n"
- gettext "${PROG##*/} patchmedia -R media_root [-v] [-f]\n [-o iso_file] [-l iso_label] pkg_or_patch [pkg_or_patch ...]\n"
- gettext "${PROG##*/} makeiso -o iso_file [-v] [-f] [-l iso_label] media_root\n"
-}
-
-
-function usage_options {
- gettext "Options:\n"
- gettext " -d output_dir\n Directory where the Driver Update directory should be created.\n"
- gettext " -f\n If output_dir/DU or iso_file already exists, remove it without\n asking first.\n"
- gettext " -l iso_label\n Label/volume name of the ISO image (if -o option is specified).\n"
- gettext " -o iso_file\n Path of ISO image file to create. For
- subcommands patchmedia and\n makeiso this will be a bootable ISO image.\n This option must be specified for subcommand makeiso.\n"
- gettext " -R media_root\n Top-level directory of on-disk image of Solaris installation media.\n This option must be specified for subcommand patchmedia.\n"
- gettext " -r solaris_release\n Solaris release number for which the Driver Update is intended.\n It takes the form of 5.10.\n This option must be specified for subcommand makedu.\n"
- gettext " -v\n Verbose. Multiple -v options increase verbosity.\n"
-
- echo;
-}
-
-
-#
-# Process command line options.
-# Note: since $OPTIND is a local variable inside functions, upon return
-# from this function global variable $MYOPTIND is set to this value.
-#
-function process_options # <arg> ...
-{
- typeset opt optlist
-
- case "$SUBCOMMAND" in
- makedu) optlist='d:fl:o:r:v' ;;
- patchmedia) optlist='fl:o:R:v' ;;
- makeiso) optlist='fl:o:v' ;;
- esac
-
- while getopts ":$optlist" opt
- do
- case $opt in
- d) DU_OUTDIR=$OPTARG
- ;;
- f) FORCE=1
- ;;
- l) ISOLABEL=$OPTARG
- ;;
- o) ISO=$OPTARG
- if [ ! -z `echo $ISO | $GREP "^/tmp"` ]; then
- gettext "ISO images will not be created on /tmp.\n"
- gettext "Please choose a different output location.\n"
- exit 3
- fi
- ;;
- R) MEDIA_ROOT=$OPTARG
- ;;
- r) RELEASE=$OPTARG
- ;;
- v) (( VERBOSE_LEVEL += 1 ))
- VERBOSE_OPTS="${VERBOSE_OPTS:--}$opt" # collect options
- ;;
- :) gettext "Option -$OPTARG missing argument.\n"
- usage_short
- return 1
- ;;
- *) gettext "Option -$OPTARG invalid for $SUBCOMMAND.\n"
- usage_short
- return 1
- ;;
- esac
- done
-
- MYOPTIND=$OPTIND
- return 0
-}
-
-
-#
-# Check some prerequisites
-#
-function check_prereqs
-{
- typeset utils f
-
- # List of must-have utilities depends on subcommand.
- case "$SUBCOMMAND" in
- makedu)
- set -A utils $GZIP ${ISO:+$MKISOFS} $PKGTRANS
- ;;
- patchmedia)
- set -A utils $CPIO $GZIP ${ISO:+$MKISOFS} $PATCHADD \
- $ROOT_ARCHIVE
- ;;
- makeiso)
- set -A utils $MKISOFS
- ;;
- esac
-
- for f in "${utils[@]}"
- do
- if [[ ! -x "$f" ]]
- then
- gettext "Can't find required utility $f.\n"
- return 1
- fi
- done
-
- # Subcommand packmedia uses the "root_archive unpack_media" command
- # which calls lofiadm -a, which requires write access as
- # determined by /dev/lofictl. See lofiadm(1m).
- if [[ $SUBCOMMAND = patchmedia && ! -w /dev/lofictl ]]
- then
- gettext "You don't have enough privileges to run lofiadm -a.\n"
- gettext "See lofiadm(1m) for more information.\n"
- return 1
- fi
-
- return 0
-}
-
-
-#
-# Verifies the given packages and collects them in the PACKAGES array.
-#
-function collect_packages # <arg> ...
-{
- typeset obj
-
- for obj in "$@"
- do
- if [[ ! -e "$obj" ]]
- then
- gettext "Can't find package $obj.\n"
- return 1
- elif [[ ! -f "$obj/pkginfo" ]]
- then
- gettext "$obj is not a package.\n"
- return 1
- fi
- PACKAGES[ ${#PACKAGES[*]} ]=$obj
- done
- return 0
-}
-
-
-#
-# Verifies the given packages and patches. Packages are then collected in
-# the array PACKAGES. Patches are stored in the PATCHES array.
-#
-function collect_packages_patches # <arg> ...
-{
- typeset obj
-
- for obj in "$@"
- do
- if [[ -f "$obj/patchinfo" ]]
- then
- # Collect patches.
- PATCHES[ ${#PATCHES[*]} ]=$obj
- elif [[ -f "$obj/pkginfo" ]]
- then
- # Collect packages.
- PACKAGES[ ${#PACKAGES[*]} ]=$obj
- elif [[ -e "$obj" ]]
- then
- gettext "$obj is not a package or patch.\n"
- return 1
- else
- gettext "$obj does not exist.\n"
- return 1
- fi
- done
- return 0
-}
-
-
-#
-# Ask user whether to overwrite an object, unless -f option was given.
-#
-function is_overwrite
-{
- typeset arg=$1
- typeset -l ans
-
- (( FORCE )) && return 0
- while true
- do
- gettext "$arg already exists. Overwrite it? (y/n) "
- read ans
- case $ans in
- y*|Y*) return 0 ;; # go ahead, overwrite
- n*|N*) return 1 ;; # don't overwrite
- esac
- done
-}
-
-
-#
-# Check the format of the Solaris release number $RELEASE.
-# Also set $VERSION (for DU format) based on $RELEASE.
-#
-function check_release
-{
- # Allow Major.Minor or Major.Minor.Micro format.
- if [[ $RELEASE != +([0-9]).+([0-9])?(.+([0-9])) ]]
- then
- gettext "Invalid release number specified: $RELEASE.\n"
- return 1
- fi
-
- # As defined by the ITU spec, a Solaris release number 5.x corresponds
- # to version number 2x (e.g. 5.10 -> 210). Hopefully, by the time we
- # do a 6.x Release we won't need ITUs any more.
- VERSION=$(echo $RELEASE | $SED 's/5\./2/')
-}
-
-
-#
-# If an ISO file was specified, get realpath of its parent directory ($ISODIR).
-# If the ISO file already exists, ask user to overwrite it, unless -f option
-# was specified.
-#
-function check_iso
-{
- if [[ "$ISO" = */* ]]
- then
- ISODIR=$(cd "${ISO%/*}" 2>/dev/null && pwd -P)
- if (( $? ))
- then
- gettext "Can't access parent directory of ISO image.\n"
- return 1
- fi
- else
- ISODIR=$(pwd -P)
- fi
-
- if [[ -f "$ISO" ]]
- then
- is_overwrite "$ISO" || return 2
- $RM -f "$ISO"
- fi
-
- return 0
-}
-
-
-#
-# If specified, check the Driver Update output directory $DU_OUTDIR (-d option).
-# Else set $DU_OUTDIR to a temporary directory. Also if $DU_OUTDIR/DU
-# already exists, ask user whether to overwrite it, unless -f option was given.
-#
-function check_dudir
-{
- typeset realpath
-
- if [[ -z "$DU_OUTDIR" ]]
- then
- DU_OUTDIR=$TMP_DIR/dudir
- return 0
- fi
-
- # Verify user-specified DU output directory.
- if [[ ! -d "$DU_OUTDIR" ]]
- then
- if [ `$MKDIR -p $DU_OUTDIR` ]; then
- gettext "$DU_OUTDIR is not a directory.\n"
- return 1
- fi
- elif [[ ! -w "$DU_OUTDIR" ]]
- then
- gettext "Directory $DU_OUTDIR is not writable.\n"
- return 1
- fi
-
- # If an ISO image path is also specified, make sure it's not under
- # $DU_OUTDIR since we might take the ISO image of $DU_OUTDIR.
- if [[ -n "$ISODIR" ]]
- then
- realpath=$(cd "$DU_OUTDIR" 2>/dev/null && pwd -P)
- if [[ "$ISODIR" = "$realpath"?(/*) ]]
- then
- gettext "ISO image must not be under Driver Update's output directory ($realpath).\n"
- return 1
- fi
- fi
-
- # If the DU directory already exists, ask user permission to
- # remove it unless -f option was given.
- if [[ -d "$DU_OUTDIR/DU" ]]
- then
- is_overwrite "$DU_OUTDIR/DU" || return 2
- $RM -rf "$DU_OUTDIR/DU" || return 1
- fi
-
- return 0
-}
-
-
-#
-# Verify $MEDIA_ROOT is indeed a Solaris install media.
-#
-function check_media_root
-{
- if [[ ! -d $(echo "$MEDIA_ROOT"/Solaris*/Tools/Boot) ]]
- then
- gettext "$MEDIA_ROOT is not a Solaris install media.\n"
- return 1
- fi
- return 0
-}
-
-
-#
-# Verify there's a miniroot file under $MEDIA_ROOT. Also set $MINIROOT
-# to the path of the miniroot.
-#
-function check_miniroot
-{
- MINIROOT=$MEDIA_ROOT/boot/x86.miniroot
- if [[ ! -f "$MINIROOT" ]]
- then
- return 0
- fi
- MINIROOT=$MEDIA_ROOT/boot/sparc.miniroot
- if [[ ! -f "$MINIROOT" ]]
- then
- return 0
- fi
- gettext "Can't find $MEDIA_ROOT/boot/x86.miniroot or $MEDIA_ROOT/boot/sparc.miniroot.\n"
- return 1
-}
-
-
-#
-# Create a non-bootable ISO image of the given directory.
-#
-function create_nonboot_iso # <dir>
-{
- typeset dir vflag i
-
- if (( $# != 1 ))
- then
- gettext "create_nonboot_iso missing argument.\n"
- return 1
- fi
- dir=$1
-
- # Skip if no ISO image was specified.
- [[ -z "$ISO" ]] && return 0
-
- # Determine mkisofs' verbose flag depending on $VERBOSE_LEVEL.
- case $VERBOSE_LEVEL in
- 0) vflag=-quiet
- ;;
- 1) vflag= # mkisofs' default verboseness
- ;;
- *) vflag=
- i=$VERBOSE_LEVEL
- while ((i > 0))
- do
- vflag="-v $vflag"
- (( i -= 1 ))
- done
- ;;
- esac
-
- print "Creating ISO image ..."
-
- # Note: the "-log-file >(cat -u >&2)" and "2>/dev/null" below is a
- # trick to filter out mkisofs's warning message about being
- # non-conforming to ISO-9660.
- # We do some funky architecture-specific stuff here so that we can
- # actually create a bootable media image for UltraSPARC systems
-
- sparc_ISOARGS="-B ... -joliet-long -U"
- i386_ISOARGS="-d -N -r -relaxed-filenames"
- if [[ "$MACH" = "i386" ]]
- then
- ISOARGS=$i386_ISOARGS
- else
- ISOARGS=$sparc_ISOARGS
- fi
-
- $MKISOFS -o "$ISO" \
- -allow-leading-dots \
- $ISOARGS \
- -l -ldots \
- -R -J \
- -V "$ISOLABEL" \
- $vflag \
- -log-file >(cat -u >&2) \
- "$dir" 2>/dev/null
-}
-
-
-#
-# Create a bootable Solaris ISO image of the given Solaris install directory.
-#
-function create_bootable_iso # <dir>
-{
- typeset dir vflag saved i
-
- if (( $# != 1 ))
- then
- gettext "create_bootable_iso missing argument.\n"
- return 1
- fi
- dir=$1
-
- # Skip if no ISO image was specified.
- [[ -z "$ISO" ]] && return 0
-
- # Determine mkisofs' verbose flag depending on $VERBOSE_LEVEL.
- case $VERBOSE_LEVEL in
- 0) vflag=-quiet
- ;;
- 1) vflag= # mkisofs' default verboseness
- ;;
- *) vflag=
- i=$VERBOSE_LEVEL
- while ((i > 0))
- do
- vflag="-v $vflag"
- (( i -= 1 ))
- done
- ;;
- esac
-
- # Verify the boot block exists under media root. If it does,
- # verify it's writable since it will be modified with some boot
- # information by mkisofs' -boot-info-table option.
- if [[ ! -f "$dir/$BOOTBLOCK" ]]
- then
- gettext "Can't find $dir/$BOOTBLOCK.\n"
- return 1
- elif [[ ! -w "$dir/$BOOTBLOCK" ]]
- then
- gettext "$dir/$BOOTBLOCK is not writable.\n"
- return 1
- fi
-
- gettext "Creating bootable ISO image ..."
-
- # Since mkisofs below will modify the file $BOOTBLOCK in-place, save
- # a copy of it first.
- saved=$TMP_DIR/${BOOTBLOCK##*/}
- $CP -f "$dir/$BOOTBLOCK" "$saved" || return
-
- # Note: the "-log-file >(cat -u >&2)" and "2>/dev/null" below is a
- # trick to filter out mkisofs's warning message about being
- # non-conforming to ISO-9660.
- # We do some funky architecture-specific stuff here so that we can
- # actually create a bootable media image for UltraSPARC systems
- sparc_ISOARGS="-G $BOOTBLOCK -B ... -joliet-long -U"
- i386_ISOARGS="-b boot/grub/stage2_eltorito -boot-info-table "
- i386_ISOARGS="$i386_ISOARGS -boot-load-size 4 -c .catalog -d -N "
- i386_ISOARGS="$i386_ISOARGS -no-emul-boot -r -relaxed-filenames"
- if [[ "$MACH" = "i386" ]]
- then
- ISOARGS=$i386_ISOARGS
- else
- ISOARGS=$sparc_ISOARGS
- fi
-
- cd $dir
- $MKISOFS -o "$ISO" \
- -allow-leading-dots \
- $ISOARGS \
- -l -ldots \
- -R -J \
- -V "$ISOLABEL" \
- $vflag \
- -log-file >(cat -u >&2) \
- "$dir" 2>/dev/null
- i=$?
-
- # Restore saved El Torito file
- $CP -f "$saved" "$dir/$ELTORITO" 2>/dev/null
-
- return $i
-}
-
-
-#
-# Create a Driver Update (DU) format directory from packages
-#
-function create_du
-{
- typeset distdir tmpdudir pkgs obj statusfile
-
- # Create DU directory first.
- distdir=$DU_OUTDIR/DU/sol_$VERSION/$MACH
- $MKDIR -p "$distdir/Tools" "$distdir/Product"
-
- echo "start create DU with MACH $MACH"
-
- # If we're running this script on sun4[vu], then create a symlink
- # to the other UltraSPARC architecture
- if [[ "$MACH" != "i386" ]]
- then
- cd $DU_OUTDIR/DU/sol_$VERSION
- $LN -s sparc sun4v
- $LN -s sparc sun4u
- else
- cd $DU_OUTDIR/DU/sol_$VERSION
- $LN -s i386 i86pc
- fi
-
- # Unfortunately pkgtrans insists that all packages must be in
- # <device1> (see pkgtrans(1)). The packages can't have any path
- # components. So we'll create a temporary directory first and then
- # symlinks to the specified packages. Then run pkgtrans with
- # the temporary directory as <device1>.
- tmpdudir=$TMP_DIR/create_du
- $RM -rf "$tmpdudir"
- $MKDIR -p "$tmpdudir"
-
- for obj in "${PACKAGES[@]}"
- do
- # Get rid of trailing /'s, if any.
- [[ "$obj" == */ ]] && obj=${obj%%+(/)}
-
- # Make sure it's full pathname.
- [[ "$obj" != /* ]] && obj=$ORIGPWD/$obj
-
- ln -s "$obj" "$tmpdudir" || return
-
- # Remember just the file component.
- pkgs[ ${#pkgs[*]} ]=${obj##*/}
- done
-
- # Package up packages as compressed data stream.
- statusfile=$TMP_DIR/.pkgtrans.status
- (
- # Use fd 9 for redirecting pkgtrans' "Transferring..."
- # messages which normally go to stderr to current stdout
- # (not the following pipeline's stdout).
- exec 9>&1
- {
- $PKGTRANS -s "$tmpdudir" /dev/stdout "${pkgs[@]}" 2>&9
- echo $? > $statusfile
- $TOUCH $statusfile # make sure file is created
- } | $GZIP -9 > "$distdir/Product/pkgs.gz"
- )
-
- [[ -s $statusfile && $(<$statusfile) != 0 ]] && return 1
-
- # Create admin file for pkgadd
- $CAT > "$distdir/Tools/admin" <<"EOF"
-mail=
-instance=overwrite
-partial=nocheck
-runlevel=nocheck
-idepend=nocheck
-rdepend=nocheck
-space=nocheck
-setuid=nocheck
-conflict=nocheck
-action=nocheck
-EOF
-
- # Create install.sh
- $CAT > "$distdir/Tools/install.sh" <<"EOF"
-#!/sbin/sh
-# install.sh -R <basedir> - install packages to basedir
-basedir=/
-toolsdir=`dirname $0`
-tmpfile=/tmp/`basename $0`.$$
-gzip=/usr/bin/gzip
-while getopts "R:" arg
-do
- case "$arg" in
- R) basedir=$OPTARG;;
- esac
-done
-
-# /etc/driver_aliases ,/etc/driver_classes
-# /etc/name_to_major /etc/minor_perm
-# The four file can't append due to ACL defect.
-# workaround this by mv and cp
-
-/usr/bin/touch /etc/driver_aliases
-if [ $? -ne 0 ] ; then
- /bin/cp /etc/driver_aliases /tmp/driver_aliases
- /bin/mv /etc/driver_aliases /tmp/driver_aliases.bak
- /bin/mv /tmp/driver_aliases /etc
-fi
-/usr/bin/touch /etc/driver_classes
-if [ $? -ne 0 ] ; then
- /bin/cp /etc/driver_classes /tmp/driver_classes
- /bin/mv /etc/driver_classes /tmp/driver_classes.bak
- /bin/mv /tmp/driver_classes /etc
-fi
-/usr/bin/touch /etc/name_to_major
-if [ $? -ne 0 ] ; then
- /bin/cp /etc/name_to_major /tmp/name_to_major
- /bin/mv /etc/name_to_major /tmp/name_to_major.bak
- /bin/mv /tmp/name_to_major /etc
-fi
-/usr/bin/touch /etc/minor_perm
-if [ $? -ne 0 ] ; then
- /bin/cp /etc/minor_perm /tmp/minor_perm
- /bin/mv /etc/minor_perm /tmp/minor_perm.bak
- /bin/mv /tmp/minor_perm /etc
-fi
-
-# Make sure that we've got our own copy of /usr/bin/gzip
-# in the tools directory
-
-if [ ! -f $gzip ] ; then
- gzip=$toolsdir/gzip
- /usr/bin/chmod a+x "$toolsdir/gzip" 2>/dev/null
-fi
-
-$gzip -c -d "$toolsdir/../Product/pkgs.gz" > $tmpfile &&
- /usr/sbin/pkgadd -R "$basedir" -d "$tmpfile" -a "$toolsdir/admin" all
-status=$?
-rm -f "$tmpfile"
-exit $status
-EOF
- $CHMOD a+rx "$distdir/Tools/install.sh"
-
- $CP -f /usr/bin/gzip "$distdir/Tools" 2>/dev/null
-}
-
-
-#
-# Unpack the miniroot of a Solaris install media.
-#
-function unpack_media
-{
- # Create temp directory to unpack the miniroot.
- $MKDIR -p "$UNPACKED_ROOT"
-
- # We need to use the unpackmedia option to correctly apply patches
- gettext "Unpacking media ... "
- $ROOT_ARCHIVE unpackmedia "$MEDIA_ROOT" "$UNPACKED_ROOT" > /dev/null 2>&1
- if [ $? != 0 ]; then
- if [ -d $MEDIA_ROOT/Solaris_10 -a -d $MEDIA_ROOT/Solaris_11 ]; then
- # we _do_ care, because we're not patching a Solaris
- # update media instance
- gettext "There was an error unpacking the media from $MEDIA_ROOT\n"
- exit 1
- fi
- fi
-}
-
-
-#
-# Pack an unpacked miniroot onto a Solaris install media.
-#
-function repack_media
-{
- gettext "Repacking media ..."
-
- # We need to ensure that we're using the appropriate version
- # of root_archive for the media that we're packing/unpacking.
- # The onnv version of root_archive differs from the S10 version,
- # and this will cause problems on re-packing. So we sneakily
- # use the version that we've just unpacked
- if [ -d $MEDIA_ROOT/Solaris_10 ]; then
- ROOT_ARCHIVE=$UNPACKED_ROOT/boot/solaris/bin/root_archive
- fi
-
- $ROOT_ARCHIVE packmedia "$MEDIA_ROOT" "$UNPACKED_ROOT" > /dev/null 2>&1
- if [ $? != 0 ]; then
- if [ -d $MEDIA_ROOT/Solaris_10 -a -d $MEDIA_ROOT/Solaris_11 ]; then
- # we _do_ care, because we're not patching a Solaris
- # update media instance
- gettext "There was an error packing the media from $MEDIA_ROOT\n"
- exit 1
- fi
- fi
- gettext "Done.\n"
-}
-
-
-#
-# Add packages to a Solaris install media. Also install these packages
-# onto the miniroot.
-#
-function add_pkgs
-{
- typeset icmd statusfile i
-
- (( ${#PACKAGES[*]} == 0 )) && return
-
- statusfile=$TMP_DIR/.add_pkgs.status
-
- DU_OUTDIR=$ITUDIR/$ITU_COUNTDIR
- (( ITU_COUNTDIR += 1 ))
- $MKDIR "$DU_OUTDIR" || return
-
- #
- # Add a Driver Update directory on the media
- #
- echo;
- gettext "Adding package(s) to media root.\n"
- create_du || return
-
- #
- # Using the Driver Update above install the packages onto the miniroot.
- #
- echo;
- gettext "Installing package(s) onto miniroot.\n"
- icmd=$DU_OUTDIR/DU/sol_$VERSION/$MACH/Tools/install.sh
- if [[ ! -f "$icmd" ]]
- then
- # This shouldn't happen, but just in case.
- gettext "Cannot find $icmd.\n"
- return 1
- fi
- [[ ! -x "$icmd" ]] && chmod a+x "$icmd"
-
- $RM -f "$statusfile"
- {
- "$icmd" -R "$UNPACKED_ROOT"
- if (( i=$? ))
- then
- echo $i > "$statusfile"
- $TOUCH "$statusfile" # make sure file is created
- fi
- } 2>&1 | $NAWK -v logfile="$LOGFILE" -v vlevel=$VERBOSE_LEVEL '
- # If not verbose, print certain lines from patchadd.
- (vlevel == 0) && /^Installing/ {print}
- (vlevel == 0) && /^Installation.*successful/ {print}
-
- # If verbose, print every line to stderr.
- (vlevel > 0) {print > "/dev/stderr"}
-
- # Save every line to logfile.
- {print >> logfile}
- ' || return
- [[ -s "$statusfile" ]] && return $(<$statusfile)
- return 0
-}
-
-
-#
-# Add patches to a Solaris install media. Also patch the miniroot with
-# these patches
-#
-function add_patches
-{
- typeset distdir tmpdir icmd obj patches statusfile
-
- (( ${#PATCHES[*]} == 0 )) && return
-
- tmpdir=$TMP_DIR/patches
- statusfile=$TMP_DIR/.add_patches.status
-
- $RM -rf "$tmpdir"
-
- distdir=$ITUDIR/$ITU_COUNTDIR/DU/sol_$VERSION/$MACH
- (( ITU_COUNTDIR += 1 ))
-
- $MKDIR -p "$distdir/Tools" "$distdir/Product" "$tmpdir" || return
-
- # If we're running this script on sun4[vu], then create a symlink
- # to the other UltraSPARC architecture
- if [[ "$MACH" != "i386" ]]
- then
- cd $ITUDIR/$ITU_COUNTDIR/DU/sol_$VERSION
- $LN -s sparc sun4v
- $LN -s sparc sun4u
- else
- cd $ITUDIR/$ITU_COUNTDIR/DU/sol_$VERSION
- $LN -s i386 i86pc
- fi
-
- #
- # Add packages onto media root
- #
- echo;
- gettext "Adding patch(es) to media root.\n"
-
- # Symlink each patch in a temp dir so a single cpio/gzip can work.
- for obj in "${PATCHES[@]}"
- do
- # Get rid of trailing /'s, if any.
- [[ "$obj" == */ ]] && obj=${obj%%+(/)}
-
- # Make sure it's a full pathname.
- [[ "$obj" != /* ]] && obj=$ORIGPWD/$obj
-
- $LN -s "$obj" "$tmpdir" || return
-
- # Remember just the file component.
- patches[ ${#patches[*]} ]=${obj##*/}
- done
-
- # Package up patches as compressed cpio archive.
- $RM -f "$statusfile"
- (
- # Save current stdout as fd 8. This doesn't point to the
- # gzip pipeline below.
- exec 8>&1
-
- {
- # Fd 9 is used later on for filtering out cpio's
- # reporting total blocks to stderr but yet still
- # print other error messages. fd 9 refers to the
- # pipeline to gzip.
- exec 9>&1
-
- cd "$tmpdir"
- for obj in "${patches[@]}"
- do
- print -u8 "Transferring patch $obj."
- $FIND "$obj/." -follow -print
- if (( i=$? ))
- then
- echo $i > "$statusfile"
- $TOUCH "$statusfile"
- return $i
- fi
- done | $CPIO -oc 2>&1 >&9 | $GREP -v '^[0-9]* blocks' >&2
- } | $GZIP -9 > "$distdir/Product/patches.gz"
- ) || return
-
- [[ -s "$statusfile" ]] && return $(<$statusfile)
-
- # Create install.sh
- $CAT > "$distdir/Tools/install.sh" <<"EOF"
-#!/sbin/sh
-# install.sh -R <basedir> - install patches to basedir
-basedir=/
-toolsdir=`dirname $0`
-tmpdir=/tmp/`basename $0`.$$
-gzip=/usr/bin/gzip
-trap "/bin/rm -rf $tmpdir" 0
-while getopts "R:" arg
-do
- case "$arg" in
- R) basedir=$OPTARG;;
- esac
-done
-/bin/mkdir -p "$tmpdir" || exit
-tmpfile=$tmpdir/patches
-patchdir=$tmpdir/patchdir
-/bin/mkdir "$patchdir" || exit
-
-# Make sure that we've got our own copy of /usr/bin/gzip
-# in the tools directory
-
-if [ ! -f $gzip ] ; then
- gzip=$toolsdir/gzip
- /usr/bin/chmod a+x "$toolsdir/gzip" 2>/dev/null
-fi
-
-$gzip -c -d "$toolsdir/../Product/patches.gz" > $tmpfile || exit
-cd "$patchdir"
-/bin/cpio -idum < "$tmpfile" || exit
-patchadd -R "$basedir" -nu *
-EOF
- $CHMOD a+rx "$distdir/Tools/install.sh"
-
- $CP -f /usr/bin/gzip "$distdir/Tools" 2>/dev/null
-
- #
- # Patch the miniroot
- #
- echo;
- gettext "Installing patch(es) onto miniroot.\n"
- $RM -f "$statusfile"
- {
- $PATCHADD -udn -C "$UNPACKED_ROOT" "${PATCHES[@]}"
- if (( i=$? ))
- then
- echo $i > "$statusfile"
- $TOUCH "$statusfile" # make sure file is created
- fi
- } 2>&1 | $NAWK -v logfile="$LOGFILE" -v vlevel=$VERBOSE_LEVEL '
- # If not verbose, print certain lines from patchadd.
- (vlevel == 0) && /^Patch.*successful/ {print}
-
- # If verbose, print every line to stderr.
- (vlevel > 0) {print > "/dev/stderr"}
-
- # Save every line to logfile.
- {print >> logfile}
- ' || return
-
- [[ -s "$statusfile" ]] && return $(<$statusfile)
-
- # Remove patch log files to save space when miniroot is repacked.
- $RM -rf "$UNPACKED_ROOT"/var/sadm/patch
-}
-
-
-#
-# Starting point for makedu subcommand:
-#
-# Convert packages into Driver Update (DU) directory format.
-#
-function makedu # <arg> ...
-{
- typeset i
-
- process_options "$@" || return
- shift 'MYOPTIND - 1'
-
- if (( $# == 0 ))
- then
- gettext "Please specify one or more packages.\n"
- usage_short
- return 1
- fi
-
- # Release number must be specified.
- if [[ -z "$RELEASE" ]]
- then
- gettext "Please specify Solaris release number (-r option).\n"
- usage_short
- return 1
- fi
- check_release || return
-
- # Either -d or -o option, or both, must be specified.
- if [[ -z "$DU_OUTDIR" && -z "$ISO" ]]
- then
- gettext "Please specify either -d or -o option (or both).\n"
- usage_short
- return 1
- fi
-
- if [[ -n "$ISO" ]]
- then
- check_iso || return
- ${ISOLABEL:=DU sol_$VERSION} 2>/dev/null # default ISO label
- fi
- check_dudir || return # should be called after check_iso
-
- # Rest of arguments must be packages.
- collect_packages "$@" || return
-
- check_prereqs || return
-
- # Create DU and the (non-bootable) ISO image (if requested).
- create_du && create_nonboot_iso "$DU_OUTDIR"
- if (( i=$? ))
- then
- $RM -rf "$DU_OUTDIR/DU"
- [[ -n "$ISO" ]] && rm -f "$ISO"
- else
- if [[ "$MACH" != "i386" ]]
- then
- echo "This DU must be written as either an ISO (hsfs)"
- echo "or a *ufs* filesystem. DO NOT USE pcfs!"
- fi
- fi
- return $i
-}
-
-
-#
-# Starting point for patchmedia subcommand:
-#
-# Patch a Solaris install image with the given packages and patches.
-#
-function patchmedia # <arg> ...
-{
- typeset soldir
-
- process_options "$@" || return
- shift 'MYOPTIND - 1'
-
- if (( $# == 0 ))
- then
- gettext "Please specify one or more packages or patches.\n"
- usage_short
- return 1
- fi
-
- # -R option must be specified
- if [[ -z "$MEDIA_ROOT" ]]
- then
- gettext "Please specify Solaris media root (-R option).\n"
- usage_short
- return 1
- fi
- check_media_root || return
-
- # Get the Solaris directory under $MEDIA_ROOT.
- soldir=$($LS -d $MEDIA_ROOT/Solaris* 2>/dev/null)
- if [[ -z "$soldir" ]]
- then
- gettext "Can't find Solaris directory in $MEDIA_ROOT.\n"
- return 1
- fi
-
- # Extract the Solaris release number from the Solaris_* directory.
- RELEASE=5.${soldir##*Solaris_}
- check_release || return
-
- # If user specifies an ISO image to create.
- if [[ -n "$ISO" ]]
- then
- check_iso || return
- ${ISOLABEL:=${soldir##*/}} # default ISO label
- fi
-
- # Rest of arguments must be packages or patches.
- collect_packages_patches "$@" || return
-
- # Verify we have some important utilities we need.
- check_prereqs || return
-
- # Verify there's miniroot file in $MEDIA_ROOT.
- check_miniroot || return
-
- # Create the ITU directory on the media root, if necessary
- ITUDIR=$MEDIA_ROOT/ITUs
- $MKDIR -p "$ITUDIR" || return
-
- # The ITU directory might contain multiple driver updates already,
- # each in a separate numbered subdirectory. So look for the
- # subdirectory with the highest number and we'll add the packages
- # and patches on the next one.
- ITU_COUNTDIR=$($LS -d "$ITUDIR"/+([0-9]) 2>/dev/null |
- $SED 's;.*/;;' | $SORT -rn | $HEAD -1)
- if [[ $ITU_COUNTDIR == *( ) ]] # ITU_COUNTDIR is a typeset -Zn var
- then
- ITU_COUNTDIR=0
- else
- (( ITU_COUNTDIR += 1 ))
- fi
-
- unpack_media || return
- add_pkgs && add_patches
- if (( status=$? )) && [[ -s "$LOGFILE" ]]
- then
- echo;
- gettext "A package or patch installation has failed.\n"
- gettext "Messages from pkgadd and patchadd have been saved in $LOGFILE\n"
- return $status
- else
- rm -f "$LOGFILE"
- fi
- print
- repack_media || return
- create_bootable_iso "$MEDIA_ROOT"
- gettext "$MEDIA_ROOT has been successfully patched\n"
-}
-
-
-#
-# Starting point for makeiso subcommand:
-#
-# Create a bootable ISO image of a Solaris install image.
-#
-function makeiso # <arg> ..
-{
- process_options "$@" || return
- shift 'MYOPTIND - 1'
-
- if (( $# == 0 ))
- then
- gettext "Please specify the Solaris media root.\n"
- usage_short
- return 1
- elif (( $# > 1 ))
- then
- gettext "Too many arguments supplied.\n"
- usage_short
- return 1
- fi
- MEDIA_ROOT=$1
- check_media_root || return
-
- # ISO image must be specified.
- if [[ -z "$ISO" ]]
- then
- gettext "Please specify ISO image file (-o option).\n"
- usage_short
- return 1
- fi
- check_iso || return
-
- # If user doesn't specify ISO label, use the Solaris_* directory name
- # under $MEDIA_ROOT.
- if [[ -z "$ISOLABEL" ]]
- then
- ISOLABEL=$(echo "$MEDIA_ROOT"/Solaris*)
- ISOLABEL=${ISOLABEL##*/}
- fi
-
- check_prereqs || return
- create_bootable_iso "$MEDIA_ROOT"
-}
-
-
-#
-# Main
-#
-trap cleanup EXIT
-
-# Numbered subdirectories under ITU directory $ITUDIR.
-typeset -Z3 ITU_COUNTDIR=0
-
-# Where to unpack a miniroot.
-UNPACKED_ROOT=${TMP_DIR}/miniroot
-
-# Reset arrays.
-unset PACKAGES PATCHES
-
-DU_OUTDIR=
-FORCE=0
-ISO=
-ISOLABEL=
-MEDIA_ROOT=
-RELEASE=
-SUBCOMMAND=
-VERBOSE_LEVEL=0
-VERBOSE_OPTS=
-
-if (( $# == 0 ))
-then
- usage_long
- return 1
-fi
-typeset -l SUBCOMMAND=$1 # ignore case
-shift
-
-if [[ $SUBCOMMAND != @(makedu|patchmedia|makeiso) ]]
-then
- # Be nice: allow some subcommands that cry out "help".
- case "$SUBCOMMAND" in
- *(-)help|*(-)usage|-h|-\?)
- usage_long
- return 0
- ;;
- *)
- gettext "Invalid subcommand: $SUBCOMMAND.\n"
- usage_short
- return 1
- ;;
- esac
-fi
-
-$MKDIR -p "$TMP_DIR" || return
-$RM -f "$LOGFILE"
-
-# Run the subcommand.
-$SUBCOMMAND "$@"
diff --git a/usr/src/cmd/itutools/mkbootmedia.ksh b/usr/src/cmd/itutools/mkbootmedia.ksh
deleted file mode 100644
index 344d82dc60..0000000000
--- a/usr/src/cmd/itutools/mkbootmedia.ksh
+++ /dev/null
@@ -1,192 +0,0 @@
-#!/bin/ksh93 -p
-#
-# CDDL HEADER START
-#
-# The contents of this file are subject to the terms of the
-# Common Development and Distribution License (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 2009 Sun Microsystems, Inc. All rights reserved.
-# Use is subject to license terms.
-#
-
-#
-# mkbootmedia - create bootable Solaris ISO image
-#
-
-readonly PROG=$0
-MKISOFS=/usr/bin/mkisofs
-ELTORITO=boot/grub/stage2_eltorito # relative to $MEDIA_ROOT
-SPARCBOOT=boot/hsfs.bootblock
-CAT=/usr/bin/cat
-CP=/usr/bin/cp
-RM=/usr/bin/rm
-UNAME=/usr/bin/uname
-MACH=`$UNAME -p`
-BOOTBLOCK=
-GREP=/usr/bin/grep
-
-# for gettext
-TEXTDOMAIN=SUNW_OST_OSCMD
-export TEXTDOMAIN
-
-
-function usage
-{
- gettext "Usage:\n${PROG##*/} [-v] [-l <label>] <media-root> <iso>\n"
- gettext "Options:\n -l <label>\n Label/volume name of the ISO image.\n"
- gettext " -v\n Verbose. Multiple -v options increase verbosity.\n"
- echo;
-}
-
-
-#
-# Main
-#
-LABEL=
-VERBOSITY=0
-
-while getopts ':l:v' opt
-do
- case $opt in
- l) LABEL=$OPTARG
- ;;
- v) (( VERBOSITY += 1 ))
- ;;
- :) gettext "Option -$OPTARG missing argument.\n"
- usage
- exit 1
- ;;
- *) gettext "Option -$OPTARG invalid.\n"
- usage
- exit 2
- ;;
- esac
-done
-shift 'OPTIND - 1'
-
-if (( $# != 2 ))
-then
- usage
- exit 1
-fi
-
-MEDIA_ROOT=$1
-ISOIMAGE=$2
-
-if [ ! -z `echo $ISOIMAGE | $GREP "^/tmp"` ]; then
- gettext "ISO images will not be created on /tmp.\nPlease choose a different output location.\n"
- exit 3
-fi
-
-# Verify $MEDIA_ROOT is a Solaris install media (Solaris 10 Update 1 or later)
-if [[ ! -d $(echo "$MEDIA_ROOT"/Solaris*/Tools/Boot) ]]; then
- gettext "$MEDIA_ROOT is not Solaris install media.\n"
- exit 1
-fi
-
-# If no label specified use the Solaris_* version under $MEDIA_ROOT
-if [[ -z "$LABEL" ]]; then
- LABEL=$(echo "$MEDIA_ROOT"/Solaris*)
- LABEL=${LABEL##*/}
-fi
-
-# If $ISOIMAGE exists, verify it's writable.
-if [[ -e "$ISOIMAGE" && ! -w "$ISOIMAGE" ]]; then
- gettext "$ISOIMAGE exists but is not writable.\n"
- exit 1
-fi
-
-# If we're on an x86/x64 system, we need to have the El Torito file
-# modified with some boot information (-boot-info-table option).
-# If the image isn't writable, we can't continue
-# UltraSPARC systems (sun4u, sun4v etc) don't use El Torito
-if [[ "$MACH" = "i386" && ! -w "$MEDIA_ROOT/$ELTORITO" ]]; then
- gettext "$MEDIA_ROOT/$ELTORITO is not writable.\n"
- exit 1
-fi
-
-# Check that we've got mkisofs installed
-if [[ ! -f "$MKISOFS" || ! -x "$MKISOFS" ]]; then
- gettext "Cannot find $f\n"
- exit 1
-fi
-
-
-# Determine mkisofs' verbose flag depending on $VERBOSITY.
-case $VERBOSITY in
-0) VERBOSE_FLAG=-quiet
- ;;
-1) VERBOSE_FLAG= # mkisofs' default verboseness
- ;;
-*) VERBOSE_FLAG=
- i=$VERBOSITY
- while ((i > 0))
- do
- VERBOSE_FLAG="-v $VERBOSE_FLAG"
- (( i -= 1 ))
- done
- ;;
-esac
-
-# Since mkisofs below will modify the file $ELTORITO in-place, save a copy
-# of it first. Use trap to restore it when this script exits (including
-# when user hits control-C).
-
-if [[ "$MACH" = "i386" ]]
-then
- BOOTBLOCK=$MEDIA_ROOT/$ELTORITO
- ELTORITO_SAVE=/tmp/${ELTORITO##*/}.$$
- $CP "$MEDIA_ROOT/$ELTORITO" "$ELTORITO_SAVE" || exit 1
- trap '"$CP" "$ELTORITO_SAVE" "$MEDIA_ROOT/$ELTORITO" 2>/dev/null;
- "$RM" -f "$ELTORITO_SAVE"' EXIT
-else
- # sun4u/sun4u1/sun4v et al
- BOOTBLOCK=$MEDIA_ROOT/$SPARCBOOT
- SPARCBOOT_SAVE=/tmp/hsfs.bootblock.$$
- $CP "$MEDIA_ROOT/$SPARCBOOT" "$SPARCBOOT_SAVE" || exit 1
- trap '"$CP" "$MEDIA_ROOT/$SPARCBOOT" "$SPARCBOOT_SAVE" 2>/dev/null;
- "$RM" -f $SPARCBOOT_SAVE"' EXIT
-fi
-
-# Call mkisofs to do the actual work.
-# Note: the "-log-file >(cat -u >&2)" and "2>/dev/null" below is a trick
-# to filter out mkisofs's warning message about being non-conforming
-# to ISO-9660.
-# We do some funky architecture-specific stuff here so that we can
-# actually create a bootable media image for UltraSPARC systems
-
-sparc_ISOARGS="-G $BOOTBLOCK -B ... -joliet-long -R -U"
-i386_ISOARGS="-b boot/grub/stage2_eltorito -boot-info-table "
-i386_ISOARGS="$i386_ISOARGS -boot-load-size 4 -c .catalog -d -N "
-i386_ISOARGS="$i386_ISOARGS -no-emul-boot -r -relaxed-filenames"
-if [[ "$MACH" = "i386" ]]
-then
- ISOARGS=$i386_ISOARGS
-else
- ISOARGS=$sparc_ISOARGS
-fi
-
-$MKISOFS -o "$ISOIMAGE" \
- -allow-leading-dots \
- $ISOARGS \
- -l -ldots \
- -R -J \
- -V "$ISOLABEL" \
- $VERBOSE_FLAG \
- -log-file >($CAT -u >&2) \
- "$MEDIA_ROOT" 2>/dev/null
diff --git a/usr/src/cmd/itutools/pkg2du.ksh b/usr/src/cmd/itutools/pkg2du.ksh
deleted file mode 100644
index eb62ce7108..0000000000
--- a/usr/src/cmd/itutools/pkg2du.ksh
+++ /dev/null
@@ -1,438 +0,0 @@
-#!/bin/ksh93 -p
-#
-#
-# CDDL HEADER START
-#
-# The contents of this file are subject to the terms of the
-# Common Development and Distribution License (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 2009 Sun Microsystems, Inc. All rights reserved.
-# Use is subject to license terms.
-#
-
-#
-# pkg2du - convert driver packages to Driver Update (DU) format
-#
-
-readonly PROG=$0
-readonly ORIGPWD=$PWD
-readonly TMP_DIR=${TMPDIR:-/tmp}/${PROG##*/}.$$
-
-# Must-have utilities
-readonly CPIO=/usr/bin/cpio
-readonly GZIP=/usr/bin/gzip
-readonly MKISOFS=/usr/bin/mkisofs
-readonly PATCHADD=/usr/sbin/patchadd
-readonly PKGTRANS=/usr/bin/pkgtrans
-readonly ROOT_ARCHIVE=/usr/sbin/root_archive
-readonly LOFIADM=/usr/sbin/lofiadm
-readonly MKDIR=/usr/bin/mkdir
-readonly RM=/usr/bin/rm
-readonly CP=/usr/bin/cp
-readonly HEAD=/usr/bin/head
-readonly SORT=/usr/bin/sort
-readonly MKBOOTMEDIA=/usr/bin/mkbootmedia
-readonly PKG2DU=/usr/bin/pkg2du
-readonly TOUCH=/usr/bin/touch
-readonly NAWK=/usr/bin/nawk
-readonly CHMOD=/usr/bin/chmod
-readonly GREP=/usr/bin/grep
-readonly LS=/usr/bin/ls
-readonly LN=/usr/bin/ln
-readonly SED=/usr/bin/sed
-readonly CAT=/usr/bin/cat
-readonly FIND=/usr/bin/find
-readonly UNAME=/usr/bin/uname
-readonly MACH=`$UNAME -p`
-
-# for gettext
-TEXTDOMAIN=SUNW_OST_OSCMD
-export TEXTDOMAIN
-
-
-function usage
-{
- gettext "Usage:\n${PROG##*/} -r <release> [-f] [-v] [-d <dir>] [-o <iso>] [-l <label>]\n <pkg> [<pkg> ...]\n"
- gettext "Options:\n -d <dir>\n Directory where the Driver Update directory should be created.\n"
- gettext " -o <iso>\n Create a Solaris ISO image of the Driver Update directory.\n"
- gettext " -f\n If <dir>/DU or <iso> exists, remove it without asking first.\n"
- gettext " -l <label>\n Label/volume name of the ISO image (if -o option is specified).\n"
- gettext " -r <release>\n Solaris release number to use. It takes the form of 5.10.\n This option must be specified.\n"
- gettext " -v\n Verbose. Multiple -v options increase verbosity.\n"
- echo;
-}
-
-
-function check_prereqs
-{
- typeset f
-
- # We must have these utilities.
- for f in $GZIP ${ISO:+$MKISOFS} $PKGTRANS
- do
- if [[ ! -x "$f" ]]
- then
- gettext "Cannot find required utilty $f"
- exit 1
- fi
- done
-}
-
-
-function cleanup
-{
- $RM -rf "$TMP_DIR"
-}
-
-
-function is_overwrite
-{
- typeset arg=$1
- typeset -l ans
-
- [[ $FORCE == yes ]] && return 0
-
- while true
- do
- gettext "$arg already exists. Overwrite it? (y/n) "
- read ans
- case $ans in
- y*|Y*) return 0 ;; # go ahead overwrite
- n*|N*) return 1 ;; # don't overwrite
- esac
- done
- echo;
-}
-
-
-function collect_objs # <pkg> ...
-{
- typeset obj fail=0
-
- for obj
- do
- if [[ -f "$obj"/pkginfo ]]
- then
- PACKAGES[ ${#PACKAGES[*]} ]=$obj
- else
- gettext "$obj is not in package format\n"
- (( fail += 1 ))
- fi
- done
- (( fail )) && return 1
- return 0
-}
-
-
-function mkdu
-{
- typeset distdir tmpdudir pkgs obj statusfile
-
- trap '/bin/rm -rf $statusfile $tmpdudir' EXIT
-
- # Create DU directory first.
- distdir=$ROOTDIR/DU/sol_$VERSION/$MACH
- $MKDIR -p "$distdir/Tools" "$distdir/Product"
-
- # to the other UltraSPARC architecture
- if [[ "$MACH" != "i386" ]]
- then
- cd $ROOTDIR/DU/sol_$VERSION
- $LN -s sparc sun4v
- $LN -s sparc sun4u
- else
- cd $ROOTDIR/DU/sol_$VERSION
- $LN -s i386 i86pc
- fi
-
- # Unfortunately pkgtrans insists that all packages must be in
- # <device1> (see pkgtrans(1)). The packages can't have any path
- # components. So we'll create a temporary directory first and then
- # symlinks to the specified packages. Then run pkgtrans with
- # the temporary directory as <device1>.
- tmpdudir=$TMP_DIR/mkdu
- $MKDIR -p "$tmpdudir"
-
- for obj in "${PACKAGES[@]}"
- do
- # Get rid of trailing /'s, if any.
- [[ "$obj" == */ ]] && obj=${obj%%+(/)}
-
- # Make sure it's a full pathname.
- [[ "$obj" != /* ]] && obj=$ORIGPWD/$obj
-
- $LN -s "$obj" "$tmpdudir" || exit 1
-
- # Remember just the file component.
- pkgs[ ${#pkgs[*]} ]=${obj##*/}
- done
-
- # Package up packages as compressed data stream.
- statusfile=$TMP_DIR/.pkgtrans.status
- {
- $PKGTRANS -s "$tmpdudir" /dev/stdout "${pkgs[@]}"
- echo $? > $statusfile
- $TOUCH $statusfile # make sure file is created
- } | $GZIP -9 > "$distdir/Product/pkgs.gz"
-
- [[ -s $statusfile && $(<$statusfile) != 0 ]] && return 1
-
- # Create admin file for pkgadd
- $CAT > "$distdir/Tools/admin" <<"EOF"
-mail=
-instance=unique
-partial=nocheck
-runlevel=nocheck
-idepend=nocheck
-rdepend=nocheck
-space=nocheck
-setuid=nocheck
-conflict=nocheck
-action=nocheck
-EOF
-
- # Create install.sh
- $CAT > "$distdir/Tools/install.sh" <<"EOF"
-#!/sbin/sh
-# install.sh -R <basedir> - install packages to basedir
-basedir=/
-toolsdir=`dirname $0`
-tmpfile=/tmp/`basename $0`.$$
-while getopts "R:" arg
-do
- case "$arg" in
- R) basedir=$OPTARG;;
- esac
-done
-/usr/bin/gzip -c -d "$toolsdir/../Product/pkgs.gz" > $tmpfile &&
- /usr/sbin/pkgadd -R "$basedir" -d "$tmpfile" -a "$toolsdir/admin" all
-status=$?
-/bin/rm -f "$tmpfile"
-exit $status
-EOF
- $CHMOD a+rx "$distdir/Tools/install.sh"
-}
-
-
-function mkiso
-{
- typeset vflag
-
- # Skip if no ISO image was specified.
- [[ -z "$ISO" ]] && return 0
-
- # Determine mkisofs' verbose flag depending on $VERBOSE_LEVEL.
- case $VERBOSE_LEVEL in
- 0) vflag=-quiet
- ;;
- 1) vflag= # mkisofs' default verboseness
- ;;
- *) vflag=
- i=$VERBOSE_LEVEL
- while ((i > 0))
- do
- vflag="-v $vflag"
- (( i -= 1 ))
- done
- ;;
- esac
-
- (( VERBOSE_LEVEL )) && gettext "Creating ISO image ..."
-
- # Note: the "-log-file >(cat -u >&2)" and "2>/dev/null" below is a
- # trick to filter out mkisofs's warning message about being
- # non-conforming to ISO-9660.
- # We do some funky architecture-specific stuff here so that we can
- # actually create a bootable media image for UltraSPARC systems
-
- ISOARGS_sparc="-B ... -joliet-long -R -U"
- ISOARGS_i386="-d -N -r -relaxed-filenames"
- if [[ "$MACH" = "i386" ]]
- then
- ISOARGS=$ISOARGS_i386
- else
- ISOARGS=$ISOARGS_sparc
- fi
-
- $MKISOFS -o "$ISO" \
- -allow-leading-dots \
- $ISOARGS \
- -ldots -full-iso9660-filenames \
- -R -J \
- -V "$ISOLABEL" \
- $vflag \
- -log-file >($CAT -u >&2) \
- "$ROOTDIR" 2>/dev/null
-}
-
-
-#
-# Main
-#
-trap cleanup EXIT
-
-FORCE=
-ISO=
-LABEL=
-RELEASE=
-ROOTDIR=
-VERBOSE_LEVEL=0
-
-while getopts ':d:fo:l:r:v' opt
-do
- case $opt in
- d) ROOTDIR=$OPTARG
- ;;
- f) FORCE=yes
- ;;
- o) ISO=$OPTARG
- if [ ! -z `echo $ISO | $GREP "^/tmp"` ]; then
- gettext "ISO images will not be created on /tmp.\n"
- gettext "Please choose a different output location.\n"
- exit 3
- fi
- ;;
- l) LABEL=$OPTARG
- ;;
- r) RELEASE=$OPTARG
- ;;
- v) (( VERBOSE_LEVEL += 1 ))
- ;;
- :) gettext "Option -$OPTARG missing argument."
- usage
- exit 1
- ;;
- *) gettext "Option -$OPTARG invalid.\n"
- usage
- exit 2
- ;;
- esac
-done
-shift 'OPTIND - 1'
-
-# Release number must be specified.
-if [[ -z "$RELEASE" ]]
-then
- gettext "Solaris release number must be specified (-r option).\n"
- usage
- exit 1
-fi
-
-# Verify release number. Allow major.minor or major.minor.micro format.
-if [[ $RELEASE != +([0-9]).+([0-9])?(.+([0-9])) ]]
-then
- gettext "Invalid release number: $RELEASE\n"
- exit 1
-fi
-VERSION=$(echo $RELEASE | $SED 's/5\./2/')
-
-# Either or both of -d or -o option must be specified.
-if [[ -z "$ROOTDIR" && -z "$ISO" ]]
-then
- gettext "Either -d or -o option (or both) must be specified.\n"
- usage
- exit 1
-fi
-
-# There must be at least one package.
-if (( $# == 0 ))
-then
- gettext "No package was specified.\n"
- usage
- exit 1
-fi
-
-# Check and collect packages
-unset PACKAGES
-collect_objs "$@" || exit 1
-
-# Default label for ISO image
-LABEL=${LABEL:-DU sol_$VERSION}
-
-check_prereqs # must be called after $ISO is possibly set
-
-# If an ISO image was specified, check its parent directory and get its
-# full pathname.
-unset ISODIR
-if [[ -n "$ISO" ]]
-then
- if [[ "$ISO" = */* ]]
- then
- ISODIR=$(cd "${ISO%/*}" 2>/dev/null && pwd -P)
- if (( $? ))
- then
- gettext "Can't access parent directory of ISO image\n"
- exit 1
- fi
- else
- ISODIR=$(pwd -P)
- fi
-fi
-
-# If user specified a media root directory, verify it exists, else use
-# a temporary directory.
-if [[ -n "$ROOTDIR" ]]
-then
- $MKDIR -p "$ROOTDIR";
- if [ $? != 0 ]; then
- gettext "$ROOTDIR is not a directory.\n"
- exit 1
- elif [[ ! -w "$ROOTDIR" ]] then
- gettext "Directory $ROOTDIR is not writable.\n"
- exit 1
- fi
- # If an ISO image path is also specified, make sure it's not under
- # $ROOTDIR since we're going to take the ISO image of $ROOTDIR.
- if [[ -n "$ISODIR" ]]
- then
- realroot=$(cd "$ROOTDIR" 2>/dev/null && pwd -P)
- if [[ "$ISODIR" = "$realroot"?(/*) ]]
- then
- gettext "ISO image must not be under Driver Update's parent directory ($realroot)\n"
- exit 1
- fi
- fi
-else
- ROOTDIR=$TMP_DIR/root
-fi
-
-# If DU directory already exists, ask user permission to remove it unless -f
-# option was specified.
-if [[ -d "$ROOTDIR/DU" ]]
-then
- is_overwrite "$ROOTDIR/DU" || exit 0
- $RM -rf "$ROOTDIR/DU"
-fi
-
-# If ISO image already exists, ask user permission to remove it unless -f
-# option was specified.
-if [[ -f "$ISO" ]]
-then
- is_overwrite "$ISO" || exit 0
- $RM -f "$ISO"
-fi
-
-# Create DU directory and the ISO image (if requested).
-mkdu && mkiso
-if (( $? ))
-then
- $RM -rf "$ROOTDIR/DU"
- [[ -n "$ISO" ]] && $RM -f "$ISO"
- exit 1
-fi
-exit 0
diff --git a/usr/src/cmd/itutools/updatemedia.ksh b/usr/src/cmd/itutools/updatemedia.ksh
deleted file mode 100644
index 2b89d7e874..0000000000
--- a/usr/src/cmd/itutools/updatemedia.ksh
+++ /dev/null
@@ -1,478 +0,0 @@
-#!/bin/ksh93 -p
-#
-# CDDL HEADER START
-#
-# The contents of this file are subject to the terms of the
-# Common Development and Distribution License (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 2009 Sun Microsystems, Inc. All rights reserved.
-# Use is subject to license terms.
-#
-
-#
-# updatemedia - modify Solaris media with patches and packages
-#
-
-readonly PROG=$0
-readonly TMP_DIR=${TMPDIR:-/tmp}/${PROG##*/}.$$
-readonly LOGFILE=${TMPDIR:-/tmp}/${PROG##*/}-log.$$
-
-# Must-have utilities
-readonly CPIO=/bin/cpio
-readonly GZIP=/bin/gzip
-readonly MKISOFS=/usr/bin/mkisofs
-readonly PATCHADD=/usr/sbin/patchadd
-readonly LOFIADM=/usr/sbin/lofiadm
-readonly MKDIR=/usr/bin/mkdir
-readonly RM=/usr/bin/rm
-readonly CP=/usr/bin/cp
-readonly MKBOOTMEDIA=/usr/bin/mkbootmedia
-readonly PKG2DU=/usr/bin/pkg2du
-readonly TOUCH=/usr/bin/touch
-readonly NAWK=/usr/bin/nawk
-readonly CHMOD=/usr/bin/chmod
-readonly GREP=/usr/bin/grep
-readonly LS=/usr/bin/ls
-readonly LN=/usr/bin/ln
-readonly SED=/usr/bin/sed
-readonly CAT=/usr/bin/cat
-readonly FIND=/usr/bin/find
-readonly HEAD=/usr/bin/head
-readonly SORT=/usr/bin/sort
-readonly UNAME=/usr/bin/uname
-readonly MACH=`$UNAME -p`
-
-ROOT_ARCHIVE=/usr/sbin/root_archive
-# for gettext
-TEXTDOMAIN=SUNW_OST_OSCMD
-export TEXTDOMAIN
-
-
-function usage
-{
- gettext "Usage:\n${PROG##*/} -d <media-root> [-v] [-l <label>] [-o <iso>]\n <pkg_or_patch> [<pkg_or_patch> ...]\n"
- gettext "Options:\n -d <media-root>\n Top-level directory of on-disk image of Solaris installation media.\n This is option must be specified.\n"
- gettext " -l <label>\n Label/volume name of the ISO image (if -o option is specified).\n"
- gettext " -o <iso>\n Create a Solaris ISO image of <media-root>.\n"
- gettext " -v\n Verbose. Multiple -v options increase verbosity.\n"
-}
-
-
-function check_prereqs
-{
- typeset f
-
- # We must have these utilities.
- for f in $CPIO $GZIP ${ISO:+$MKISOFS} $PATCHADD $ROOT_ARCHIVE
- do
- if [[ ! -x "$f" ]]
- then
- gettext "Cannot find required utility $f\n"
- exit 1
- fi
- done
-
- # root_archive unpack_media calls lofiadm -a, which requires
- # write access as determined by /dev/lofictl. See lofiadm(1m).
- if [[ ! -w /dev/lofictl ]]
- then
- gettext "You do not have enough privileges to run lofiadm -a).\nSee lofiadm(1m) for more information.\n"
- exit 1
- fi
-}
-
-
-function cleanup
-{
- $RM -rf "$TMP_DIR"
-}
-
-
-function unpack_media
-{
- # Create temp directory to unpack the miniroot.
- $MKDIR -p "$UNPACKED_ROOT"
-
- # We need to use the unpackmedia option to correctly apply patches
- gettext "Unpacking media ..."
- $ROOT_ARCHIVE unpackmedia "$MEDIA_ROOT" "$UNPACKED_ROOT" > /dev/null 2>&1
- if [ $? != 0 -a ! -d $MEDIA_ROOT/Solaris_10 ]; then
- # we _do_ care, because we're not patching a Solaris 10
- # update media instance
- gettext "\nThere was an error unpacking the media from $MEDIA_ROOT\n"
- exit 1
- fi
- echo;
-}
-
-
-function repack_media
-{
- gettext "Repacking media ..."
-
- # We need to ensure that we're using the appropriate version
- # of root_archive for the media that we're packing/unpacking.
- # The onnv version of root_archive differs from the S10 version,
- # and this will cause problems on re-packing. So we sneakily
- # use the version that we've just unpacked
- if [ -d $MEDIA_ROOT/Solaris_10 ]; then
- ROOT_ARCHIVE=$UNPACKED_ROOT/boot/solaris/bin/root_archive
- fi
-
- $ROOT_ARCHIVE packmedia "$MEDIA_ROOT" "$UNPACKED_ROOT" > /dev/null 2>&1
- if [ $? != 0 -a ! -d $MEDIA_ROOT/Solaris_10 ]; then
- # we _do_ care, because we're not patching a Solaris 10
- # update media instance
- gettext "\nThere was an error unpacking the media from $MEDIA_ROOT\n"
- exit 1
- fi
- echo;
-}
-
-
-function mkiso
-{
- typeset vflag
-
- # Skip if no ISO image was specified.
- [[ -z "$ISO" ]] && return 0
-
- gettext "Creating ISO image ..."
- $MKBOOTMEDIA $VERBOSE_OPTS -l "$ISOLABEL" "$MEDIA_ROOT" "$ISO"
- echo;
-}
-
-
-function collect_objs # <pkg_or_patch> ...
-{
- typeset obj fail=0
-
- for obj
- do
- if [[ -f "$obj"/patchinfo ]]
- then
- PATCHES[ ${#PATCHES[*]} ]=$obj
- elif [[ -f "$obj"/pkginfo ]]
- then
- PACKAGES[ ${#PACKAGES[*]} ]=$obj
- else
- gettext "$obj is not in package or patch format\n"
- (( fail += 1 ))
- fi
- done
- (( fail )) && return 1
- return 0
-}
-
-
-function add_pkgs
-{
- typeset dudir icmd statusfile
-
- (( ${#PACKAGES[*]} == 0 )) && return
-
- statusfile=$TMP_DIR/.add_pkgs.status
-
- trap '$RM -f $statusfile' EXIT
-
- dudir=$ITUDIR/$COUNTDIR
- (( COUNTDIR += 1 ))
- $MKDIR "$dudir" || return
-
- # Add a Driver Update directory on the media
- echo;
- gettext "Adding package(s) to media root."
- $PKG2DU -r "$RELEASE" -f -d "$dudir" $VERBOSE_OPTS \
- "${PACKAGES[@]}" || return
-
- # Using the Driver Update above install the packages onto the miniroot.
- echo;
- gettext "Installing package(s) onto miniroot."
- icmd=$dudir/DU/sol_$VERSION/$MACH/Tools/install.sh
- if [[ ! -f "$icmd" ]]
- then
- # This shouldn't happen, but just in case.
- gettext "Cannot find $icmd\n"
- return 1
- fi
- [[ ! -x "$icmd" ]] && $CHMOD a+x "$icmd"
-
- $RM -f "$statusfile"
- {
- "$icmd" -R "$UNPACKED_ROOT"
- if (( i=$? ))
- then
- echo $i > "$statusfile"
- $TOUCH "$statusfile" # make sure file is created
- fi
- } 2>&1 | $NAWK -v logfile="$LOGFILE" '
- # Print certain lines from $icmd, save all in logfile.
- /^Installing/ {print}
- /^Installation.*successful/ {print}
- {print >> logfile}
- ' || return
- [[ -s "$statusfile" ]] && return $(<$statusfile)
- return 0
-}
-
-
-function add_patches
-{
- typeset distdir tmpdir icmd obj patches statusfile
-
- (( ${#PATCHES[*]} == 0 )) && return
-
- tmpdir=$TMP_DIR/patches
- statusfile=$TMP_DIR/.add_patches.status
-
- trap '$RM -rf $tmpdir $statusfile' EXIT
-
- distdir=$ITUDIR/$COUNTDIR/DU/sol_$VERSION/$MACH
- (( COUNTDIR += 1 ))
-
- $MKDIR -p "$distdir/Tools" "$distdir/Product" "$tmpdir" || return
-
- # If we're running this script on sun4[vu], then create a symlink
- # to the other UltraSPARC architecture
- if [[ "$MACH" != "i386" ]]
- then
- cd $ITUDIR/$COUNTDIR/DU/sol_$VERSION/
- $LN -s sparc sun4v
- $LN -s sparc sun4u
- else
- cd $ITUDIR/$COUNTDIR/DU/sol_$VERSION/
- $LN -s i386 i86pc
- fi
-
- # Patch the miniroot
- echo;
- gettext "Installing patch(es) onto miniroot."
- $RM -f "$statusfile"
- {
- $PATCHADD -udn -C "$UNPACKED_ROOT" "${PATCHES[@]}"
- if (( i=$? ))
- then
- echo $i > "$statusfile"
- $TOUCH "$statusfile" # make sure file is created
- fi
- } 2>&1 | $NAWK -v logfile="$LOGFILE" '
- # Print certain lines from patchadd, save all in logfile.
- /^Patch.*successful/ {print}
- {print >> logfile}
- ' || return
-
- [[ -s "$statusfile" ]] && return $(<$statusfile)
-
- # Remove patch log files to save space when miniroot is repacked.
- $RM -rf "$UNPACKED_ROOT"/var/sadm/patch
-
- # Symlink each patch in a temp dir so a single cpio/gzip can work.
- for obj in "${PATCHES[@]}"
- do
- # Get rid of trailing /'s, if any.
- [[ "$obj" == */ ]] && obj=${obj%%+(/)}
-
- # Make sure it's full pathname.
- [[ "$obj" != /* ]] && obj=$ORIGPWD/$obj
-
- $LN -s "$obj" "$tmpdir" || return
-
- # Remember just the file component.
- patches[ ${#patches[*]} ]=${obj##*/}
- done
-
- # Package up patches as compressed cpio archive.
- echo;
- gettext "Adding patch(es) to media root.\n"
- $RM -f "$statusfile"
- (
- cd "$tmpdir"
- # fd 9 is used later on for filtering out cpio's
- # reporting total blocks to stderr but yet still
- # print other error messages.
- exec 9>&1
- for obj in "${patches[@]}"
- do
- gettext "Transferring patch $obj\n"
- $FIND "$obj/." -follow -print
- if (( i=$? ))
- then
- echo $i > "$statusfile"
- $TOUCH "$statusfile"
- return $i
- fi
- done | $CPIO -oc 2>&1 >&9 | $GREP -v '^[0-9]* blocks' >&2
- ) | $GZIP -9 > "$distdir/Product/patches.gz" || return
-
- [[ -s "$statusfile" ]] && return $(<$statusfile)
-
- # Create install.sh
- $CAT > "$distdir/Tools/install.sh" <<"EOF"
-#!/sbin/sh
-# install.sh -R <basedir> - install patches to basedir
-basedir=/
-toolsdir=`dirname $0`
-tmpdir=/tmp/`basename $0`.$$
-trap "/bin/rm -rf $tmpdir" 0
-while getopts "R:" arg
-do
- case "$arg" in
- R) basedir=$OPTARG;;
- esac
-done
-/bin/mkdir -p "$tmpdir" || exit
-tmpfile=$tmpdir/patches
-patchdir=$tmpdir/patchdir
-/bin/mkdir "$patchdir" || exit
-/usr/bin/gzip -c -d "$toolsdir/../Product/patches.gz" > $tmpfile || exit
-cd "$patchdir"
-/bin/cpio -idum < "$tmpfile" || exit
-/usr/sbin/patchadd -R "$basedir" -nu *
-EOF
- $CHMOD a+rx "$distdir/Tools/install.sh"
-
-}
-
-
-#
-# Main
-#
-trap cleanup EXIT
-
-ISO=
-ISOLABEL=
-MEDIA_ROOT=
-VERBOSE_LEVEL=0
-VERBOSE_OPTS=
-
-while getopts ':d:o:l:v' opt
-do
- case $opt in
- d) MEDIA_ROOT=$OPTARG
- ;;
- o) ISO=$OPTARG
- if [ ! -z `echo $ISO | $GREP "^/tmp"` ]; then
- gettext "ISO images will not be created on /tmp.\nPlease choose a different output location.\n"
- exit 3
- fi
- ;;
- l) ISOLABEL=$OPTARG
- ;;
- v) (( VERBOSE_LEVEL += 1 ))
- VERBOSE_OPTS="${VERBOSE_OPTS:--}$opt" # collect -v options
- ;;
- :) gettext "Option -$OPTARG missing argument.\n"
- usage
- exit 1
- ;;
- *) gettext "Option -$OPTARG is invalid.\n"
- usage
- exit 2
- ;;
- esac
-done
-shift 'OPTIND - 1'
-
-unset PACKAGES PATCHES # reset arrays
-collect_objs "$@"
-
-# If there are no packages or patches, then print info and we're done.
-if (( ${#PACKAGES[*]} == 0 && ${#PATCHES[*]} == 0 ))
-then
- gettext "No valid package or patch was specified.\nPackages and patches must be unpacked.\n"
- usage
- exit 1
-fi
-
-# -d option must be specified
-if [[ -z "$MEDIA_ROOT" ]]
-then
- gettext "No media root (-d option) was specified.\n"
- usage
- exit 1
-fi
-
-check_prereqs # must be called after $ISO is possibly set
-
-# Verify it's a Solaris install media.
-SOLARIS_DIR=$($LS -d $MEDIA_ROOT/Solaris* 2>/dev/null)
-if [[ -z "$SOLARIS_DIR" || ! -d "$SOLARIS_DIR/Tools/Boot" ]]
-then
- gettext "$MEDIA_ROOT is not valid Solaris install media.\n"
- exit 1
-fi
-
-$MKDIR -p "$TMP_DIR" || exit 1
-
-# Extract the Solaris release number from the Solaris_* directory and the
-# corresponding version number. As defined by the ITU spec, a Solaris release
-# number 5.x corresponds to version number 2x (e.g. 5.10 -> 210).
-RELEASE=5.${SOLARIS_DIR##*Solaris_}
-VERSION=$(echo $RELEASE | $SED 's/5\./2/')
-
-# If user didn't specify ISO label, use the Solaris_* dir as label.
-${ISOLABEL:=${SOLARIS_DIR##*/}} 2>/dev/null
-
-# Verify miniroot
-
-MINIROOT=
-# Relative to a Solaris media root.
-if [ "$MACH" = "sparc" ]; then
- MINIROOT=$MEDIA_ROOT/boot/sparc.miniroot
-else
- # x86/x64
- MINIROOT=$MEDIA_ROOT/boot/x86.miniroot
-fi
-if [ ! -f $MINIROOT ]; then
- gettext "No boot/x86.miniroot under media root.\n"
- exit 1
-fi
-
-# Where to unpack the miniroot.
-UNPACKED_ROOT=${TMP_DIR}/miniroot
-
-# Create the ITU directory on the media, if necessary
-ITUDIR=$MEDIA_ROOT/ITUs
-$MKDIR -p "$ITUDIR" || exit 1
-
-# The ITU directory might contain multiple driver updates already, each in a
-# separate numbered subdirectory. So look for the subdirectory with the
-# highest number and we'll add the packages and patches on the next one.
-typeset -Z3 COUNTDIR
-COUNTDIR=$($LS -d "$ITUDIR"/+([0-9]) 2>/dev/null | $SED 's;.*/;;' |
- $SORT -rn | $HEAD -1)
-if [[ $COUNTDIR == *( ) ]]
-then
- COUNTDIR=0
-else
- (( COUNTDIR += 1 ))
-fi
-
-unpack_media || exit
-add_pkgs && add_patches
-if (( status=$? )) && [[ -s "$LOGFILE" ]]
-then
- echo;
- gettext "A package or patch installation has failed.\nMessages from pkgadd and patchadd have been saved in $LOGFILE\n"
- exit $status
-else
- $RM -f "$LOGFILE"
-fi
-print
-repack_media || exit
-mkiso
diff --git a/usr/src/cmd/lms/Makefile b/usr/src/cmd/lms/Makefile
index 04e3c6bc63..03c52c4b31 100644
--- a/usr/src/cmd/lms/Makefile
+++ b/usr/src/cmd/lms/Makefile
@@ -50,7 +50,7 @@ TOOLS_DIR=tools
CPPFLAGS= -DBSD_COMP -D_REMOTE_SUPPORT \
-I. -I$(SYNCLIB_HDRDIR) -I$(HECI_DIR) -I$(TOOLS_DIR)
CCFLAGS += -compat=5 -features=zla
-$(__SUNC)CCNEEDED= -lCrun -lCstd
+$(__SUNC)CCNEEDED= $(CCEXTNEEDED)
LDFLAGS += $(ZIGNORE) -norunpath
LDLIBS += -lsocket -lnsl
diff --git a/usr/src/cmd/ls/ls.c b/usr/src/cmd/ls/ls.c
index 048afb3ec2..94fc114b01 100644
--- a/usr/src/cmd/ls/ls.c
+++ b/usr/src/cmd/ls/ls.c
@@ -21,6 +21,7 @@
/*
* Copyright (c) 1988, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012, Joyent, Inc. All rights reserved.
*/
/*
@@ -309,6 +310,7 @@ static mode_t flags;
static int err = 0; /* Contains return code */
static int colorflg;
static int file_typeflg;
+static int noflist = 0;
static uid_t lastuid = (uid_t)-1;
static gid_t lastgid = (gid_t)-1;
@@ -998,6 +1000,15 @@ main(int argc, char *argv[])
#endif
}
+ /*
+ * When certain options (-f, or -U and -1, and not -l, etc.) are
+ * specified, don't cache each dirent as it's read. This 'noflist'
+ * option is set when there's no need to cache those dirents; instead,
+ * print them out as they're read.
+ */
+ if ((Uflg || fflg) && !Cflg && !lflg && !iflg && statreq == 0)
+ noflist = 1;
+
if (num_cols < 20 || num_cols > 1000)
/* assume it is an error */
num_cols = 80;
@@ -1156,7 +1167,7 @@ pdirectory(char *name, int title, int lp, int cdetect, struct ditem *myinfo)
nfiles = lp;
rddir(name, myinfo);
- if (nomocore)
+ if (nomocore || noflist)
return;
if (fflg == 0 && Uflg == 0)
qsort(&flist[lp], (unsigned)(nfiles - lp),
@@ -1250,6 +1261,11 @@ pentry(struct lbuf *ap)
char *cp;
char *str;
+ if (noflist) {
+ (void) printf("%s\n", ap->ln.lname);
+ return;
+ }
+
p = ap;
column();
if (iflg)
@@ -1572,6 +1588,15 @@ rddir(char *dir, struct ditem *myinfo)
for (j = 0; dentry->d_name[j] != '\0'; j++)
ep->ln.lname[j] = dentry->d_name[j];
ep->ln.lname[j] = '\0';
+
+ /*
+ * Since this entry doesn't need to be sorted
+ * or further processed, print it right away.
+ */
+ if (noflist) {
+ pem(&ep, &ep + 1, 0);
+ nfiles--;
+ }
}
}
if (errno) {
@@ -1784,6 +1809,14 @@ gstat(char *file, int argfl, struct ditem *myparent)
rep = flist[nfiles++];
}
+ /*
+ * When noflist is set, none of the extra information about the dirent
+ * will be printed, so omit initialization of this lbuf as well as the
+ * stat(2) call.
+ */
+ if (!argfl && noflist)
+ return (rep);
+
/* Initialize */
rep->lflags = (mode_t)0;
diff --git a/usr/src/cmd/mdb/Makefile.kmdb.files b/usr/src/cmd/mdb/Makefile.kmdb.files
index 56dff97a8d..b5645ec1ba 100644
--- a/usr/src/cmd/mdb/Makefile.kmdb.files
+++ b/usr/src/cmd/mdb/Makefile.kmdb.files
@@ -80,6 +80,7 @@ KMDBSRCS += \
mdb_string.c \
mdb_strio.c \
kmdb_stubs.c \
+ mdb_tab.c \
mdb_target.c \
kmdb_terminfo.c \
mdb_termio.c \
diff --git a/usr/src/cmd/mdb/Makefile.mdb b/usr/src/cmd/mdb/Makefile.mdb
index 17d06056e6..1d87ac199f 100644
--- a/usr/src/cmd/mdb/Makefile.mdb
+++ b/usr/src/cmd/mdb/Makefile.mdb
@@ -19,12 +19,12 @@
# CDDL HEADER END
#
#
-# Copyright 2011 Nexenta Systems, Inc. All rights reserved.
# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
#
+# Copyright 2011 Nexenta Systems, Inc. All rights reserved.
# Copyright (c) 2012 by Delphix. All rights reserved.
# Copyright (c) 2012 Joyent, Inc. All rights reserved.
#
diff --git a/usr/src/cmd/mdb/common/mdb/mdb.c b/usr/src/cmd/mdb/common/mdb/mdb.c
index 20e07fb5ee..79f94919d0 100644
--- a/usr/src/cmd/mdb/common/mdb/mdb.c
+++ b/usr/src/cmd/mdb/common/mdb/mdb.c
@@ -26,6 +26,11 @@
*/
/*
+ * Copyright (c) 2012 by Delphix. All rights reserved.
+ * Copyright (c) 2012 Joyent, Inc. All rights reserved.
+ */
+
+/*
* Modular Debugger (MDB)
*
* Refer to the white paper "A Modular Debugger for Solaris" for information
diff --git a/usr/src/cmd/mdb/common/mdb/mdb.h b/usr/src/cmd/mdb/common/mdb/mdb.h
index ffb7ee4042..0938b16562 100644
--- a/usr/src/cmd/mdb/common/mdb/mdb.h
+++ b/usr/src/cmd/mdb/common/mdb/mdb.h
@@ -25,6 +25,11 @@
* Copyright (c) 2012 Joyent, Inc. All rights reserved.
*/
+/*
+ * Copyright (c) 2012 by Delphix. All rights reserved.
+ * Copyright (c) 2012 Joyent, Inc. All rights reserved.
+ */
+
#ifndef _MDB_H
#define _MDB_H
diff --git a/usr/src/cmd/mdb/common/mdb/mdb_cmds.c b/usr/src/cmd/mdb/common/mdb/mdb_cmds.c
index c9cf91b14f..f099567413 100644
--- a/usr/src/cmd/mdb/common/mdb/mdb_cmds.c
+++ b/usr/src/cmd/mdb/common/mdb/mdb_cmds.c
@@ -26,6 +26,11 @@
* Copyright (c) 2012 Joyent, Inc. All rights reserved.
*/
+/*
+ * Copyright (c) 2012 by Delphix. All rights reserved.
+ * Copyright (c) 2012 Joyent, Inc. All rights reserved.
+ */
+
#include <sys/elf.h>
#include <sys/elf_SPARC.h>
diff --git a/usr/src/cmd/mdb/common/mdb/mdb_main.c b/usr/src/cmd/mdb/common/mdb/mdb_main.c
index 8399bde41c..caccef986d 100644
--- a/usr/src/cmd/mdb/common/mdb/mdb_main.c
+++ b/usr/src/cmd/mdb/common/mdb/mdb_main.c
@@ -21,6 +21,7 @@
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
+ * Copyright 2012, Josef 'Jeff' Sipek <jeffpc@31bits.net>. All rights reserved.
*/
#include <sys/types.h>
@@ -803,6 +804,9 @@ main(int argc, char *argv[], char *envp[])
tgt_argc -= c;
}
+ if (fflag)
+ goto tcreate; /* skip re-exec and just create target */
+
/*
* If we just have an object file name, and that file doesn't
* exist, and it's a string of digits, infer it to be a
@@ -866,8 +870,7 @@ main(int argc, char *argv[], char *envp[])
* it is not and the target is unknown, use the rawfile tgt.
* Otherwise an ELF-based target is needed, so we must abort.
*/
- if (tgt_ctor != mdb_rawfile_tgt_create &&
- mdb_gelf_check(io, &ehdr, ET_NONE) == -1) {
+ if (mdb_gelf_check(io, &ehdr, ET_NONE) == -1) {
if (tgt_ctor != NULL) {
(void) mdb_gelf_check(io, &ehdr, ET_EXEC);
mdb_io_destroy(io);
@@ -878,8 +881,7 @@ main(int argc, char *argv[], char *envp[])
mdb_io_destroy(io);
- if (identify_xvm_file(tgt_argv[0], &longmode) == 1 &&
- !fflag) {
+ if (identify_xvm_file(tgt_argv[0], &longmode) == 1) {
#ifdef _LP64
if (!longmode)
goto reexec;
@@ -891,9 +893,6 @@ main(int argc, char *argv[], char *envp[])
goto tcreate;
}
- if (tgt_ctor == mdb_rawfile_tgt_create)
- goto tcreate; /* skip re-exec and just create target */
-
/*
* The object file turned out to be a user core file (ET_CORE),
* and no other arguments were specified, swap 0 and 1. The
diff --git a/usr/src/cmd/mdb/common/mdb/mdb_module.h b/usr/src/cmd/mdb/common/mdb/mdb_module.h
index 24ba113ca9..04cb3d1cee 100644
--- a/usr/src/cmd/mdb/common/mdb/mdb_module.h
+++ b/usr/src/cmd/mdb/common/mdb/mdb_module.h
@@ -26,6 +26,11 @@
* Copyright (c) 2012 Joyent, Inc. All rights reserved.
*/
+/*
+ * Copyright (c) 2012 by Delphix. All rights reserved.
+ * Copyright (c) 2012 Joyent, Inc. All rights reserved.
+ */
+
#ifndef _MDB_MODULE_H
#define _MDB_MODULE_H
diff --git a/usr/src/cmd/mdb/common/mdb/mdb_print.c b/usr/src/cmd/mdb/common/mdb/mdb_print.c
index e0ba9e2fa3..9de62791b8 100644
--- a/usr/src/cmd/mdb/common/mdb/mdb_print.c
+++ b/usr/src/cmd/mdb/common/mdb/mdb_print.c
@@ -25,6 +25,11 @@
* Copyright (c) 2012 Joyent, Inc. All rights reserved.
*/
+/*
+ * Copyright (c) 2012 by Delphix. All rights reserved.
+ * Copyright (c) 2012 Joyent, Inc. All rights reserved.
+ */
+
#include <mdb/mdb_modapi.h>
#include <mdb/mdb_target.h>
#include <mdb/mdb_argvec.h>
@@ -1685,7 +1690,7 @@ pipe_print(mdb_ctf_id_t id, ulong_t off, void *data)
} u;
if (mdb_ctf_type_resolve(id, &base) == -1) {
- mdb_warn("could not resolve type\n");
+ mdb_warn("could not resolve type");
return (-1);
}
@@ -1908,7 +1913,8 @@ parse_member(printarg_t *pap, const char *str, mdb_ctf_id_t id,
return (-1);
}
- (void) mdb_snprintf(member, end - start + 1, start);
+ (void) mdb_snprintf(member, end - start + 1, "%s",
+ start);
index = mdb_strtoull(member);
@@ -1985,7 +1991,7 @@ parse_member(printarg_t *pap, const char *str, mdb_ctf_id_t id,
for (end = start + 1; isalnum(*end) || *end == '_'; end++)
continue;
- (void) mdb_snprintf(member, end - start + 1, start);
+ (void) mdb_snprintf(member, end - start + 1, "%s", start);
if (mdb_ctf_member_info(rid, member, &off, &id) != 0) {
mdb_warn("failed to find member %s of %s", member,
@@ -2142,6 +2148,7 @@ cmd_print_tab_common(mdb_tab_cookie_t *mcp, uint_t flags, int argc,
* already have in rid.
*/
return (mdb_tab_complete_member_by_id(mcp, rid, member));
+<<<<<<< HEAD
}
@@ -2768,6 +2775,7 @@ enum {
};
int
+<<<<<<< HEAD
cmd_printf_tab(mdb_tab_cookie_t *mcp, uint_t flags, int argc,
const mdb_arg_t *argv)
{
@@ -2813,6 +2821,8 @@ cmd_printf_tab(mdb_tab_cookie_t *mcp, uint_t flags, int argc,
}
int
+=======
+>>>>>>> 5ada8a07255938930de285f1d55b0ef0bdba90ff
cmd_printf(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
{
char type[MDB_SYM_NAMLEN];
@@ -2833,7 +2843,11 @@ cmd_printf(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
if (argc == 0 || argv[0].a_type != MDB_TYPE_STRING) {
mdb_warn("expected a format string\n");
+<<<<<<< HEAD
return (DCMD_ABORT);
+=======
+ return (DCMD_USAGE);
+>>>>>>> 5ada8a07255938930de285f1d55b0ef0bdba90ff
}
/*
@@ -2842,6 +2856,15 @@ cmd_printf(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
* subset of mdb_printf() format strings that we allow.
*/
fmt = argv[0].a_un.a_str;
+<<<<<<< HEAD
+=======
+ /*
+ * 'dest' must be large enough to hold a copy of the format string,
+ * plus a NUL and up to 2 additional characters for each conversion
+ * in the format string. This gives us a bloat factor of 5/2 ~= 3.
+ * e.g. "%d" (strlen of 2) --> "%lld\0" (need 5 bytes)
+ */
+>>>>>>> 5ada8a07255938930de285f1d55b0ef0bdba90ff
dest = mdb_zalloc(strlen(fmt) * 3, UM_SLEEP | UM_GC);
fmts = mdb_zalloc(strlen(fmt) * sizeof (char *), UM_SLEEP | UM_GC);
funcs = mdb_zalloc(strlen(fmt) * sizeof (void *), UM_SLEEP | UM_GC);
@@ -2908,7 +2931,10 @@ cmd_printf(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
funcs[nfmts] = printf_ipv6;
break;
+<<<<<<< HEAD
case 'H':
+=======
+>>>>>>> 5ada8a07255938930de285f1d55b0ef0bdba90ff
case 'o':
case 'r':
case 'u':
@@ -3024,6 +3050,7 @@ static char _mdb_printf_help[] =
"\n"
" %% Prints the '%' symbol.\n"
" %a Prints the member in symbolic form.\n"
+<<<<<<< HEAD
" %d Prints the member as a decimal integer. If the member is a signed\n"
" integer type, the output will be signed.\n"
" %H Prints the member as a human-readable size.\n"
@@ -3034,12 +3061,27 @@ static char _mdb_printf_help[] =
" %q Prints the member in signed octal. Honk if you ever use this!\n"
" %r Prints the member as an unsigned value in the current output radix. \n"
" %R Prints the member as a signed value in the current output radix. \n"
+=======
+" %d Prints the member as a decimal integer. If the member is a signed\n"
+" integer type, the output will be signed.\n"
+" %I Prints the member a IPv4 address (must be a 32-bit integer type).\n"
+" %N Prints the member an IPv6 address (must be of type in6_addr_t).\n"
+" %o Prints the member as an unsigned octal integer.\n"
+" %p Prints the member as a pointer, in hexadecimal.\n"
+" %q Prints the member in signed octal. Honk if you ever use this!\n"
+" %r Prints the member as an unsigned value in the current output radix.\n"
+" %R Prints the member as a signed value in the current output radix.\n"
+>>>>>>> 5ada8a07255938930de285f1d55b0ef0bdba90ff
" %s Prints the member as a string (requires a pointer or an array of\n"
" characters).\n"
" %u Prints the member as an unsigned decimal integer.\n"
" %x Prints the member in hexadecimal.\n"
" %X Prints the member in hexadecimal, using the characters A-F as the\n"
+<<<<<<< HEAD
" digits for the values 10-15. \n"
+=======
+" digits for the values 10-15.\n"
+>>>>>>> 5ada8a07255938930de285f1d55b0ef0bdba90ff
" %Y Prints the member as a time_t as the string "
"'year month day HH:MM:SS'.\n"
"\n"
@@ -3052,6 +3094,7 @@ static char _mdb_printf_help[] =
"\n"
"The following flag specifers are recognized by ::printf:\n"
"\n"
+<<<<<<< HEAD
" %- Left-justify the output within the specified field width. If the\n"
" width of the output is less than the specified field width, the\n"
" output will be padded with blanks on the right-hand side. Without\n"
@@ -3059,6 +3102,15 @@ static char _mdb_printf_help[] =
"\n"
" %0 Zero-fill the output field if the output is right-justified and the\n"
" width of the output is less than the specified field width. Without\n"
+=======
+" %- Left-justify the output within the specified field width. If the\n"
+" width of the output is less than the specified field width, the\n"
+" output will be padded with blanks on the right-hand side. Without\n"
+" %-, values are right-justified by default.\n"
+"\n"
+" %0 Zero-fill the output field if the output is right-justified and the\n"
+" width of the output is less than the specified field width. Without\n"
+>>>>>>> 5ada8a07255938930de285f1d55b0ef0bdba90ff
" %0, right-justified values are prepended with blanks in order to\n"
" fill the field.\n"
"\n"
diff --git a/usr/src/cmd/mdb/common/mdb/mdb_print.h b/usr/src/cmd/mdb/common/mdb/mdb_print.h
index 9f4d0ba0dd..7449e8e71a 100644
--- a/usr/src/cmd/mdb/common/mdb/mdb_print.h
+++ b/usr/src/cmd/mdb/common/mdb/mdb_print.h
@@ -25,6 +25,11 @@
* Copyright (c) 2012 Joyent, Inc. All rights reserved.
*/
+/*
+ * Copyright (c) 2012 by Delphix. All rights reserved.
+ * Copyright (c) 2012 Joyent, Inc. All rights reserved.
+ */
+
#ifndef _MDB_PRINT_H
#define _MDB_PRINT_H
diff --git a/usr/src/cmd/mdb/common/mdb/mdb_tab.c b/usr/src/cmd/mdb/common/mdb/mdb_tab.c
index ebf9a637f2..f52decb165 100644
--- a/usr/src/cmd/mdb/common/mdb/mdb_tab.c
+++ b/usr/src/cmd/mdb/common/mdb/mdb_tab.c
@@ -501,6 +501,7 @@ tab_complete_type(mdb_ctf_id_t id, void *arg)
return (0);
if (flags & MDB_TABC_NOARRAY && rkind == CTF_K_ARRAY)
+
return (0);
(void) mdb_ctf_type_name(id, buf, sizeof (buf));
diff --git a/usr/src/cmd/mdb/common/mdb/mdb_termio.c b/usr/src/cmd/mdb/common/mdb/mdb_termio.c
index 1f2992ba65..9f9571d925 100644
--- a/usr/src/cmd/mdb/common/mdb/mdb_termio.c
+++ b/usr/src/cmd/mdb/common/mdb/mdb_termio.c
@@ -27,6 +27,11 @@
*/
/*
+ * Copyright (c) 2012 by Delphix. All rights reserved.
+ * Copyright (c) 2012 Joyent, Inc. All rights reserved.
+ */
+
+/*
* Terminal I/O Backend
*
* Terminal editing backend for standard input. The terminal i/o backend is
@@ -1639,7 +1644,6 @@ termio_tab(termio_data_t *td, int c)
buf = mdb_alloc(td->tio_cmdbuf.cmd_bufidx + 1, UM_SLEEP | UM_GC);
(void) strncpy(buf, td->tio_cmdbuf.cmd_buf, td->tio_cmdbuf.cmd_bufidx);
buf[td->tio_cmdbuf.cmd_bufidx] = '\0';
- buf = strndup(td->tio_cmdbuf.cmd_buf, td->tio_cmdbuf.cmd_bufidx);
td->tio_flags |= TIO_TAB;
mtp = mdb_tab_init();
nres = mdb_tab_command(mtp, buf);
@@ -1648,8 +1652,10 @@ termio_tab(termio_data_t *td, int c)
result = NULL;
} else {
result = mdb_tab_match(mtp);
- if (nres != 1)
+ if (nres != 1) {
+ mdb_printf("\n");
mdb_tab_print(mtp);
+ }
}
if (result != NULL) {
diff --git a/usr/src/cmd/mdb/common/mdb/mdb_whatis.c b/usr/src/cmd/mdb/common/mdb/mdb_whatis.c
index c0be53506d..6a26a7dec9 100644
--- a/usr/src/cmd/mdb/common/mdb/mdb_whatis.c
+++ b/usr/src/cmd/mdb/common/mdb/mdb_whatis.c
@@ -25,6 +25,11 @@
* Copyright (c) 2012 Joyent, Inc. All rights reserved.
*/
+/*
+ * Copyright (c) 2012 by Delphix. All rights reserved.
+ * Copyright (c) 2012 Joyent, Inc. All rights reserved.
+ */
+
#include <mdb/mdb_modapi.h>
#include <mdb/mdb.h>
#include <mdb/mdb_io.h>
diff --git a/usr/src/cmd/mdb/common/modules/sockfs/sockfs.c b/usr/src/cmd/mdb/common/modules/sockfs/sockfs.c
index 33b8d20f8a..3bc0b264d0 100644
--- a/usr/src/cmd/mdb/common/modules/sockfs/sockfs.c
+++ b/usr/src/cmd/mdb/common/modules/sockfs/sockfs.c
@@ -66,6 +66,8 @@ static int
sockparams_prt(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
{
struct sockparams sp;
+ char strdev[MAXPATHLEN];
+ char sockmod[MODMAXNAMELEN];
if ((flags & DCMD_ADDRSPEC) == 0) {
uint_t opt_e = 0;
@@ -112,12 +114,18 @@ sockparams_prt(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
return (DCMD_ERR);
}
+ if ((sp.sp_sdev_info.sd_devpath == NULL) ||
+ (mdb_readstr(strdev, sizeof (strdev),
+ (uintptr_t)sp.sp_sdev_info.sd_devpath) <= 0))
+ strcpy(strdev, "-");
+ if (mdb_readstr(sockmod, sizeof (sockmod),
+ (uintptr_t)sp.sp_smod_name) <= 0)
+ strcpy(sockmod, "");
+
mdb_printf("%0?p %3u %3u %3u %15s %15s %6u %#6x\n",
addr,
sp.sp_family, sp.sp_type, sp.sp_protocol,
- (sp.sp_sdev_info.sd_devpath != 0) ?
- sp.sp_sdev_info.sd_devpath : "-",
- sp.sp_smod_name, sp.sp_refcnt,
+ strdev, sockmod, sp.sp_refcnt,
sp.sp_flags);
diff --git a/usr/src/cmd/mdb/common/modules/zfs/zfs.c b/usr/src/cmd/mdb/common/modules/zfs/zfs.c
index bb5dbf9ba2..ffb030ab07 100644
--- a/usr/src/cmd/mdb/common/modules/zfs/zfs.c
+++ b/usr/src/cmd/mdb/common/modules/zfs/zfs.c
@@ -21,6 +21,7 @@
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright 2011 Nexenta Systems, Inc. All rights reserved.
+ * Copyright (c) 2012 by Delphix. All rights reserved.
*/
/* Portions Copyright 2010 Robert Milkowski */
@@ -1237,6 +1238,9 @@ do_print_vdev(uintptr_t addr, int flags, int depth, int stats,
case VDEV_AUX_VERSION_OLDER:
aux = "VERS_OLDER";
break;
+ case VDEV_AUX_UNSUP_FEAT:
+ aux = "UNSUP_FEAT";
+ break;
case VDEV_AUX_SPARED:
aux = "SPARED";
break;
@@ -2182,7 +2186,7 @@ zfs_blkstats(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
return (DCMD_ERR);
}
- tzb = &stats.zab_type[DN_MAX_LEVELS][DMU_OT_NUMTYPES];
+ tzb = &stats.zab_type[DN_MAX_LEVELS][DMU_OT_TOTAL];
if (tzb->zb_gangs != 0) {
mdb_printf("Ganged blocks: %llu\n",
(longlong_t)tzb->zb_gangs);
@@ -2198,7 +2202,7 @@ zfs_blkstats(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
mdb_printf("\nBlocks\tLSIZE\tPSIZE\tASIZE"
"\t avg\t comp\t%%Total\tType\n");
- for (t = 0; t <= DMU_OT_NUMTYPES; t++) {
+ for (t = 0; t <= DMU_OT_TOTAL; t++) {
char csize[NICENUM_BUFLEN], lsize[NICENUM_BUFLEN];
char psize[NICENUM_BUFLEN], asize[NICENUM_BUFLEN];
char avg[NICENUM_BUFLEN];
@@ -2209,6 +2213,8 @@ zfs_blkstats(uintptr_t addr, uint_t flags, int argc, const mdb_arg_t *argv)
if (t == DMU_OT_DEFERRED)
strcpy(typename, "deferred free");
+ else if (t == DMU_OT_OTHER)
+ strcpy(typename, "other");
else if (t == DMU_OT_TOTAL)
strcpy(typename, "Total");
else if (mdb_readstr(typename, sizeof (typename),
diff --git a/usr/src/cmd/mpathadm/mpathadm.c b/usr/src/cmd/mpathadm/mpathadm.c
index 468f772fd4..615fa25144 100644
--- a/usr/src/cmd/mpathadm/mpathadm.c
+++ b/usr/src/cmd/mpathadm/mpathadm.c
@@ -3144,7 +3144,7 @@ displayWideArray(MP_WCHAR *arrayToDisplay, int arraySize)
for (i = 0; i < numChars; i++) {
if (L'\0' != arrayToDisplay[i]) {
- (void) fprintf(stdout, "%wc", arrayToDisplay[i]);
+ (void) fprintf(stdout, "%wc", (int)arrayToDisplay[i]);
}
}
}
diff --git a/usr/src/cmd/pgrep/pgrep.c b/usr/src/cmd/pgrep/pgrep.c
index a8371dd6d8..4531f11267 100644
--- a/usr/src/cmd/pgrep/pgrep.c
+++ b/usr/src/cmd/pgrep/pgrep.c
@@ -22,8 +22,7 @@
* Copyright 2006 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
-
-#pragma ident "%Z%%M% %I% %E% SMI"
+/* Copyright (c) 2012 by Delphix. All rights reserved */
#include <sys/types.h>
#include <sys/stat.h>
@@ -164,8 +163,8 @@ Usage: %s [-signal] [-fnovx] [-P ppidlist] [-g pgrplist] [-s sidlist]\n\
[-u euidlist] [-U uidlist] [-G gidlist] [-J projidlist]\n\
[-T taskidlist] [-t termlist] [-z zonelist] [-c ctidlist] [pattern]\n";
-static const char PGREP_OPTS[] = "flnovxc:d:D:u:U:G:P:g:s:t:z:J:T:";
-static const char PKILL_OPTS[] = "fnovxc:D:u:U:G:P:g:s:t:z:J:T:";
+static const char PGREP_OPTS[] = ":flnovxc:d:D:u:U:G:P:g:s:t:z:J:T:";
+static const char PKILL_OPTS[] = ":fnovxc:D:u:U:G:P:g:s:t:z:J:T:";
static const char LSEP[] = ",\t "; /* Argument list delimiter chars */
@@ -630,8 +629,13 @@ main(int argc, char *argv[])
while (optind < argc) {
while ((c = getopt(argc, argv, optstr)) != (int)EOF) {
- if (c == '?' || g_optdtab[c - 'A'].o_opts == 0) {
- if (optopt != '?') {
+ if (c == ':' || c == '?' ||
+ g_optdtab[c - 'A'].o_opts == 0) {
+ if (c == ':') {
+ uu_warn(
+ gettext("missing argument -- %c\n"),
+ optopt);
+ } else if (optopt != '?') {
uu_warn(
gettext("illegal option -- %c\n"),
optopt);
diff --git a/usr/src/cmd/power/Makefile b/usr/src/cmd/power/Makefile
index 5451dc8a27..3496ab78df 100644
--- a/usr/src/cmd/power/Makefile
+++ b/usr/src/cmd/power/Makefile
@@ -67,7 +67,7 @@ i386_LDEVINFO=
LDEVINFO= -ldevinfo
DAEMON_LDLIBS = $(LDLIBS.cmd) -lkstat $(LDEVINFO)
-PMCFG_LDLIBS = $(LDLIBS.cmd) -lcmd -lsmbios -lkstat $($(MACH)_LDEVINFO)
+PMCFG_LDLIBS = $(LDLIBS.cmd) -lsmbios -lkstat $($(MACH)_LDEVINFO)
SUSPEND_LDLIBS = $(LDLIBS.cmd) -lbsm -lpam -lsecdb
ROOTUSRSBINPMCFG= $(PMCFG:%=$(ROOTUSRSBIN)/%)
diff --git a/usr/src/cmd/psrinfo/Makefile b/usr/src/cmd/psrinfo/Makefile
index 2455b4c67d..0c0f980612 100644
--- a/usr/src/cmd/psrinfo/Makefile
+++ b/usr/src/cmd/psrinfo/Makefile
@@ -21,6 +21,8 @@
# Copyright 2009 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
+# Copyright (c) 2012 DEY Storage Systems, Inc. All rights reserved.
+#
# cmd/psrinfo/Makefile
#
@@ -28,6 +30,11 @@ PROG= psrinfo
include ../Makefile.cmd
+LDLIBS += -lkstat
+XGETFLAGS +=
+$(PROG).po := CPPFLAGS += -DXGETTEXT
+
+
.KEEP_STATE:
all: $(PROG)
@@ -41,6 +48,6 @@ clean:
$(ROOTUSRSBINBINPROG): $(PROG)
$(INS.file)
-lint:
+lint: lint_PROG
include ../Makefile.targ
diff --git a/usr/src/cmd/psrinfo/psrinfo.c b/usr/src/cmd/psrinfo/psrinfo.c
new file mode 100644
index 0000000000..7488933901
--- /dev/null
+++ b/usr/src/cmd/psrinfo/psrinfo.c
@@ -0,0 +1,655 @@
+/*
+ * 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 (c) 2012 DEY Storage Systems, Inc. All rights reserved.
+ */
+
+/*
+ * This implements psrinfo(1M), a utility to report various information
+ * about processors, cores, and threads (virtual cpus). This is mostly
+ * intended for human consumption - this utility doesn't do much more than
+ * simply process kstats for human readability.
+ *
+ * All the relevant kstats are in the cpu_info kstat module.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <unistd.h>
+#include <string.h>
+#include <kstat.h>
+#include <libintl.h>
+#include <locale.h>
+#include <libgen.h>
+#include <ctype.h>
+#include <errno.h>
+
+#define _(x) gettext(x)
+#if XGETTEXT
+/* These CPU states are here for benefit of xgettext */
+_("on-line")
+_("off-line")
+_("faulted")
+_("powered-off")
+_("no-intr")
+_("spare")
+_("unknown")
+#endif
+
+/*
+ * We deal with sorted linked lists, where the sort key is usually the
+ * cpu id, core id, or chip id. We generalize this with simple node.
+ */
+struct link {
+ long l_id;
+ struct link *l_next;
+ void *l_ptr;
+};
+
+/*
+ * A physical chip. A chip can contain multiple cores and virtual cpus.
+ */
+struct pchip {
+ struct link p_link;
+ int p_ncore;
+ int p_nvcpu;
+ struct link *p_cores;
+ struct link *p_vcpus;
+ int p_doit;
+};
+
+struct core {
+ struct link c_link;
+ struct link c_link_pchip;
+
+ int c_nvcpu;
+ int c_doit;
+
+ struct pchip *c_pchip;
+ struct link *c_vcpus;
+};
+
+struct vcpu {
+ struct link v_link;
+
+ struct link v_link_core;
+ struct link v_link_pchip;
+
+ int v_doit;
+
+ struct pchip *v_pchip;
+ struct core *v_core;
+
+ char *v_state;
+ long v_state_begin;
+ char *v_cpu_type;
+ char *v_fpu_type;
+ long v_clock_mhz;
+ long v_pchip_id; /* 1 per socket */
+ char *v_impl;
+ char *v_brand;
+ long v_core_id; /* n per chip_id */
+};
+
+static struct link *pchips = NULL;
+static struct link *cores = NULL;
+static struct link *vcpus = NULL;
+
+static const char *cmdname;
+
+static void
+usage(char *msg)
+{
+ if (msg != NULL)
+ (void) fprintf(stderr, "%s: %s\n", cmdname, msg);
+ (void) fprintf(stderr, _("usage: \n" \
+ "\t%s [-v] [-p] [processor_id ...]\n" \
+ "\t%s -s [-p] processor_id\n"), cmdname, cmdname);
+ exit(2);
+}
+
+/* like perror, but includes the command name */
+static void
+die(const char *msg)
+{
+ (void) fprintf(stderr, "%s: %s: %s\n", cmdname, msg, strerror(errno));
+ exit(2);
+}
+
+static char *
+mystrdup(const char *src)
+{
+ char *dst;
+
+ if ((dst = strdup(src)) == NULL)
+ die(_("strdup() failed"));
+ return (dst);
+}
+
+static void *
+zalloc(size_t size)
+{
+ void *ptr;
+
+ if ((ptr = calloc(1, size)) == NULL)
+ die(_("calloc() failed"));
+ return (ptr);
+}
+
+/*
+ * Insert a new node on a list, at the insertion point given.
+ */
+static void
+ins_link(struct link **ins, struct link *item)
+{
+ item->l_next = *ins;
+ *ins = item;
+}
+
+/*
+ * Find an id on a sorted list. If the requested id is not found,
+ * then the insertpt will be set (if not null) to the location where
+ * a new node should be inserted with ins_link (see above).
+ */
+static void *
+find_link(void *list, int id, struct link ***insertpt)
+{
+ struct link **ins = list;
+ struct link *l;
+
+ while ((l = *ins) != NULL) {
+ if (l->l_id == id)
+ return (l->l_ptr);
+ if (l->l_id > id)
+ break;
+ ins = &l->l_next;
+ }
+ if (insertpt != NULL)
+ *insertpt = ins;
+ return (NULL);
+}
+
+/*
+ * Print the linked list of ids in parens, taking care to collapse
+ * ranges, so instead of (0 1 2 3) it should print (0-3).
+ */
+static void
+print_links(struct link *l)
+{
+ int start = -1;
+ int end = 0;
+
+ (void) printf(" (");
+ while (l != NULL) {
+ if (start < 0) {
+ start = l->l_id;
+ }
+ end = l->l_id;
+ if ((l->l_next == NULL) ||
+ (l->l_next->l_id > (l->l_id + 1))) {
+ /* end of the contiguous group */
+ if (start == end) {
+ (void) printf("%d", start);
+ } else {
+ (void) printf("%d-%d", start, end);
+ }
+ if (l->l_next)
+ (void) printf(" ");
+ start = -1;
+ }
+ l = l->l_next;
+ }
+ (void) printf(")");
+}
+
+static const char *
+timestr(long t)
+{
+ static char buffer[256];
+ (void) strftime(buffer, sizeof (buffer), _("%m/%d/%Y %T"),
+ localtime(&t));
+ return (buffer);
+}
+
+static void
+print_vp(int nspec)
+{
+ struct pchip *chip;
+ struct core *core;
+ struct vcpu *vcpu;
+ struct link *l1, *l2;
+ int len;
+ for (l1 = pchips; l1; l1 = l1->l_next) {
+
+ chip = l1->l_ptr;
+
+ if ((nspec != 0) && (chip->p_doit == 0))
+ continue;
+
+ vcpu = chip->p_vcpus->l_ptr;
+
+ /*
+ * Note that some of the way these strings are broken up are
+ * to accommodate the legacy translations so that we won't
+ * have to retranslate for this utility.
+ */
+ if ((chip->p_ncore == 1) || (chip->p_ncore == chip->p_nvcpu)) {
+ (void) printf(_("%s has %d virtual %s"),
+ _("The physical processor"),
+ chip->p_nvcpu,
+ chip->p_nvcpu > 1 ?
+ _("processors") :
+ _("processor"));
+ } else {
+ (void) printf(_("%s has %d %s and %d virtual %s"),
+ _("The physical processor"),
+ chip->p_ncore, _("cores"),
+ chip->p_nvcpu,
+ chip->p_nvcpu > 1 ?
+ _("processors") : _("processor"));
+ }
+
+ print_links(chip->p_vcpus);
+ (void) putchar('\n');
+
+ if ((chip->p_ncore == 1) || (chip->p_ncore == chip->p_nvcpu)) {
+ if (strlen(vcpu->v_impl)) {
+ (void) printf(" %s\n", vcpu->v_impl);
+ }
+ if (((len = strlen(vcpu->v_brand)) != 0) &&
+ (strncmp(vcpu->v_brand, vcpu->v_impl, len) != 0))
+ (void) printf("\t%s", vcpu->v_brand);
+ (void) putchar('\n');
+ } else {
+ for (l2 = chip->p_cores; l2; l2 = l2->l_next) {
+ core = l2->l_ptr;
+ (void) printf(_(" %s has %d virtual %s"),
+ _("The core"),
+ core->c_nvcpu,
+ chip->p_nvcpu > 1 ?
+ _("processors") : _("processor"));
+ print_links(core->c_vcpus);
+ (void) putchar('\n');
+ }
+ if (strlen(vcpu->v_impl)) {
+ (void) printf(" %s\n", vcpu->v_impl);
+ }
+ if (((len = strlen(vcpu->v_brand)) != 0) &&
+ (strncmp(vcpu->v_brand, vcpu->v_impl, len) != 0))
+ (void) printf(" %s\n", vcpu->v_brand);
+ }
+ }
+}
+
+static void
+print_ps(void)
+{
+ int online = 1;
+ struct pchip *p;
+ struct vcpu *v;
+ struct link *l;
+
+ /*
+ * Report "1" if all cpus colocated on the same chip are online.
+ */
+ for (l = pchips; l != NULL; l = l->l_next) {
+ p = l->l_ptr;
+ if (p->p_doit)
+ break;
+ }
+ if (p == NULL)
+ return; /* should never happen! */
+ for (l = p->p_vcpus; l != NULL; l = l->l_next) {
+ v = l->l_ptr;
+ if (strcmp(v->v_state, "on-line") != 0) {
+ online = 0;
+ break;
+ }
+ }
+
+ (void) printf("%d\n", online);
+}
+
+static void
+print_s(void)
+{
+ struct link *l;
+
+ /*
+ * Find the processor (there will be only one) that we selected,
+ * and report whether or not it is online.
+ */
+ for (l = vcpus; l != NULL; l = l->l_next) {
+ struct vcpu *v = l->l_ptr;
+ if (v->v_doit) {
+ (void) printf("%d\n",
+ strcmp(v->v_state, "on-line") == 0 ? 1 : 0);
+ return;
+ }
+ }
+}
+
+static void
+print_p(int nspec)
+{
+ struct link *l1, *l2;
+ int online = 0;
+
+ /*
+ * Print the number of physical packages with at least one processor
+ * online.
+ */
+ for (l1 = pchips; l1 != NULL; l1 = l1->l_next) {
+ struct pchip *p = l1->l_ptr;
+ if ((nspec == 0) || (p->p_doit)) {
+
+ for (l2 = p->p_vcpus; l2 != NULL; l2 = l2->l_next) {
+ struct vcpu *v = l2->l_ptr;
+ if (strcmp(v->v_state, "on-line") == 0) {
+ online++;
+ break;
+ }
+ }
+ }
+ }
+ (void) printf("%d\n", online);
+}
+
+static void
+print_v(int nspec)
+{
+ struct link *l;
+
+ for (l = vcpus; l != NULL; l = l->l_next) {
+ struct vcpu *v = l->l_ptr;
+
+ if ((nspec != 0) && (!v->v_doit))
+ continue;
+ (void) printf(_("Status of virtual processor %d as of: "),
+ l->l_id);
+ (void) printf("%s\n", timestr(time(NULL)));
+ (void) printf(_(" %s since %s.\n"),
+ _(v->v_state), timestr(v->v_state_begin));
+ if (v->v_clock_mhz) {
+ (void) printf(
+ _(" The %s processor operates at %llu MHz,\n"),
+ v->v_cpu_type, (unsigned long long)v->v_clock_mhz);
+ } else {
+ (void) printf(
+ _(" The %s processor operates at " \
+ "an unknown frequency,\n"), v->v_cpu_type);
+ }
+ switch (*v->v_fpu_type) {
+ case '\0':
+ (void) printf(
+ _("\tand has no floating point processor.\n"));
+ break;
+ case 'a': case 'A':
+ case 'e': case 'E':
+ case 'i': case 'I':
+ case 'o': case 'O':
+ case 'u': case 'U':
+ case 'y': case 'Y':
+ (void) printf(
+ _("\tand has an %s floating point processor.\n"),
+ v->v_fpu_type);
+ break;
+ default:
+ (void) printf(
+ _("\tand has a %s floating point processor.\n"),
+ v->v_fpu_type);
+ break;
+ }
+ }
+}
+
+static void
+print_normal(int nspec)
+{
+ struct link *l;
+ struct vcpu *v;
+
+ for (l = vcpus; l != NULL; l = l->l_next) {
+ v = l->l_ptr;
+ if ((nspec == 0) || (v->v_doit)) {
+ (void) printf(_("%d\t%-8s since %s\n"),
+ l->l_id, _(v->v_state), timestr(v->v_state_begin));
+ }
+ }
+}
+
+int
+main(int argc, char **argv)
+{
+ kstat_ctl_t *kc;
+ kstat_t *ksp;
+ kstat_named_t *knp;
+ struct vcpu *vc;
+ struct core *core;
+ struct pchip *chip;
+ struct link **ins;
+ char *s;
+ int nspec;
+ int optc;
+ int opt_s = 0;
+ int opt_p = 0;
+ int opt_v = 0;
+ int ex = 0;
+
+ cmdname = basename(argv[0]);
+
+
+ (void) setlocale(LC_ALL, "");
+#if !defined(TEXT_DOMAIN)
+#define TEXT_DOMAIN "SYS_TEST"
+#endif
+ (void) textdomain(TEXT_DOMAIN);
+
+ /* collect the kstats */
+ if ((kc = kstat_open()) == NULL)
+ die(_("kstat_open() failed"));
+
+ if ((ksp = kstat_lookup(kc, "cpu_info", -1, NULL)) == NULL)
+ die(_("kstat_lookup() failed"));
+
+ for (ksp = kc->kc_chain; ksp; ksp = ksp->ks_next) {
+
+ if (strcmp(ksp->ks_module, "cpu_info") != 0)
+ continue;
+ if (kstat_read(kc, ksp, NULL) == NULL)
+ die(_("kstat_read() failed"));
+
+ vc = find_link(&vcpus, ksp->ks_instance, &ins);
+ if (vc == NULL) {
+ vc = zalloc(sizeof (struct vcpu));
+ vc->v_link.l_id = ksp->ks_instance;
+ vc->v_link_core.l_id = ksp->ks_instance;
+ vc->v_link_pchip.l_id = ksp->ks_instance;
+ vc->v_link.l_ptr = vc;
+ vc->v_link_core.l_ptr = vc;
+ vc->v_link_pchip.l_ptr = vc;
+ ins_link(ins, &vc->v_link);
+ }
+
+ if ((knp = kstat_data_lookup(ksp, "state")) != NULL) {
+ vc->v_state = mystrdup(knp->value.c);
+ } else {
+ vc->v_state = "unknown";
+ }
+
+ if ((knp = kstat_data_lookup(ksp, "cpu_type")) != NULL) {
+ vc->v_cpu_type = mystrdup(knp->value.c);
+ }
+ if ((knp = kstat_data_lookup(ksp, "fpu_type")) != NULL) {
+ vc->v_fpu_type = mystrdup(knp->value.c);
+ }
+
+ if ((knp = kstat_data_lookup(ksp, "state_begin")) != NULL) {
+ vc->v_state_begin = knp->value.l;
+ }
+
+ if ((knp = kstat_data_lookup(ksp, "clock_MHz")) != NULL) {
+ vc->v_clock_mhz = knp->value.l;
+ }
+
+ if ((knp = kstat_data_lookup(ksp, "brand")) == NULL) {
+ vc->v_brand = _("(unknown)");
+ } else {
+ vc->v_brand = mystrdup(knp->value.str.addr.ptr);
+ }
+
+ if ((knp = kstat_data_lookup(ksp, "implementation")) == NULL) {
+ vc->v_impl = _("(unknown)");
+ } else {
+ vc->v_impl = mystrdup(knp->value.str.addr.ptr);
+ }
+ /*
+ * Legacy code removed the chipid and cpuid fields... we
+ * do the same for compatibility. Note that the original
+ * pattern is a bit strange, and we have to emulate this because
+ * on SPARC we *do* emit these. The original pattern we are
+ * emulating is: $impl =~ s/(cpuid|chipid)\s*\w+\s+//;
+ */
+ if ((s = strstr(vc->v_impl, "chipid")) != NULL) {
+ char *x = s + strlen("chipid");
+ while (isspace(*x))
+ x++;
+ if ((!isalnum(*x)) && (*x != '_'))
+ goto nochipid;
+ while (isalnum(*x) || (*x == '_'))
+ x++;
+ if (!isspace(*x))
+ goto nochipid;
+ while (isspace(*x))
+ x++;
+ (void) strcpy(s, x);
+ }
+nochipid:
+ if ((s = strstr(vc->v_impl, "cpuid")) != NULL) {
+ char *x = s + strlen("cpuid");
+ while (isspace(*x))
+ x++;
+ if ((!isalnum(*x)) && (*x != '_'))
+ goto nocpuid;
+ while (isalnum(*x) || (*x == '_'))
+ x++;
+ if (!isspace(*x))
+ goto nocpuid;
+ while (isspace(*x))
+ x++;
+ (void) strcpy(s, x);
+ }
+nocpuid:
+
+ if ((knp = kstat_data_lookup(ksp, "chip_id")) != NULL)
+ vc->v_pchip_id = knp->value.l;
+ chip = find_link(&pchips, vc->v_pchip_id, &ins);
+ if (chip == NULL) {
+ chip = zalloc(sizeof (struct pchip));
+ chip->p_link.l_id = vc->v_pchip_id;
+ chip->p_link.l_ptr = chip;
+ ins_link(ins, &chip->p_link);
+ }
+ vc->v_pchip = chip;
+
+ if ((knp = kstat_data_lookup(ksp, "core_id")) != NULL)
+ vc->v_core_id = knp->value.l;
+ core = find_link(&cores, vc->v_core_id, &ins);
+ if (core == NULL) {
+ core = zalloc(sizeof (struct core));
+ core->c_link.l_id = vc->v_core_id;
+ core->c_link.l_ptr = core;
+ core->c_link_pchip.l_id = vc->v_core_id;
+ core->c_link_pchip.l_ptr = core;
+ core->c_pchip = chip;
+ ins_link(ins, &core->c_link);
+ chip->p_ncore++;
+ (void) find_link(&chip->p_cores, core->c_link.l_id,
+ &ins);
+ ins_link(ins, &core->c_link_pchip);
+ }
+ vc->v_core = core;
+
+
+
+ /* now put other linkages in place */
+ (void) find_link(&chip->p_vcpus, vc->v_link.l_id, &ins);
+ ins_link(ins, &vc->v_link_pchip);
+ chip->p_nvcpu++;
+
+ (void) find_link(&core->c_vcpus, vc->v_link.l_id, &ins);
+ ins_link(ins, &vc->v_link_core);
+ core->c_nvcpu++;
+ }
+
+ (void) kstat_close(kc);
+
+ nspec = 0;
+
+ while ((optc = getopt(argc, argv, "pvs")) != EOF) {
+ switch (optc) {
+ case 's':
+ opt_s = 1;
+ break;
+ case 'p':
+ opt_p = 1;
+ break;
+ case 'v':
+ opt_v = 1;
+ break;
+ default:
+ usage(NULL);
+ }
+ }
+
+ while (optind < argc) {
+ long id;
+ char *eptr;
+ struct link *l;
+ id = strtol(argv[optind], &eptr, 10);
+ l = find_link(&vcpus, id, NULL);
+ if ((*eptr != '\0') || (l == NULL)) {
+ (void) fprintf(stderr,
+ _("%s: processor %s: Invalid argument\n"),
+ cmdname, argv[optind]);
+ ex = 2;
+ } else {
+ ((struct vcpu *)l->l_ptr)->v_doit = 1;
+ ((struct vcpu *)l->l_ptr)->v_pchip->p_doit = 1;
+ ((struct vcpu *)l->l_ptr)->v_core->c_doit = 1;
+ }
+ nspec++;
+ optind++;
+ }
+
+ if (opt_s && opt_v) {
+ usage(_("options -s and -v are mutually exclusive"));
+ }
+ if (opt_s && nspec != 1) {
+ usage(_("must specify exactly one processor if -s used"));
+ }
+ if (opt_v && opt_p) {
+ print_vp(nspec);
+ } else if (opt_s && opt_p) {
+ print_ps();
+ } else if (opt_p) {
+ print_p(nspec);
+ } else if (opt_v) {
+ print_v(nspec);
+ } else if (opt_s) {
+ print_s();
+ } else {
+ print_normal(nspec);
+ }
+
+ return (ex);
+}
diff --git a/usr/src/cmd/psrinfo/psrinfo.pl b/usr/src/cmd/psrinfo/psrinfo.pl
deleted file mode 100644
index 237e4d00f5..0000000000
--- a/usr/src/cmd/psrinfo/psrinfo.pl
+++ /dev/null
@@ -1,853 +0,0 @@
-#!/usr/perl5/bin/perl
-
-#
-# CDDL HEADER START
-#
-# The contents of this file are subject to the terms of the
-# Common Development and Distribution License (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 2009 Sun Microsystems, Inc. All rights reserved.
-# Use is subject to license terms.
-#
-# psrinfo: displays information about processors
-#
-# See detailed comment in the end of this file.
-#
-
-use strict;
-use warnings;
-use locale;
-use POSIX qw(locale_h strftime);
-use File::Basename;
-use Getopt::Long qw(:config no_ignore_case bundling auto_version);
-use Sun::Solaris::Utils qw(textdomain gettext);
-use Sun::Solaris::Kstat;
-
-# Set message locale
-setlocale(LC_ALL, "");
-textdomain(TEXT_DOMAIN);
-
-######################################################################
-# Configuration variables
-######################################################################
-
-# Regexp describing cpu_info kstat fields describing CPU hierarchy.
-my $valid_id_exp = qr{^(?:chip|core)_id$};
-
-# Translation of kstat name to human-readable form
-my %translations = ('chip_id' => gettext("The physical processor"),
- 'core_id' => gettext("The core"));
-
-# Localized version of plural forms
-my %pluralized_names = ('processor' => gettext("processor"),
- 'processors' => gettext("processors"),
- 'chip' => gettext("chip"),
- 'chips' => gettext("chips"),
- 'core' => gettext("core"),
- 'cores' => gettext("cores"));
-
-# Localized CPU states
-my %cpu_states = ('on-line' => gettext("on-line"),
- 'off-line' => gettext("off-line"),
- 'faulted' => gettext("faulted"),
- 'powered-off' => gettext("powered-off"),
- 'no-intr' => gettext("no-intr"),
- 'spare' => gettext("spare"),
- 'unknown' => gettext("unknown"));
-
-######################################################################
-# Global variables
-######################################################################
-
-# Hash with CPU ID as a key and specific per-cpu kstat hash as a value
-our %cpu_list;
-
-# Command name without path and trailing .pl - used for error messages.
-our $cmdname = basename($0, ".pl");
-
-# Return value
-our $errors = 0;
-
-######################################################################
-# Helper subroutines
-######################################################################
-
-#
-# Print help string if specified or the standard help message and exit setting
-# errno.
-#
-sub usage
-{
- my (@msg) = @_;
- print STDERR $cmdname, ": @msg\n" if (@msg);
- print STDERR gettext("usage: \n" .
- "\tpsrinfo [-v] [-p] [processor_id ...]\n" .
- "\tpsrinfo -s [-p] processor_id\n");
- exit(2);
-}
-
-#
-# Return the input list with duplicates removed.
-# Count how many times we've seen each element and remove elements seen more
-# than once.
-#
-sub uniq
-{
- my %seen; # Have we seen this element already?
- return (grep { ++$seen{$_} == 1 } @_);
-}
-
-#
-# Return the intersection of two lists passed by reference
-# Convert the first list to a hash with seen entries marked as 1-values
-# Then grep only elements present in the first list from the second list.
-# As a little optimization, use the shorter list to build a hash.
-#
-sub intersect
-{
- my ($left, $right) = @_;
- my %seen; # Set to 1 for everything in the first list
- # Put the shortest list in $left
- scalar @$left <= scalar @$right or ($right, $left) = ($left, $right);
-
- # Create a hash indexed by elements in @left with ones as a value.
- map { $seen{$_} = 1 } @$left;
- # Find members of @right present in @left
- return (grep { $seen{$_} } @$right);
-}
-
-#
-# Return elements of the second list not present in the first list. Both lists
-# are passed by reference.
-#
-sub set_subtract
-{
- my ($left, $right) = @_;
- my %seen; # Set to 1 for everything in the first list
- # Create a hash indexed by elements in @left with ones as a value.
- map { $seen{$_} = 1 } @$left;
- # Find members of @right present in @left
- return (grep { ! $seen{$_} } @$right);
-}
-
-#
-# Sort the list numerically
-# Should be called in list context
-#
-sub nsort
-{
- return (sort { $a <=> $b } @_);
-}
-
-#
-# Sort list numerically and remove duplicates
-# Should be called in list context
-#
-sub uniqsort
-{
- return (sort { $a <=> $b } uniq(@_));
-}
-
-#
-# Return the maximum value of its arguments
-#
-sub max
-{
- my $m = shift;
-
- foreach my $el (@_) {
- $m = $el if $m < $el;
- }
- return ($m);
-}
-
-#
-# Pluralize name if there is more than one instance
-# Arguments: name, ninstances
-#
-sub pluralize
-{
- my ($name, $count) = @_;
- # Remove trailing '_id' from the name.
- $name =~ s/_id$//;
- my $plural_name = $count > 1 ? "${name}s" : $name;
- return ($pluralized_names{$plural_name} || $plural_name)
-}
-
-#
-# Translate id name into printable form
-# Look at the %translations table and replace everything found there
-# Remove trailing _id from the name if there is no translation
-#
-sub id_translate
-{
- my $name = shift or return;
- my $translated_name = $translations{$name};
- $name =~ s/_id$// unless $translated_name;
- return ($translated_name || $name);
-}
-
-#
-# Consolidate consequtive CPU ids as start-end
-# Input: list of CPUs
-# Output: string with space-sepated cpu values with CPU ranges
-# collapsed as x-y
-#
-sub collapse
-{
- return ('') unless @_;
- my @args = uniqsort(@_);
- my $start = shift(@args);
- my $result = '';
- my $end = $start; # Initial range consists of the first element
- foreach my $el (@args) {
- if ($el == ($end + 1)) {
- #
- # Got consecutive ID, so extend end of range without
- # printing anything since the range may extend further
- #
- $end = $el;
- } else {
- #
- # Next ID is not consecutive, so print IDs gotten so
- # far.
- #
- if ($end > $start + 1) { # range
- $result = "$result $start-$end";
- } elsif ($end > $start) { # different values
- $result = "$result $start $end";
- } else { # same value
- $result = "$result $start";
- }
-
- # Try finding consecutive range starting from this ID
- $start = $end = $el;
- }
- }
-
- # Print last ID(s)
- if ($end > $start + 1) {
- $result = "$result $start-$end";
- } elsif ($end > $start) {
- $result = "$result $start $end";
- } else {
- $result = "$result $start";
- }
- # Remove any spaces in the beginning
- $result =~ s/^\s+//;
- return ($result);
-}
-
-#
-# Expand start-end into the list of values
-# Input: string containing a single numeric ID or x-y range
-# Output: single value or a list of values
-# Ranges with start being more than end are inverted
-#
-sub expand
-{
- my $arg = shift;
-
- if ($arg =~ m/^\d+$/) {
- # single number
- return ($_);
- } elsif ($arg =~ m/^(\d+)\-(\d+)$/) {
- my ($start, $end) = ($1, $2); # $start-$end
- # Reverse the interval if start > end
- ($start, $end) = ($end, $start) if $start > $end;
- return ($start .. $end);
- } elsif ($arg =~ m/-/) {
- printf STDERR
- gettext("%s: invalid processor range %s\n"),
- $cmdname, $_;
- } else {
- printf STDERR
- gettext("%s: processor %s: Invalid argument\n"),
- $cmdname, $_;
- }
- $errors = 2;
- return ();
-}
-
-#
-# Functions for constructing CPU hierarchy. Only used with -vp option.
-#
-
-#
-# Return numerically sorted list of distinct values of a given cpu_info kstat
-# field, spanning given CPU set.
-#
-# Arguments:
-# Property name
-# list of CPUs
-#
-# Treat undefined values as zeroes.
-sub property_list
-{
- my $prop_name = shift;
- return (grep {$_ >= 0} uniqsort(map { $cpu_list{$_}->{$prop_name} || 0 } @_));
-}
-
-#
-# Return subset of CPUs sharing specified value of a given cpu_info kstat field.
-# Arguments:
-# Property name
-# Property value
-# List of CPUs to select from
-#
-# Treat undefined values as zeroes.
-sub cpus_by_prop
-{
- my $prop_name = shift;
- my $prop_val = shift;
-
- return (grep { ($cpu_list{$_}->{$prop_name} || 0) == $prop_val } @_);
-}
-
-#
-# Build component tree
-#
-# Arguments:
-# Reference to the list of CPUs sharing the component
-# Reference to the list of sub-components
-#
-sub build_component_tree
-{
- my ($cpus, $comp_list) = @_;
- # Get the first component and the rest
- my ($comp_name, @comps) = @$comp_list;
- my $tree = {};
- if (!$comp_name) {
- $tree->{cpus} = $cpus;
- return ($tree);
- }
-
- # Get all possible component values
- foreach my $v (property_list($comp_name, @$cpus)) {
- my @comp_cpus = cpus_by_prop ($comp_name, $v, @$cpus);
- $tree->{name} = $comp_name;
- $tree->{cpus} = $cpus;
- $tree->{values}->{$v} = build_component_tree(\@comp_cpus,
- \@comps);
- }
- return ($tree);
-}
-
-#
-# Print the component tree
-# Arguments:
-# Reference to a tree
-# indentation
-# Output: maximum indentation
-#
-sub print_component_tree
-{
- my ($tree, $ind) = @_;
- my $spaces = ' ' x $ind; # indentation string
- my $vals = $tree->{values};
- my $retval = $ind;
- if ($vals) {
- # This is not a leaf node
- # Get node name and translate it to printable format
- my $id_name = id_translate($tree->{name});
- # Examine each sub-node
- foreach my $comp_val (nsort(keys %$vals)) {
- my $child_tree = $vals->{$comp_val}; # Sub-tree
- my $child_id = $child_tree->{name}; # Name of child node
- my @cpus = @{$child_tree->{cpus}}; # CPUs for the child
- my $ncpus = scalar @cpus; # Number of CPUs
- my $cpuname = pluralize('processor', $ncpus);
- my $cl = collapse(@cpus); # Printable CPU list
- if (!$child_id) {
- # Child is a leaf node
- print $spaces;
- printf gettext("%s has %d virtual %s"),
- $id_name, $ncpus, $cpuname;
- print " ($cl)\n";
- $retval = max($retval, $ind + 2);
- } else {
- # Child has several values. Let's see how many
- my $grandchild_tree = $child_tree->{values};
- my $nvals = scalar(keys %$grandchild_tree);
- my $child_id_name = pluralize($child_id,
- $nvals);
- print $spaces;
- printf
- gettext("%s has %d %s and %d virtual %s"),
- $id_name, $nvals, $child_id_name, $ncpus,
- $cpuname;
- print " ($cl)\n";
- # Print the tree for the child
- $retval = max($retval,
- print_component_tree($child_tree,
- $ind + 2));
- }
- }
- }
- return ($retval);
-}
-
-
-############################
-# Main part of the program
-############################
-
-#
-# Option processing
-#
-my ($opt_v, $opt_p, $opt_silent);
-
-GetOptions("p" => \$opt_p,
- "v" => \$opt_v,
- "s" => \$opt_silent) || usage();
-
-
-my $verbosity = 1;
-my $phys_view;
-
-$verbosity |= 2 if $opt_v;
-$verbosity &= ~1 if $opt_silent;
-$phys_view = 1 if $opt_p;
-
-# Set $phys_verbose if -vp is specified
-my $phys_verbose = $phys_view && ($verbosity > 1);
-
-# Verify options
-usage(gettext("options -s and -v are mutually exclusive")) if $verbosity == 2;
-
-usage(gettext("must specify exactly one processor if -s used")) if
- (($verbosity == 0) && scalar @ARGV != 1);
-
-#
-# Read cpu_info kstats
-#
-my $ks = Sun::Solaris::Kstat->new(strip_strings => 1) or
- (printf STDERR gettext("%s: kstat_open() failed: %s\n"),
- $cmdname, $!),
- exit(2);
-my $cpu_info = $ks->{cpu_info} or
- (printf STDERR gettext("%s: can not read cpu_info kstats\n"),
- $cmdname),
- exit(2);
-
-my (
- @all_cpus, # List of all CPUs in the system
- @cpu_args, # CPUs to look at
- @cpus, # List of CPUs to process
- @id_list, # list of various xxx_id kstats representing CPU topology
- %chips, # Hash with chip ID as a key and reference to the list of
- # virtual CPU IDs, belonging to the chip as a value
- @chip_list, # List of all chip_id values
- $ctree, # The component tree
- );
-
-#
-# Get information about each CPU.
-#
-# Collect list of all CPUs in @cpu_list array
-#
-# Construct %cpu_list hash keyed by CPU ID with cpu_info kstat hash as its
-# value.
-#
-# Construct %chips hash keyed by chip ID. It has a 'cpus' entry, which is
-# a reference to a list of CPU IDs within a chip.
-#
-foreach my $id (nsort(keys %$cpu_info)) {
- # $id is CPU id
- my $info = $cpu_info->{$id};
-
- #
- # The name part of the cpu_info kstat should always be a string
- # cpu_info$id.
- #
- # The $ci hash reference holds all data for a specific CPU id.
- #
- my $ci = $info->{"cpu_info$id"} or next;
- # Save CPU-specific information in cpu_list hash, indexed by CPU ID.
- $cpu_list{$id} = $ci;
- my $chip_id = $ci->{'chip_id'};
- # Collect CPUs within the chip.
- # $chips{$chip_id} is a reference to a list of CPU IDs belonging to thie
- # chip. It is automatically created when first referenced.
- push (@{$chips{$chip_id}}, $id) if (defined($chip_id));
- # Collect list of CPU IDs in @cpus
- push (@all_cpus, $id);
-}
-
-#
-# Figure out what CPUs to examine.
-# Look at specific CPUs if any are specified on the command line or at all CPUs
-# CPU ranges specified in the command line are expanded into lists of CPUs
-#
-if (scalar(@ARGV) == 0) {
- @cpu_args = @all_cpus;
-} else {
- # Expand all x-y intervals in the argument list
- @cpu_args = map { expand($_) } @ARGV;
-
- usage(gettext("must specify exactly one processor if -s used")) if
- (($verbosity == 0) && scalar @cpu_args != 1);
-
- # Detect invalid CPUs in the arguments
- my @bad_args = set_subtract(\@all_cpus, \@cpu_args);
- my $nbadargs = scalar @bad_args;
-
- if ($nbadargs != 0) {
- # Warn user about bad CPUs in the command line
- my $argstr = collapse(@bad_args);
-
- if ($nbadargs > 1) {
- printf STDERR gettext("%s: Invalid processors %s\n"),
- $cmdname, $argstr;
- } else {
- printf STDERR
- gettext("%s: processor %s: Invalid argument\n"),
- $cmdname, $argstr;
- }
- $errors = 2;
- }
-
- @cpu_args = uniqsort(intersect(\@all_cpus, \@cpu_args));
-}
-
-#
-# In physical view, CPUs specified in the command line are only used to identify
-# chips. The actual CPUs are all CPUs belonging to these chips.
-#
-if (! $phys_view) {
- @cpus = @cpu_args;
-} else {
- # Get list of chips spanning all CPUs specified
- @chip_list = property_list('chip_id', @cpu_args);
- if (!scalar @chip_list && $errors == 0) {
- printf STDERR
- gettext("%s: Physical processor view not supported\n"),
- $cmdname;
- exit(1);
- }
-
- # Get list of all CPUs within these chips
- @cpus = uniqsort(map { @{$chips{$_}} } @chip_list);
-}
-
-
-if ($phys_verbose) {
- #
- # 1) Look at all possible xxx_id properties and remove those that have
- # NCPU values or one value. Sort the rest.
- #
- # 2) Drop ids which have the same number of entries as number of CPUs or
- # number of chips.
- #
- # 3) Build the component tree for the system
- #
- foreach my $id (keys %$cpu_info) {
- my $info = $cpu_info->{$id};
- my $name = "cpu_info$id";
- my $ci = $info->{$name}; # cpu_info kstat for this CPU
-
- # Collect all statistic names matching $valid_id_exp
- push @id_list, grep(/$valid_id_exp/, keys(%$ci));
- }
-
- # Remove duplicates
- @id_list = uniq(@id_list);
-
- my $ncpus = scalar @cpus;
- my %prop_nvals; # Number of instances of each property
- my $nchips = scalar @chip_list;
-
- #
- # Get list of properties which have more than ncpus and less than nchips
- # instances.
- # Also collect number of instances for each property.
- #
- @id_list = grep {
- my @ids = property_list($_, @cpus);
- my $nids = scalar @ids;
- $prop_nvals{$_} = $nids;
- ($_ eq "chip_id") ||
- (($nids > $nchips) && ($nids > 1) && ($nids < $ncpus));
- } @id_list;
-
- # Sort @id_list by number of instances for each property
- @id_list = sort { $prop_nvals{$a} <=> $prop_nvals{$b} } @id_list;
-
- $ctree = build_component_tree(\@cpus, \@id_list);
-}
-
-
-#
-# Walk all CPUs specified and print information about them.
-# Do nothing for physical view - will do everything later.
-#
-foreach my $id (@cpus) {
- last if $phys_view; # physical view is handled later
- my $cpu = $cpu_list{$id} or next;
-
- # Get CPU state and its modification time
- my $mtime = $cpu->{'state_begin'};
- my $mstring = strftime(gettext("%m/%d/%Y %T"), localtime($mtime));
- my $status = $cpu->{'state'} || gettext("unknown");
- # Get localized version of CPU status
- $status = $cpu_states{$status} || $status;
-
- if ($verbosity == 0) {
- # Print 1 if CPU is online, 0 if offline.
- printf "%d\n", $status eq 'on-line';
- } elsif (! ($verbosity & 2)) {
- printf gettext("%d\t%-8s since %s\n"),
- $id, $status, $mstring;
- } else {
- printf gettext("Status of virtual processor %d as of: "), $id;
- print strftime(gettext("%m/%d/%Y %T"), localtime());
- print "\n";
- printf gettext(" %s since %s.\n"), $status, $mstring;
- my $clock_speed = $cpu->{'clock_MHz'};
- my $cpu_type = $cpu->{'cpu_type'};
-
- # Display clock speed
- if ($clock_speed ) {
- printf
- gettext(" The %s processor operates at %s MHz,\n"),
- $cpu_type, $clock_speed;
- } else {
- printf
- gettext(" the %s processor operates at an unknown frequency,\n"),
- $cpu_type;
- }
-
- # Display FPU type
- my $fpu = $cpu->{'fpu_type'};
- if (! $fpu) {
- print
- gettext("\tand has no floating point processor.\n");
- } elsif ($fpu =~ m/^[aeiouy]/) {
- printf
- gettext("\tand has an %s floating point processor.\n"),
- $fpu;
- } else {
- printf
- gettext("\tand has a %s floating point processor.\n"),
- $fpu;
- }
- }
-}
-
-#
-# Physical view print
-#
-if ($phys_view) {
- if ($verbosity == 1) {
- print scalar @chip_list, "\n";
- } elsif ($verbosity == 0) {
- # Print 1 if all CPUs are online, 0 otherwise.
- foreach my $chip_id (@chip_list) {
- # Get CPUs on a chip
- my @chip_cpus = uniqsort(@{$chips{$chip_id}});
- # List of all on-line CPUs on a chip
- my @online_cpus = grep {
- ($cpu_list{$_}->{state}) eq 'on-line'
- } @chip_cpus;
-
- #
- # Print 1 if number of online CPUs equals number of all
- # CPUs
- #
- printf
- "%d\n", scalar @online_cpus == scalar @chip_cpus;
- }
- } else {
- # Walk the property tree and print everything in it.
- my $tcores = $ctree->{values};
- my $cname = id_translate($ctree->{name});
- foreach my $chip (nsort(keys %$tcores)) {
- my $chipref = $tcores->{$chip};
- my @chip_cpus = @{$chipref->{cpus}};
- my $ncpus = scalar @chip_cpus;
- my $cpu_id = $chip_cpus[0];
- my $cpu = $cpu_list{$cpu_id};
- my $brand = $cpu->{brand} || gettext("(unknown)");
- my $impl = $cpu->{implementation} ||
- gettext("(unknown)");
- my $socket = $cpu->{socket_type};
- #
- # Remove cpuid and chipid information from
- # implementation string and print it.
- #
- $impl =~ s/(cpuid|chipid)\s*\w+\s+//;
- $brand = '' if $impl && $impl =~ /^$brand/;
- # List of CPUs on a chip
- my $cpu_name = pluralize('processor', $ncpus);
- # Collapse range of CPUs into a-b string
- my $cl = collapse(@chip_cpus);
- my $childname = $chipref->{name};
- if (! $childname) {
- printf gettext("%s has %d virtual %s "),
- $cname, $ncpus, $cpu_name;
- print "($cl)\n";
- print " $impl\n" if $impl;
- print "\t$brand" if $brand;
- print "\t[ Socket: $socket ]" if $socket &&
- $socket ne "Unknown";
- print "\n";
- } else {
- # Get child count
- my $nchildren =
- scalar(keys(%{$chipref->{values}}));
- $childname = pluralize($childname, $nchildren);
- printf
- gettext("%s has %d %s and %d virtual %s "),
- $cname, $nchildren, $childname, $ncpus,
- $cpu_name;
- print "($cl)\n";
- my $ident = print_component_tree ($chipref, 2);
- my $spaces = ' ' x $ident;
- print "$spaces$impl\n" if $impl;
- print "$spaces $brand\n" if $brand;
- }
- }
- }
-}
-
-exit($errors);
-
-__END__
-
-# The psrinfo command displays information about virtual and physical processors
-# in a system. It gets all the information from the 'cpu_info' kstat.
-#
-# See detailed comment in the end of this file.
-#
-#
-#
-# This kstat
-# has the following components:
-#
-# module: cpu_info
-# instance: CPU ID
-# name: cpu_infoID where ID is CPU ID
-# class: misc
-#
-# The psrinfo command translates this information from kstat-specific
-# representation to user-friendly format.
-#
-# The psrinfo command has several basic modes of operations:
-#
-# 1) Without options, it displays a line per CPU with CPU ID and its status and
-# the time the status was last set in the following format:
-#
-# 0 on-line since MM/DD/YYYY HH:MM:SS
-# 1 on-line since MM/DD/YYYY HH:MM:SS
-# ...
-#
-# In this mode, the psrinfo command walks the list of CPUs (either from a
-# command line or all CPUs) and prints the 'state' and 'state_begin' fields
-# of cpu_info kstat structure for each CPU. The 'state_begin' is converted to
-# local time.
-#
-# 2) With -s option and a single CPU ID as an argument, it displays 1 if the CPU
-# is online and 0 otherwise.
-#
-# 3) With -p option, it displays the number of physical processors in a system.
-# If any CPUs are specified in the command line, it displays the number of
-# physical processors containing all virtual CPUs specified. The physical
-# processor is identified by the 'chip_id' field of the cpu_info kstat.
-#
-# The code just walks over all CPUs specified and checks how many different
-# core_id values they span.
-#
-# 4) With -v option, it displays several lines of information per virtual CPU,
-# including its status, type, operating speed and FPU type. For example:
-#
-# Status of virtual processor 0 as of: MM/DD/YYYY HH:MM:SS
-# on-line since MM/DD/YYYY HH:MM:SS.
-# The i386 processor operates at XXXX MHz,
-# and has an i387 compatible floating point processor.
-# Status of virtual processor 1 as of: MM/DD/YYYY HH:MM:SS
-# on-line since MM/DD/YYYY HH:MM:SS.
-# The i386 processor operates at XXXX MHz,
-# and has an i387 compatible floating point processor.
-#
-# This works in the same way as 1), just more kstat fields are massaged in the
-# output.
-#
-# 5) With -vp option, it reports additional information about each physical
-# processor. This information includes information about sub-components of
-# each physical processor and virtual CPUs in each sub-component. For
-# example:
-#
-# The physical processor has 2 cores and 4 virtual processors (0-3)
-# The core has 2 virtual processors (0 1)
-# The core has 2 virtual processors (2 3)
-# x86 (GenuineIntel family 15 model 4 step 4 clock 3211 MHz)
-# Intel(r) Pentium(r) D CPU 3.20GHz
-#
-# The implementation does not know anything about physical CPU components
-# such as cores. Instead it looks at various cpu_info kstat statistics that
-# look like xxx_id and tries to reconstruct the CPU hierarchy based on these
-# fields. This works as follows:
-#
-# a) All kstats statistic names matching the $valid_id_exp regular expression
-# are examined and each kstat statistic name is associated with the number
-# of distinct entries in it.
-#
-# b) The resulting list of kstat statistic names is sorted according to the
-# number of distinct entries, matching each name. For example, there are
-# fewer chip_id values than core_id values. This implies that the core is
-# a sub-component of a chip.
-#
-# c) All kstat names that have the same number of values as the number of
-# physical processors ('chip_id' values) or the number of virtual
-# processors are removed from the list.
-#
-# d) The resulting list represents the CPU hierarchy of the machine. It is
-# translated into a tree showing the hardware hierarchy. Each level of the
-# hierarchy contains the name, reference to a list of CPUs at this level
-# and subcomponents, indexed by the value of each component.
-# The example system above is represented by the following tree:
-#
-# $tree =
-# {
-# 'name' => 'chip_id',
-# 'cpus' => [ '0', '1', '2', '3' ]
-# 'values' =>
-# {
-# '0' =>
-# {
-# 'name' => 'core_id',
-# 'cpus' => [ '0', '1', '2', '3' ]
-# 'values' =>
-# {
-# '0' => { 'cpus' => [ '0', '1' ] }
-# '1' => { 'cpus' => [ '2', '3' ] },
-# },
-# }
-# },
-# };
-#
-# Each node contains reference to a list of virtual CPUs at this level of
-# hierarchy - one list for a system as a whole, one for chip 0 and one two
-# for each cores. node. Non-leaf nodes also contain the symbolic name of
-# the component as represented in the cpu_info kstat and a hash of
-# subnodes, indexed by the value of the component. The tree is built by
-# the build_component_tree() function.
-#
-# e) The resulting tree is pretty-printed showing the number of
-# sub-components and virtual CPUs in each sub-component. The tree is
-# printed by the print_component_tree() function.
-#
diff --git a/usr/src/cmd/savecore/savecore.c b/usr/src/cmd/savecore/savecore.c
index 4042d8f3ab..2bd0517055 100644
--- a/usr/src/cmd/savecore/savecore.c
+++ b/usr/src/cmd/savecore/savecore.c
@@ -22,6 +22,9 @@
* Copyright (c) 1983, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, Joyent, Inc. All rights reserved.
*/
+/*
+ * Copyright 2012 Nexenta Systems, Inc. All rights reserved.
+ */
#include <stdio.h>
#include <stdlib.h>
@@ -219,6 +222,13 @@ logprint(uint32_t flags, char *message, ...)
break;
case SC_EXIT_PEND:
+ /*
+ * Raise an ireport saying why we are exiting. Do not
+ * raise if run as savecore -m. If something in the
+ * raise_event codepath calls logprint avoid recursion.
+ */
+ if (!mflag && logprint_raised++ == 0)
+ raise_event(SC_EVENT_SAVECORE_FAILURE, buf);
code = 2;
break;
@@ -228,11 +238,6 @@ logprint(uint32_t flags, char *message, ...)
case SC_EXIT_ERR:
default:
- /*
- * Raise an ireport saying why we are exiting. Do not
- * raise if run as savecore -m. If something in the
- * raise_event codepath calls logprint avoid recursion.
- */
if (!mflag && logprint_raised++ == 0)
raise_event(SC_EVENT_SAVECORE_FAILURE, buf);
code = 1;
@@ -357,7 +362,7 @@ read_dumphdr(void)
pagesize = dumphdr.dump_pagesize;
if (dumphdr.dump_magic != DUMP_MAGIC)
- logprint(SC_SL_NONE | SC_EXIT_OK, "bad magic number %x",
+ logprint(SC_SL_NONE | SC_EXIT_PEND, "bad magic number %x",
dumphdr.dump_magic);
if ((dumphdr.dump_flags & DF_VALID) == 0 && !disregard_valid_flag)
@@ -365,18 +370,18 @@ read_dumphdr(void)
"dump already processed");
if (dumphdr.dump_version != DUMP_VERSION)
- logprint(SC_SL_NONE | SC_IF_VERBOSE | SC_EXIT_OK,
+ logprint(SC_SL_NONE | SC_IF_VERBOSE | SC_EXIT_PEND,
"dump version (%d) != %s version (%d)",
dumphdr.dump_version, progname, DUMP_VERSION);
if (dumphdr.dump_wordsize != DUMP_WORDSIZE)
- logprint(SC_SL_NONE | SC_EXIT_OK,
+ logprint(SC_SL_NONE | SC_EXIT_PEND,
"dump is from %u-bit kernel - cannot save on %u-bit kernel",
dumphdr.dump_wordsize, DUMP_WORDSIZE);
if (datahdr.dump_datahdr_magic == DUMP_DATAHDR_MAGIC) {
if (datahdr.dump_datahdr_version != DUMP_DATAHDR_VERSION)
- logprint(SC_SL_NONE | SC_IF_VERBOSE | SC_EXIT_OK,
+ logprint(SC_SL_NONE | SC_IF_VERBOSE | SC_EXIT_PEND,
"dump data version (%d) != %s data version (%d)",
datahdr.dump_datahdr_version, progname,
DUMP_DATAHDR_VERSION);
diff --git a/usr/src/cmd/smbsrv/smbd/Makefile b/usr/src/cmd/smbsrv/smbd/Makefile
index fd3e41d8ad..4f460c1ed8 100644
--- a/usr/src/cmd/smbsrv/smbd/Makefile
+++ b/usr/src/cmd/smbsrv/smbd/Makefile
@@ -20,6 +20,7 @@
#
#
# Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright 2012 Nexenta Systems, Inc. All rights reserved.
#
@@ -55,6 +56,8 @@ LDLIBS += -L$(ROOT)/usr/lib/smbsrv -lmlsvc -lmlrpc -lsmbns -lsmb \
-lzfs -lbsm -lsocket -lnsl -lscf -lumem -lcmdutils
LDFLAGS += -R/usr/lib/smbsrv
+$(ENABLE_SMB_PRINTING) CPPFLAGS += -DHAVE_CUPS
+
ROOTSMBDDIR = $(ROOTLIB)/smbsrv
ROOTSMBDFILE = $(PROG:%=$(ROOTSMBDDIR)/%)
diff --git a/usr/src/cmd/smbsrv/smbd/smbd_spool.c b/usr/src/cmd/smbsrv/smbd/smbd_spool.c
index 107a2ddbad..844484e918 100644
--- a/usr/src/cmd/smbsrv/smbd/smbd_spool.c
+++ b/usr/src/cmd/smbsrv/smbd/smbd_spool.c
@@ -20,7 +20,7 @@
*/
/*
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
+ * Copyright 2012 Nexenta Systems, Inc. All rights reserved.
*/
/*
@@ -29,7 +29,6 @@
#include <sys/types.h>
#include <sys/stat.h>
-#include <cups/cups.h>
#include <strings.h>
#include <syslog.h>
#include <signal.h>
@@ -41,6 +40,9 @@
#include <smbsrv/smb_share.h>
#include "smbd.h"
+#ifdef HAVE_CUPS
+#include <cups/cups.h>
+
#define SMB_SPOOL_WAIT 2
#define SMBD_PJOBLEN 256
#define SMBD_PRINTER "Postscript"
@@ -512,3 +514,47 @@ smbd_print_share_comment(smb_share_t *si, cups_dest_t *dest)
(void) strlcpy(si->shr_cmnt, comment, SMB_SHARE_CMNT_MAX);
}
+
+#else /* HAVE_CUPS */
+
+/*
+ * If not HAVE_CUPS, just provide a few "stubs".
+ */
+
+int
+smbd_cups_init(void)
+{
+ return (ENOENT);
+}
+
+void
+smbd_cups_fini(void)
+{
+}
+
+void
+smbd_load_printers(void)
+{
+}
+
+void
+smbd_spool_init(void)
+{
+}
+
+void
+smbd_spool_fini(void)
+{
+}
+
+void
+smbd_spool_start(void)
+{
+}
+
+void
+smbd_spool_stop(void)
+{
+}
+
+#endif /* HAVE_CUPS */
diff --git a/usr/src/cmd/su/su.c b/usr/src/cmd/su/su.c
index e878077368..c1e6849263 100644
--- a/usr/src/cmd/su/su.c
+++ b/usr/src/cmd/su/su.c
@@ -20,6 +20,7 @@
*/
/*
* Copyright (c) 1988, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright 2012 Milan Jurik. All rights reserved.
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
/* All Rights Reserved */
@@ -535,6 +536,10 @@ ok:
malloc(strlen(initenv[j])
+ strlen(initvar)
+ 2);
+ if (var == NULL) {
+ perror("malloc");
+ exit(4);
+ }
(void) strcpy(var, initenv[j]);
(void) strcat(var, "=");
(void) strcat(var, initvar);
diff --git a/usr/src/cmd/svc/configd/restore_repository.sh b/usr/src/cmd/svc/configd/restore_repository.sh
index 3d84c68c21..0c8e4bab54 100644
--- a/usr/src/cmd/svc/configd/restore_repository.sh
+++ b/usr/src/cmd/svc/configd/restore_repository.sh
@@ -21,6 +21,7 @@
# CDDL HEADER END
#
#
+# Copyright 2012 Nexenta Sysytems, Inc. All rights reserved.
# Copyright 2005 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
@@ -91,7 +92,7 @@ this script to restore backup copies of the smf(5) repository.
If there are any problems which need human intervention, this script will
give instructions and then exit back to your shell."
-if [ "$myroot" -eq / ]; then
+if [ "$myroot" = "/" ]; then
system="system"
[ "`/sbin/zonename`" != global ] && system="zone"
echo >&2 "
diff --git a/usr/src/cmd/svc/startd/Makefile b/usr/src/cmd/svc/startd/Makefile
index 3a0908828b..1df70d64dd 100644
--- a/usr/src/cmd/svc/startd/Makefile
+++ b/usr/src/cmd/svc/startd/Makefile
@@ -20,6 +20,7 @@
#
#
# Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright 2012 Milan Jurik. All rights reserved.
#
PROG = svc.startd
@@ -61,6 +62,7 @@ include ../../Makefile.ctf
ROOTCMDDIR= $(ROOT)/lib/svc/bin
+$(NOT_RELEASE_BUILD)CPPFLAGS += -DDEBUG
CFLAGS += -v
CPPFLAGS += -I. -I../common
diff --git a/usr/src/cmd/svc/startd/libscf.c b/usr/src/cmd/svc/startd/libscf.c
index 96a7bcef1f..c4a3b20117 100644
--- a/usr/src/cmd/svc/startd/libscf.c
+++ b/usr/src/cmd/svc/startd/libscf.c
@@ -21,6 +21,7 @@
/*
* Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright 2012 Milan Jurik. All rights reserved.
*/
@@ -1850,6 +1851,7 @@ libscf_extract_runlevel(scf_property_t *prop, char *rlp)
val = safe_scf_value_create(scf_property_handle(prop));
if (scf_property_get_value(prop, val) != 0) {
+ scf_value_destroy(val);
switch (scf_error()) {
case SCF_ERROR_CONNECTION_BROKEN:
return (ECONNABORTED);
@@ -1875,12 +1877,15 @@ libscf_extract_runlevel(scf_property_t *prop, char *rlp)
}
if (scf_value_get_astring(val, buf, sizeof (buf)) < 0) {
+ scf_value_destroy(val);
if (scf_error() != SCF_ERROR_TYPE_MISMATCH)
bad_error("scf_value_get_astring", scf_error());
return (EINVAL);
}
+ scf_value_destroy(val);
+
if (buf[0] == '\0' || buf[1] != '\0')
return (EINVAL);
diff --git a/usr/src/cmd/svc/svccfg/svccfg_libscf.c b/usr/src/cmd/svc/svccfg/svccfg_libscf.c
index b32c8d453f..5e4ffc412a 100644
--- a/usr/src/cmd/svc/svccfg/svccfg_libscf.c
+++ b/usr/src/cmd/svc/svccfg/svccfg_libscf.c
@@ -22,6 +22,7 @@
/*
* Copyright (c) 2004, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, Joyent, Inc. All rights reserved.
+ * Copyright 2012 Milan Jurik. All rights reserved.
*/
@@ -3905,8 +3906,8 @@ upgrade_manifestfiles(pgroup_t *pg, const entity_t *ient,
pgroup_t *mfst_pgroup;
property_t *mfst_prop;
property_t *old_prop;
- char *pname = malloc(MAXPATHLEN);
- char *fval = NULL;
+ char *pname;
+ char *fval;
char *old_pname;
char *old_fval;
int no_upgrade_pg;
@@ -3976,6 +3977,13 @@ upgrade_manifestfiles(pgroup_t *pg, const entity_t *ient,
SCF_SUCCESS)
return (-1);
+ if ((pname = malloc(MAXPATHLEN)) == NULL)
+ return (ENOMEM);
+ if ((fval = malloc(MAXPATHLEN)) == NULL) {
+ free(pname);
+ return (ENOMEM);
+ }
+
while ((r = scf_iter_next_property(ud_prop_iter, ud_prop)) == 1) {
mfst_seen = 0;
if (scf_property_get_name(ud_prop, pname, MAXPATHLEN) < 0)
@@ -3995,16 +4003,12 @@ upgrade_manifestfiles(pgroup_t *pg, const entity_t *ient,
* property list to get proccessed into the repo.
*/
if (mfst_seen == 0) {
- if (fval == NULL)
- fval = malloc(MAXPATHLEN);
-
/*
* If we cannot get the value then there is no
* reason to attempt to attach the value to
* the property group
*/
- if (fval != NULL &&
- prop_get_val(ud_prop, fname_value) == 0 &&
+ if (prop_get_val(ud_prop, fname_value) == 0 &&
scf_value_get_astring(fname_value, fval,
MAXPATHLEN) != -1) {
old_pname = safe_strdup(pname);
@@ -4021,6 +4025,7 @@ upgrade_manifestfiles(pgroup_t *pg, const entity_t *ient,
}
}
}
+ free(pname);
free(fval);
cbdata.sc_handle = g_hndl;
diff --git a/usr/src/cmd/tail/Makefile b/usr/src/cmd/tail/Makefile
index d1e2eda647..293920cfd1 100644
--- a/usr/src/cmd/tail/Makefile
+++ b/usr/src/cmd/tail/Makefile
@@ -23,7 +23,7 @@ SRCS= $(OBJS:%.o=%.c)
include ../Makefile.cmd
CLOBBERFILES= $(PROG)
-
+CPPFLAGS += -D_LARGEFILE_SOURCE -D_FILE_OFFSET_BITS=64
C99MODE= -xc99=%all
C99LMODE= -Xc99=%all
diff --git a/usr/src/cmd/tar/tar.c b/usr/src/cmd/tar/tar.c
index d6e39db1dd..6cb084e9d0 100644
--- a/usr/src/cmd/tar/tar.c
+++ b/usr/src/cmd/tar/tar.c
@@ -20,6 +20,7 @@
*/
/*
* Copyright (c) 1988, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright 2012 Milan Jurik. All rights reserved.
*/
/* Copyright (c) 1983, 1984, 1985, 1986, 1987, 1988, 1989 AT&T */
@@ -548,11 +549,14 @@ static void compress_back(void);
static void decompress_file(void);
static pid_t uncompress_file(void);
static void *compress_malloc(size_t);
-static void check_compression();
-static char *bz_suffix();
-static char *gz_suffix();
+static void check_compression(void);
+static char *bz_suffix(void);
+static char *gz_suffix(void);
+static char *xz_suffix(void);
static char *add_suffix();
static void wait_pid(pid_t);
+static void verify_compress_opt(const char *t);
+static void detect_compress(void);
static struct stat stbuf;
@@ -572,6 +576,8 @@ static int Dflag; /* Data change flag */
static int jflag; /* flag to use 'bzip2' */
static int zflag; /* flag to use 'gzip' */
static int Zflag; /* flag to use 'compress' */
+static int Jflag; /* flag to use 'xz' */
+static int aflag; /* flag to use autocompression */
/* Trusted Extensions */
static int Tflag; /* Trusted Extensions attr flags */
@@ -693,17 +699,21 @@ int waitaround = 0; /* wait for rendezvous with the debugger */
#define BZIP "/usr/bin/bzip2"
#define GZIP "/usr/bin/gzip"
#define COMPRESS "/usr/bin/compress"
+#define XZ "/usr/bin/xz"
#define BZCAT "/usr/bin/bzcat"
#define GZCAT "/usr/bin/gzcat"
#define ZCAT "/usr/bin/zcat"
-#define GS 8 /* number of valid 'gzip' sufixes */
-#define BS 4 /* number of valid 'bzip2' sufixes */
+#define XZCAT "/usr/bin/xzcat"
+#define GSUF 8 /* number of valid 'gzip' sufixes */
+#define BSUF 4 /* number of valid 'bzip2' sufixes */
+#define XSUF 1 /* number of valid 'xz' suffixes */
static char *compress_opt; /* compression type */
static char *gsuffix[] = {".gz", "-gz", ".z", "-z", "_z", ".Z",
".tgz", ".taz"};
static char *bsuffix[] = {".bz2", ".bz", ".tbz2", ".tbz"};
+static char *xsuffix[] = {".xz"};
static char *suffix;
@@ -897,13 +907,19 @@ main(int argc, char *argv[])
pflag++; /* also set flag for ACL */
break;
case 'j': /* compession "bzip2" */
- jflag++;
+ jflag = 1;
break;
case 'z': /* compression "gzip" */
- zflag++;
+ zflag = 1;
break;
case 'Z': /* compression "compress" */
- Zflag++;
+ Zflag = 1;
+ break;
+ case 'J': /* compression "xz" */
+ Jflag = 1;
+ break;
+ case 'a':
+ aflag = 1; /* autocompression */
break;
default:
(void) fprintf(stderr, gettext(
@@ -919,10 +935,9 @@ main(int argc, char *argv[])
usage();
}
if (cflag) {
- if ((zflag && jflag) || (zflag && Zflag) ||
- (jflag && Zflag)) {
+ if ((jflag + zflag + Zflag + Jflag + aflag) > 1) {
(void) fprintf(stderr, gettext(
- "tar: specify only one of [jzZ] to "
+ "tar: specify only one of [ajJzZ] to "
"create a compressed file.\n"));
usage();
}
@@ -992,6 +1007,9 @@ main(int argc, char *argv[])
if (rflag) {
if (cflag && usefile != NULL) {
/* Set the compression type */
+ if (aflag)
+ detect_compress();
+
if (jflag) {
compress_opt = compress_malloc(strlen(BZIP)
+ 1);
@@ -1004,6 +1022,9 @@ main(int argc, char *argv[])
compress_opt =
compress_malloc(strlen(COMPRESS) + 1);
(void) strcpy(compress_opt, COMPRESS);
+ } else if (Jflag) {
+ compress_opt = compress_malloc(strlen(XZ) + 1);
+ (void) strcpy(compress_opt, XZ);
}
} else {
/*
@@ -1167,7 +1188,7 @@ usage(void)
#else
"Usage: tar {c|r|t|u|x}[BDeEFhilmnopPTvw[0-7]][bf][X...] "
#endif /* O_XATTR */
- "[j|z|Z] "
+ "[j|J|z|Z] "
"[blocksize] [tarfile] [size] [exclude-file...] "
"{file | -I include-file | -C directory file}...\n"));
done(1);
@@ -9158,6 +9179,7 @@ compress_back()
usefile, compress_opt);
}
if ((pid = fork()) == 0) {
+ verify_compress_opt(compress_opt);
(void) execlp(compress_opt, compress_opt,
usefile, NULL);
} else if (pid == -1) {
@@ -9174,18 +9196,16 @@ compress_back()
#define GZIP_MAGIC "\037\213"
#define BZIP_MAGIC "BZh"
#define COMP_MAGIC "\037\235"
+#define XZ_MAGIC "\375\067\172\130\132\000"
void
-check_compression()
+check_compression(void)
{
- char magic[2];
- char buf[16];
+ char magic[16];
FILE *fp;
if ((fp = fopen(usefile, "r")) != NULL) {
- (void) fread(buf, sizeof (char), 6, fp);
- magic[0] = buf[0];
- magic[1] = buf[1];
+ (void) fread(magic, sizeof (char), 6, fp);
(void) fclose(fp);
}
@@ -9213,6 +9233,14 @@ check_compression()
compress_opt = compress_malloc(strlen(COMPRESS) + 1);
(void) strcpy(compress_opt, COMPRESS);
}
+ } else if (memcmp(magic, XZ_MAGIC, 6) == 0) {
+ if (xflag || tflag) {
+ compress_opt = compress_malloc(strlen(XZCAT) + 1);
+ (void) strcpy(compress_opt, XZCAT);
+ } else if (uflag || rflag) {
+ compress_opt = compress_malloc(strlen(XZ) + 1);
+ (void) strcpy(compress_opt, XZ);
+ }
}
}
@@ -9235,6 +9263,11 @@ add_suffix()
strlcat(tfname, bsuffix[0], sizeof (tfname));
return (bsuffix[0]);
}
+ } else if (strcmp(compress_opt, XZ) == 0) {
+ if ((suffix = xz_suffix()) == NULL) {
+ strlcat(tfname, xsuffix[0], sizeof (tfname));
+ return (xsuffix[0]);
+ }
}
return (NULL);
}
@@ -9260,6 +9293,7 @@ decompress_file(void)
gettext("Decompressing '%s' with "
"'%s'...\n"), usefile, compress_opt);
}
+ verify_compress_opt(compress_opt);
(void) execlp(compress_opt, compress_opt, "-df",
tfname, NULL);
vperror(1, gettext("Could not exec %s"), compress_opt);
@@ -9297,6 +9331,7 @@ compress_file(void)
(void) dup2(fd[0], STDIN_FILENO);
(void) close(fd[1]);
(void) dup2(mt, STDOUT_FILENO);
+ verify_compress_opt(compress_opt);
(void) execlp(compress_opt, compress_opt, NULL);
vperror(1, gettext("Could not exec %s"), compress_opt);
return (0); /*NOTREACHED*/
@@ -9325,45 +9360,49 @@ uncompress_file(void)
(void) dup2(fd[1], STDOUT_FILENO);
(void) close(fd[0]);
(void) dup2(mt, STDIN_FILENO);
+ verify_compress_opt(compress_opt);
(void) execlp(compress_opt, compress_opt, NULL);
vperror(1, gettext("Could not exec %s"), compress_opt);
return (0); /*NOTREACHED*/
}
-/* Checking valid 'bzip2' suffix */
+/* Checking suffix validity */
char *
-bz_suffix()
+check_suffix(char **suf, int size)
{
int i;
int slen;
int nlen = strlen(usefile);
- for (i = 0; i < BS; i++) {
- slen = strlen(bsuffix[i]);
+ for (i = 0; i < size; i++) {
+ slen = strlen(suf[i]);
if (nlen < slen)
return (NULL);
- if (strcmp(usefile + nlen - slen, bsuffix[i]) == 0)
- return (bsuffix[i]);
+ if (strcmp(usefile + nlen - slen, suf[i]) == 0)
+ return (suf[i]);
}
return (NULL);
}
+/* Checking valid 'bzip2' suffix */
+char *
+bz_suffix(void)
+{
+ return (check_suffix(bsuffix, BSUF));
+}
+
/* Checking valid 'gzip' suffix */
char *
-gz_suffix()
+gz_suffix(void)
{
- int i;
- int slen;
- int nlen = strlen(usefile);
+ return (check_suffix(gsuffix, GSUF));
+}
- for (i = 0; i < GS; i++) {
- slen = strlen(gsuffix[i]);
- if (nlen < slen)
- return (NULL);
- if (strcmp(usefile + nlen - slen, gsuffix[i]) == 0)
- return (gsuffix[i]);
- }
- return (NULL);
+/* Checking valid 'xz' suffix */
+char *
+xz_suffix(void)
+{
+ return (check_suffix(xsuffix, XSUF));
}
void *
@@ -9386,3 +9425,30 @@ wait_pid(pid_t pid)
while (waitpid(pid, &status, 0) == -1 && errno == EINTR)
;
}
+
+static void
+verify_compress_opt(const char *t)
+{
+ struct stat statbuf;
+
+ if (stat(t, &statbuf) == -1)
+ vperror(1, "%s %s: %s\n", gettext("Could not stat"),
+ t, strerror(errno));
+}
+
+static void
+detect_compress(void)
+{
+ char *zsuf[] = {".Z"};
+ if (check_suffix(zsuf, 1) != NULL) {
+ Zflag = 1;
+ } else if (check_suffix(bsuffix, BSUF) != NULL) {
+ jflag = 1;
+ } else if (check_suffix(gsuffix, GSUF) != NULL) {
+ zflag = 1;
+ } else if (check_suffix(xsuffix, XSUF) != NULL) {
+ Jflag = 1;
+ } else {
+ vperror(1, "%s\n", gettext("No compression method detected"));
+ }
+}
diff --git a/usr/src/cmd/truss/codes.c b/usr/src/cmd/truss/codes.c
index 93ffe17ad5..4162c8b661 100644
--- a/usr/src/cmd/truss/codes.c
+++ b/usr/src/cmd/truss/codes.c
@@ -23,6 +23,7 @@
* Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012 by Delphix. All rights reserved.
* Copyright 2011 Nexenta Systems, Inc. All rights reserved.
+ * Copyright (c) 2012, Joyent, Inc. All rights reserved.
*/
/* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
@@ -1250,12 +1251,22 @@ const struct ioc {
"zfs_cmd_t" },
{ (uint_t)ZFS_IOC_SPACE_WRITTEN, "ZFS_IOC_SPACE_WRITTEN",
"zfs_cmd_t" },
- { (uint_t)ZFS_IOC_DESTROY_SNAPS_NVL, "ZFS_IOC_DESTROY_SNAPS_NVL",
+ { (uint_t)ZFS_IOC_DESTROY_SNAPS, "ZFS_IOC_DESTROY_SNAPS",
"zfs_cmd_t" },
{ (uint_t)ZFS_IOC_POOL_REGUID, "ZFS_IOC_POOL_REGUID",
"zfs_cmd_t" },
{ (uint_t)ZFS_IOC_POOL_REOPEN, "ZFS_IOC_POOL_REOPEN",
"zfs_cmd_t" },
+ { (uint_t)ZFS_IOC_SEND_PROGRESS, "ZFS_IOC_SEND_PROGRESS",
+ "zfs_cmd_t" },
+ { (uint_t)ZFS_IOC_LOG_HISTORY, "ZFS_IOC_LOG_HISTORY",
+ "zfs_cmd_t" },
+ { (uint_t)ZFS_IOC_SEND_NEW, "ZFS_IOC_SEND_NEW",
+ "zfs_cmd_t" },
+ { (uint_t)ZFS_IOC_SEND_SPACE, "ZFS_IOC_SEND_SPACE",
+ "zfs_cmd_t" },
+ { (uint_t)ZFS_IOC_CLONE, "ZFS_IOC_CLONE",
+ "zfs_cmd_t" },
/* kssl ioctls */
{ (uint_t)KSSL_ADD_ENTRY, "KSSL_ADD_ENTRY",
diff --git a/usr/src/cmd/vi/port/ex_cmdsub.c b/usr/src/cmd/vi/port/ex_cmdsub.c
index 7f122a7111..00bdcefccb 100644
--- a/usr/src/cmd/vi/port/ex_cmdsub.c
+++ b/usr/src/cmd/vi/port/ex_cmdsub.c
@@ -39,6 +39,8 @@
#undef getchar
#undef putchar
#endif
+
+
/*
* Command mode subroutines implementing
* append, args, copy, delete, join, move, put,
@@ -1725,12 +1727,11 @@ unsigned char c;
unsigned char *
vgetpass(prompt)
-unsigned char *prompt;
+char *prompt;
{
unsigned char *p;
int c;
static unsigned char pbuf[9];
- char *getpass();
/* In ex mode, let the system hassle with setting no echo */
if (!inopen)
diff --git a/usr/src/cmd/zdb/zdb.c b/usr/src/cmd/zdb/zdb.c
index 194e886219..d462d3f18e 100644
--- a/usr/src/cmd/zdb/zdb.c
+++ b/usr/src/cmd/zdb/zdb.c
@@ -18,8 +18,10 @@
*
* CDDL HEADER END
*/
+
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012 by Delphix. All rights reserved.
*/
#include <stdio.h>
@@ -54,6 +56,8 @@
#include <sys/zfs_fuid.h>
#include <sys/arc.h>
#include <sys/ddt.h>
+#include <sys/zfeature.h>
+#include <zfs_comutil.h>
#undef ZFS_MAXNAMELEN
#undef verify
#include <libzfs.h>
@@ -63,7 +67,8 @@
#define ZDB_CHECKSUM_NAME(idx) ((idx) < ZIO_CHECKSUM_FUNCTIONS ? \
zio_checksum_table[(idx)].ci_name : "UNKNOWN")
#define ZDB_OT_NAME(idx) ((idx) < DMU_OT_NUMTYPES ? \
- dmu_ot[(idx)].ot_name : "UNKNOWN")
+ dmu_ot[(idx)].ot_name : DMU_OT_IS_VALID(idx) ? \
+ dmu_ot_byteswap[DMU_OT_BYTESWAP(idx)].ob_name : "UNKNOWN")
#define ZDB_OT_TYPE(idx) ((idx) < DMU_OT_NUMTYPES ? (idx) : DMU_OT_NUMTYPES)
#ifndef lint
@@ -200,6 +205,27 @@ dump_packed_nvlist(objset_t *os, uint64_t object, void *data, size_t size)
nvlist_free(nv);
}
+/* ARGSUSED */
+static void
+dump_history_offsets(objset_t *os, uint64_t object, void *data, size_t size)
+{
+ spa_history_phys_t *shp = data;
+
+ if (shp == NULL)
+ return;
+
+ (void) printf("\t\tpool_create_len = %llu\n",
+ (u_longlong_t)shp->sh_pool_create_len);
+ (void) printf("\t\tphys_max_off = %llu\n",
+ (u_longlong_t)shp->sh_phys_max_off);
+ (void) printf("\t\tbof = %llu\n",
+ (u_longlong_t)shp->sh_bof);
+ (void) printf("\t\teof = %llu\n",
+ (u_longlong_t)shp->sh_eof);
+ (void) printf("\t\trecords_lost = %llu\n",
+ (u_longlong_t)shp->sh_records_lost);
+}
+
static void
zdb_nicenum(uint64_t num, char *buf)
{
@@ -849,21 +875,22 @@ dump_history(spa_t *spa)
for (int i = 0; i < num; i++) {
uint64_t time, txg, ievent;
char *cmd, *intstr;
+ boolean_t printed = B_FALSE;
if (nvlist_lookup_uint64(events[i], ZPOOL_HIST_TIME,
&time) != 0)
- continue;
+ goto next;
if (nvlist_lookup_string(events[i], ZPOOL_HIST_CMD,
&cmd) != 0) {
if (nvlist_lookup_uint64(events[i],
ZPOOL_HIST_INT_EVENT, &ievent) != 0)
- continue;
+ goto next;
verify(nvlist_lookup_uint64(events[i],
ZPOOL_HIST_TXG, &txg) == 0);
verify(nvlist_lookup_string(events[i],
ZPOOL_HIST_INT_STR, &intstr) == 0);
- if (ievent >= LOG_END)
- continue;
+ if (ievent >= ZFS_NUM_LEGACY_HISTORY_EVENTS)
+ goto next;
(void) snprintf(internalstr,
sizeof (internalstr),
@@ -876,6 +903,14 @@ dump_history(spa_t *spa)
(void) localtime_r(&tsec, &t);
(void) strftime(tbuf, sizeof (tbuf), "%F.%T", &t);
(void) printf("%s %s\n", tbuf, cmd);
+ printed = B_TRUE;
+
+next:
+ if (dump_opt['h'] > 1) {
+ if (!printed)
+ (void) printf("unrecognized record:\n");
+ dump_nvlist(events[i], 2);
+ }
}
}
@@ -1088,7 +1123,7 @@ dump_dsl_dataset(objset_t *os, uint64_t object, void *data, size_t size)
ASSERT(size == sizeof (*ds));
crtime = ds->ds_creation_time;
- zdb_nicenum(ds->ds_used_bytes, used);
+ zdb_nicenum(ds->ds_referenced_bytes, used);
zdb_nicenum(ds->ds_compressed_bytes, compressed);
zdb_nicenum(ds->ds_uncompressed_bytes, uncompressed);
zdb_nicenum(ds->ds_unique_bytes, unique);
@@ -1132,6 +1167,44 @@ dump_dsl_dataset(objset_t *os, uint64_t object, void *data, size_t size)
/* ARGSUSED */
static int
+dump_bptree_cb(void *arg, const blkptr_t *bp, dmu_tx_t *tx)
+{
+ char blkbuf[BP_SPRINTF_LEN];
+
+ if (bp->blk_birth != 0) {
+ sprintf_blkptr(blkbuf, bp);
+ (void) printf("\t%s\n", blkbuf);
+ }
+ return (0);
+}
+
+static void
+dump_bptree(objset_t *os, uint64_t obj, char *name)
+{
+ char bytes[32];
+ bptree_phys_t *bt;
+ dmu_buf_t *db;
+
+ if (dump_opt['d'] < 3)
+ return;
+
+ VERIFY3U(0, ==, dmu_bonus_hold(os, obj, FTAG, &db));
+ bt = db->db_data;
+ zdb_nicenum(bt->bt_bytes, bytes);
+ (void) printf("\n %s: %llu datasets, %s\n",
+ name, (unsigned long long)(bt->bt_end - bt->bt_begin), bytes);
+ dmu_buf_rele(db, FTAG);
+
+ if (dump_opt['d'] < 5)
+ return;
+
+ (void) printf("\n");
+
+ (void) bptree_iterate(os, obj, B_FALSE, dump_bptree_cb, NULL, NULL);
+}
+
+/* ARGSUSED */
+static int
dump_bpobj_cb(void *arg, const blkptr_t *bp, dmu_tx_t *tx)
{
char blkbuf[BP_SPRINTF_LEN];
@@ -1414,7 +1487,7 @@ static object_viewer_t *object_viewer[DMU_OT_NUMTYPES + 1] = {
dump_zap, /* other ZAP */
dump_zap, /* persistent error log */
dump_uint8, /* SPA history */
- dump_uint64, /* SPA history offsets */
+ dump_history_offsets, /* SPA history offsets */
dump_zap, /* Pool properties */
dump_zap, /* DSL permissions */
dump_acl, /* ZFS ACL */
@@ -1883,11 +1956,13 @@ typedef struct zdb_blkstats {
*/
#define ZDB_OT_DEFERRED (DMU_OT_NUMTYPES + 0)
#define ZDB_OT_DITTO (DMU_OT_NUMTYPES + 1)
-#define ZDB_OT_TOTAL (DMU_OT_NUMTYPES + 2)
+#define ZDB_OT_OTHER (DMU_OT_NUMTYPES + 2)
+#define ZDB_OT_TOTAL (DMU_OT_NUMTYPES + 3)
static char *zdb_ot_extname[] = {
"deferred free",
"dedup ditto",
+ "other",
"Total",
};
@@ -1968,9 +2043,10 @@ zdb_blkptr_cb(spa_t *spa, zilog_t *zilog, const blkptr_t *bp, arc_buf_t *pbuf,
type = BP_GET_TYPE(bp);
- zdb_count_block(zcb, zilog, bp, type);
+ zdb_count_block(zcb, zilog, bp,
+ (type & DMU_OT_NEWTYPE) ? ZDB_OT_OTHER : type);
- is_metadata = (BP_GET_LEVEL(bp) != 0 || dmu_ot[type].ot_metadata);
+ is_metadata = (BP_GET_LEVEL(bp) != 0 || DMU_OT_IS_METADATA(type));
if (dump_opt['c'] > 1 || (dump_opt['c'] && is_metadata)) {
int ioerr;
@@ -2195,6 +2271,12 @@ dump_block_stats(spa_t *spa)
count_block_cb, &zcb, NULL);
(void) bpobj_iterate_nofree(&spa->spa_dsl_pool->dp_free_bpobj,
count_block_cb, &zcb, NULL);
+ if (spa_feature_is_active(spa,
+ &spa_feature_table[SPA_FEATURE_ASYNC_DESTROY])) {
+ VERIFY3U(0, ==, bptree_iterate(spa->spa_meta_objset,
+ spa->spa_dsl_pool->dp_bptree_obj, B_FALSE, count_block_cb,
+ &zcb, NULL));
+ }
if (dump_opt['c'] > 1)
flags |= TRAVERSE_PREFETCH_DATA;
@@ -2371,7 +2453,7 @@ zdb_ddt_add_cb(spa_t *spa, zilog_t *zilog, const blkptr_t *bp,
}
if (BP_IS_HOLE(bp) || BP_GET_CHECKSUM(bp) == ZIO_CHECKSUM_OFF ||
- BP_GET_LEVEL(bp) > 0 || dmu_ot[BP_GET_TYPE(bp)].ot_metadata)
+ BP_GET_LEVEL(bp) > 0 || DMU_OT_IS_METADATA(BP_GET_TYPE(bp)))
return (0);
ddt_key_fill(&zdde_search.zdde_key, bp);
@@ -2476,7 +2558,14 @@ dump_zpool(spa_t *spa)
dump_bpobj(&spa->spa_deferred_bpobj, "Deferred frees");
if (spa_version(spa) >= SPA_VERSION_DEADLISTS) {
dump_bpobj(&spa->spa_dsl_pool->dp_free_bpobj,
- "Pool frees");
+ "Pool snapshot frees");
+ }
+
+ if (spa_feature_is_active(spa,
+ &spa_feature_table[SPA_FEATURE_ASYNC_DESTROY])) {
+ dump_bptree(spa->spa_meta_objset,
+ spa->spa_dsl_pool->dp_bptree_obj,
+ "Pool dataset frees");
}
dump_dtl(spa->spa_root_vdev, 0);
}
diff --git a/usr/src/cmd/zfs/Makefile b/usr/src/cmd/zfs/Makefile
index d5848aa5a3..b117b1206e 100644
--- a/usr/src/cmd/zfs/Makefile
+++ b/usr/src/cmd/zfs/Makefile
@@ -18,11 +18,12 @@
#
# CDDL HEADER END
#
-#
# Copyright 2010 Sun Microsystems, Inc. All rights reserved.
-# Copyright 2010 Nexenta Systems, Inc. All rights reserved.
# Use is subject to license terms.
#
+# Copyright 2010 Nexenta Systems, Inc. All rights reserved.
+# Copyright (c) 2012 by Delphix. All rights reserved.
+#
PROG= zfs
OBJS= zfs_main.o zfs_iter.o
@@ -38,7 +39,7 @@ LINKPROGS= mount umount
ROOTETCFSTYPE= $(ROOTETC)/fs/$(FSTYPE)
USRLIBFSTYPE= $(ROOTLIB)/fs/$(FSTYPE)
-LDLIBS += -lzfs -luutil -lumem -lnvpair -lsec -lidmap
+LDLIBS += -lzfs_core -lzfs -luutil -lumem -lnvpair -lsec -lidmap
INCS += -I../../common/zfs
diff --git a/usr/src/cmd/zfs/zfs_main.c b/usr/src/cmd/zfs/zfs_main.c
index b5ec25de5b..1457c425ca 100644
--- a/usr/src/cmd/zfs/zfs_main.c
+++ b/usr/src/cmd/zfs/zfs_main.c
@@ -25,6 +25,7 @@
* Copyright (c) 2012 by Delphix. All rights reserved.
* Copyright (c) 2012, Joyent, Inc. All rights reserved.
* Copyright 2012 Milan Jurik. All rights reserved.
+ * Copyright (c) 2012, Joyent, Inc. All rights reserved.
*/
#include <assert.h>
@@ -56,6 +57,7 @@
#include <time.h>
#include <libzfs.h>
+#include <libzfs_core.h>
#include <zfs_prop.h>
#include <zfs_deleg.h>
#include <libuutil.h>
@@ -70,6 +72,7 @@ libzfs_handle_t *g_zfs;
static FILE *mnttab_file;
static char history_str[HIS_MAX_RECORD_LEN];
+static boolean_t log_history = B_TRUE;
static int zfs_do_clone(int argc, char **argv);
static int zfs_do_create(int argc, char **argv);
@@ -259,7 +262,7 @@ get_usage(zfs_help_t idx)
return (gettext("\tshare <-a | filesystem>\n"));
case HELP_SNAPSHOT:
return (gettext("\tsnapshot [-r] [-o property=value] ... "
- "<filesystem@snapname|volume@snapname>\n"));
+ "<filesystem@snapname|volume@snapname> ...\n"));
case HELP_UNMOUNT:
return (gettext("\tunmount [-f] "
"<-a | filesystem|mountpoint>\n"));
@@ -905,9 +908,9 @@ typedef struct destroy_cbdata {
nvlist_t *cb_nvl;
/* first snap in contiguous run */
- zfs_handle_t *cb_firstsnap;
+ char *cb_firstsnap;
/* previous snap in contiguous run */
- zfs_handle_t *cb_prevsnap;
+ char *cb_prevsnap;
int64_t cb_snapused;
char *cb_snapspec;
} destroy_cbdata_t;
@@ -1055,11 +1058,13 @@ destroy_print_cb(zfs_handle_t *zhp, void *arg)
if (nvlist_exists(cb->cb_nvl, name)) {
if (cb->cb_firstsnap == NULL)
- cb->cb_firstsnap = zfs_handle_dup(zhp);
+ cb->cb_firstsnap = strdup(name);
if (cb->cb_prevsnap != NULL)
- zfs_close(cb->cb_prevsnap);
+ free(cb->cb_prevsnap);
/* this snap continues the current range */
- cb->cb_prevsnap = zfs_handle_dup(zhp);
+ cb->cb_prevsnap = strdup(name);
+ if (cb->cb_firstsnap == NULL || cb->cb_prevsnap == NULL)
+ nomem();
if (cb->cb_verbose) {
if (cb->cb_parsable) {
(void) printf("destroy\t%s\n", name);
@@ -1074,12 +1079,12 @@ destroy_print_cb(zfs_handle_t *zhp, void *arg)
} else if (cb->cb_firstsnap != NULL) {
/* end of this range */
uint64_t used = 0;
- err = zfs_get_snapused_int(cb->cb_firstsnap,
+ err = lzc_snaprange_space(cb->cb_firstsnap,
cb->cb_prevsnap, &used);
cb->cb_snapused += used;
- zfs_close(cb->cb_firstsnap);
+ free(cb->cb_firstsnap);
cb->cb_firstsnap = NULL;
- zfs_close(cb->cb_prevsnap);
+ free(cb->cb_prevsnap);
cb->cb_prevsnap = NULL;
}
zfs_close(zhp);
@@ -1096,13 +1101,13 @@ destroy_print_snapshots(zfs_handle_t *fs_zhp, destroy_cbdata_t *cb)
if (cb->cb_firstsnap != NULL) {
uint64_t used = 0;
if (err == 0) {
- err = zfs_get_snapused_int(cb->cb_firstsnap,
+ err = lzc_snaprange_space(cb->cb_firstsnap,
cb->cb_prevsnap, &used);
}
cb->cb_snapused += used;
- zfs_close(cb->cb_firstsnap);
+ free(cb->cb_firstsnap);
cb->cb_firstsnap = NULL;
- zfs_close(cb->cb_prevsnap);
+ free(cb->cb_prevsnap);
cb->cb_prevsnap = NULL;
}
return (err);
@@ -1115,7 +1120,7 @@ snapshot_to_nvl_cb(zfs_handle_t *zhp, void *arg)
int err = 0;
/* Check for clones. */
- if (!cb->cb_doclones) {
+ if (!cb->cb_doclones && !cb->cb_defer_destroy) {
cb->cb_target = zhp;
cb->cb_first = B_TRUE;
err = zfs_iter_dependents(zhp, B_TRUE,
@@ -1961,9 +1966,11 @@ upgrade_set_callback(zfs_handle_t *zhp, void *data)
/*
* If they did "zfs upgrade -a", then we could
* be doing ioctls to different pools. We need
- * to log this history once to each pool.
+ * to log this history once to each pool, and bypass
+ * the normal history logging that happens in main().
*/
- verify(zpool_stage_history(g_zfs, history_str) == 0);
+ (void) zpool_log_history(g_zfs, history_str);
+ log_history = B_FALSE;
}
if (zfs_prop_set(zhp, "version", verstr) == 0)
cb->cb_numupgraded++;
@@ -3500,6 +3507,32 @@ zfs_do_set(int argc, char **argv)
return (ret);
}
+typedef struct snap_cbdata {
+ nvlist_t *sd_nvl;
+ boolean_t sd_recursive;
+ const char *sd_snapname;
+} snap_cbdata_t;
+
+static int
+zfs_snapshot_cb(zfs_handle_t *zhp, void *arg)
+{
+ snap_cbdata_t *sd = arg;
+ char *name;
+ int rv = 0;
+ int error;
+
+ error = asprintf(&name, "%s@%s", zfs_get_name(zhp), sd->sd_snapname);
+ if (error == -1)
+ nomem();
+ fnvlist_add_boolean(sd->sd_nvl, name);
+ free(name);
+
+ if (sd->sd_recursive)
+ rv = zfs_iter_filesystems(zhp, zfs_snapshot_cb, sd);
+ zfs_close(zhp);
+ return (rv);
+}
+
/*
* zfs snapshot [-r] [-o prop=value] ... <fs@snap>
*
@@ -3509,13 +3542,16 @@ zfs_do_set(int argc, char **argv)
static int
zfs_do_snapshot(int argc, char **argv)
{
- boolean_t recursive = B_FALSE;
int ret = 0;
char c;
nvlist_t *props;
+ snap_cbdata_t sd = { 0 };
+ boolean_t multiple_snaps = B_FALSE;
if (nvlist_alloc(&props, NV_UNIQUE_NAME, 0) != 0)
nomem();
+ if (nvlist_alloc(&sd.sd_nvl, NV_UNIQUE_NAME, 0) != 0)
+ nomem();
/* check options */
while ((c = getopt(argc, argv, "ro:")) != -1) {
@@ -3525,7 +3561,8 @@ zfs_do_snapshot(int argc, char **argv)
return (1);
break;
case 'r':
- recursive = B_TRUE;
+ sd.sd_recursive = B_TRUE;
+ multiple_snaps = B_TRUE;
break;
case '?':
(void) fprintf(stderr, gettext("invalid option '%c'\n"),
@@ -3542,18 +3579,35 @@ zfs_do_snapshot(int argc, char **argv)
(void) fprintf(stderr, gettext("missing snapshot argument\n"));
goto usage;
}
- if (argc > 1) {
- (void) fprintf(stderr, gettext("too many arguments\n"));
- goto usage;
+
+ if (argc > 1)
+ multiple_snaps = B_TRUE;
+ for (; argc > 0; argc--, argv++) {
+ char *atp;
+ zfs_handle_t *zhp;
+
+ atp = strchr(argv[0], '@');
+ if (atp == NULL)
+ goto usage;
+ *atp = '\0';
+ sd.sd_snapname = atp + 1;
+ zhp = zfs_open(g_zfs, argv[0],
+ ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME);
+ if (zhp == NULL)
+ goto usage;
+ if (zfs_snapshot_cb(zhp, &sd) != 0)
+ goto usage;
}
- ret = zfs_snapshot(g_zfs, argv[0], recursive, props);
+ ret = zfs_snapshot_nvl(g_zfs, sd.sd_nvl, props);
+ nvlist_free(sd.sd_nvl);
nvlist_free(props);
- if (ret && recursive)
+ if (ret != 0 && multiple_snaps)
(void) fprintf(stderr, gettext("no snapshots were created\n"));
return (ret != 0);
usage:
+ nvlist_free(sd.sd_nvl);
nvlist_free(props);
usage(B_FALSE);
return (-1);
@@ -3602,6 +3656,7 @@ zfs_do_send(int argc, char **argv)
if (flags.verbose)
extraverbose = B_TRUE;
flags.verbose = B_TRUE;
+ flags.progress = B_TRUE;
break;
case 'D':
flags.dedup = B_TRUE;
@@ -6554,8 +6609,7 @@ main(int argc, char **argv)
return (1);
}
- zpool_set_history_str("zfs", argc, argv, history_str);
- verify(zpool_stage_history(g_zfs, history_str) == 0);
+ zfs_save_arguments(argc, argv, history_str, sizeof (history_str));
libzfs_print_on_error(g_zfs, B_TRUE);
@@ -6624,6 +6678,9 @@ main(int argc, char **argv)
(void) fclose(mnttab_file);
+ if (ret == 0 && log_history)
+ (void) zpool_log_history(g_zfs, history_str);
+
libzfs_fini(g_zfs);
/*
diff --git a/usr/src/cmd/zhack/Makefile b/usr/src/cmd/zhack/Makefile
new file mode 100644
index 0000000000..d4f3018fd7
--- /dev/null
+++ b/usr/src/cmd/zhack/Makefile
@@ -0,0 +1,57 @@
+#
+# 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 2005 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+#
+# Copyright (c) 2012 by Delphix. All rights reserved.
+#
+
+PROG= zhack
+
+include ../Makefile.cmd
+
+$(INTEL_BLD)SUBDIRS = $(MACH)
+$(BUILD64)SUBDIRS += $(MACH64)
+
+all := TARGET = all
+install := TARGET = install
+clean := TARGET = clean
+clobber := TARGET = clobber
+lint := TARGET = lint
+
+.KEEP_STATE:
+
+all clean clobber lint: $(SUBDIRS)
+
+install: $(SUBDIRS)
+ -$(RM) $(ROOTUSRSBINPROG)
+ -$(LN) $(ISAEXEC) $(ROOTUSRSBINPROG)
+
+$(SUBDIRS): FRC
+ @cd $@; pwd; $(MAKE) $(TARGET)
+
+FRC:
+
+include ../Makefile.targ
diff --git a/usr/src/cmd/zhack/Makefile.com b/usr/src/cmd/zhack/Makefile.com
new file mode 100644
index 0000000000..b22aa347b5
--- /dev/null
+++ b/usr/src/cmd/zhack/Makefile.com
@@ -0,0 +1,67 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (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 2009 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+#
+# Copyright (c) 2012 by Delphix. All rights reserved.
+#
+
+PROG= zhack
+SRCS= ../$(PROG).c
+OBJS= $(PROG).o
+
+include ../../Makefile.cmd
+include ../../Makefile.ctf
+
+INCS += -I../../../lib/libzpool/common
+INCS += -I../../../uts/common/fs/zfs
+INCS += -I../../../common/zfs
+
+LDLIBS += -lzpool -lumem -lnvpair -lzfs
+
+C99MODE= -xc99=%all
+C99LMODE= -Xc99=%all
+
+CFLAGS += $(CCVERBOSE)
+CFLAGS64 += $(CCVERBOSE)
+CPPFLAGS += -D_LARGEFILE64_SOURCE=1 -D_REENTRANT $(INCS)
+
+.KEEP_STATE:
+
+all: $(PROG)
+
+$(PROG): $(OBJS)
+ $(LINK.c) -o $(PROG) $(OBJS) $(LDLIBS)
+ $(POST_PROCESS)
+
+clean:
+
+lint: lint_SRCS
+
+include ../../Makefile.targ
+
+%.o: ../%.c
+ $(COMPILE.c) $<
+ $(POST_PROCESS_O)
diff --git a/usr/src/cmd/zhack/amd64/Makefile b/usr/src/cmd/zhack/amd64/Makefile
new file mode 100644
index 0000000000..74c7a42a08
--- /dev/null
+++ b/usr/src/cmd/zhack/amd64/Makefile
@@ -0,0 +1,30 @@
+#
+# 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 2005 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+include ../Makefile.com
+include ../../Makefile.cmd.64
+
+install: all $(ROOTUSRSBINPROG64)
diff --git a/usr/src/lib/libldap4/sparc/Makefile b/usr/src/cmd/zhack/i386/Makefile
index 7cf5507978..2ff9c89632 100644
--- a/usr/src/lib/libldap4/sparc/Makefile
+++ b/usr/src/cmd/zhack/i386/Makefile
@@ -2,8 +2,9 @@
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
-# Common Development and Distribution License (the "License").
-# You may not use this file except in compliance with the License.
+# 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.
@@ -19,16 +20,10 @@
# CDDL HEADER END
#
#
-# Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+# Copyright 2005 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
-# ident "%Z%%M% %I% %E% SMI"
-#
include ../Makefile.com
-.KEEP_STATE:
-
-all: $(LIBS)
-
-install: all $(ROOTLIBS)
+install: all $(ROOTUSRSBINPROG32)
diff --git a/usr/src/cmd/zhack/sparcv9/Makefile b/usr/src/cmd/zhack/sparcv9/Makefile
new file mode 100644
index 0000000000..74c7a42a08
--- /dev/null
+++ b/usr/src/cmd/zhack/sparcv9/Makefile
@@ -0,0 +1,30 @@
+#
+# 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 2005 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+include ../Makefile.com
+include ../../Makefile.cmd.64
+
+install: all $(ROOTUSRSBINPROG64)
diff --git a/usr/src/cmd/zhack/zhack.c b/usr/src/cmd/zhack/zhack.c
new file mode 100644
index 0000000000..7cc83d2dc0
--- /dev/null
+++ b/usr/src/cmd/zhack/zhack.c
@@ -0,0 +1,540 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (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) 2012 by Delphix. All rights reserved.
+ */
+
+/*
+ * zhack is a debugging tool that can write changes to ZFS pool using libzpool
+ * for testing purposes. Altering pools with zhack is unsupported and may
+ * result in corrupted pools.
+ */
+
+#include <stdio.h>
+#include <stdlib.h>
+#include <ctype.h>
+#include <sys/zfs_context.h>
+#include <sys/spa.h>
+#include <sys/spa_impl.h>
+#include <sys/dmu.h>
+#include <sys/zap.h>
+#include <sys/zfs_znode.h>
+#include <sys/dsl_synctask.h>
+#include <sys/vdev.h>
+#include <sys/fs/zfs.h>
+#include <sys/dmu_objset.h>
+#include <sys/dsl_pool.h>
+#include <sys/zio_checksum.h>
+#include <sys/zio_compress.h>
+#include <sys/zfeature.h>
+#undef ZFS_MAXNAMELEN
+#undef verify
+#include <libzfs.h>
+
+extern boolean_t zfeature_checks_disable;
+
+const char cmdname[] = "zhack";
+libzfs_handle_t *g_zfs;
+static importargs_t g_importargs;
+static char *g_pool;
+static boolean_t g_readonly;
+
+static void
+usage(void)
+{
+ (void) fprintf(stderr,
+ "Usage: %s [-c cachefile] [-d dir] <subcommand> <args> ...\n"
+ "where <subcommand> <args> is one of the following:\n"
+ "\n", cmdname);
+
+ (void) fprintf(stderr,
+ " feature stat <pool>\n"
+ " print information about enabled features\n"
+ " feature enable [-d desc] <pool> <feature>\n"
+ " add a new enabled feature to the pool\n"
+ " -d <desc> sets the feature's description\n"
+ " feature ref [-md] <pool> <feature>\n"
+ " change the refcount on the given feature\n"
+ " -d decrease instead of increase the refcount\n"
+ " -m add the feature to the label if increasing refcount\n"
+ "\n"
+ " <feature> : should be a feature guid\n");
+ exit(1);
+}
+
+
+static void
+fatal(const char *fmt, ...)
+{
+ va_list ap;
+
+ va_start(ap, fmt);
+ (void) fprintf(stderr, "%s: ", cmdname);
+ (void) vfprintf(stderr, fmt, ap);
+ va_end(ap);
+ (void) fprintf(stderr, "\n");
+
+ exit(1);
+}
+
+/* ARGSUSED */
+static int
+space_delta_cb(dmu_object_type_t bonustype, void *data,
+ uint64_t *userp, uint64_t *groupp)
+{
+ /*
+ * Is it a valid type of object to track?
+ */
+ if (bonustype != DMU_OT_ZNODE && bonustype != DMU_OT_SA)
+ return (ENOENT);
+ (void) fprintf(stderr, "modifying object that needs user accounting");
+ abort();
+ /* NOTREACHED */
+}
+
+/*
+ * Target is the dataset whose pool we want to open.
+ */
+static void
+import_pool(const char *target, boolean_t readonly)
+{
+ nvlist_t *config;
+ nvlist_t *pools;
+ int error;
+ char *sepp;
+ spa_t *spa;
+ nvpair_t *elem;
+ nvlist_t *props;
+ const char *name;
+
+ kernel_init(readonly ? FREAD : (FREAD | FWRITE));
+ g_zfs = libzfs_init();
+ ASSERT(g_zfs != NULL);
+
+ dmu_objset_register_type(DMU_OST_ZFS, space_delta_cb);
+
+ g_readonly = readonly;
+
+ /*
+ * If we only want readonly access, it's OK if we find
+ * a potentially-active (ie, imported into the kernel) pool from the
+ * default cachefile.
+ */
+ if (readonly && spa_open(target, &spa, FTAG) == 0) {
+ spa_close(spa, FTAG);
+ return;
+ }
+
+ g_importargs.unique = B_TRUE;
+ g_importargs.can_be_active = readonly;
+ g_pool = strdup(target);
+ if ((sepp = strpbrk(g_pool, "/@")) != NULL)
+ *sepp = '\0';
+ g_importargs.poolname = g_pool;
+ pools = zpool_search_import(g_zfs, &g_importargs);
+
+ if (pools == NULL || nvlist_next_nvpair(pools, NULL) == NULL) {
+ if (!g_importargs.can_be_active) {
+ g_importargs.can_be_active = B_TRUE;
+ if (zpool_search_import(g_zfs, &g_importargs) != NULL ||
+ spa_open(target, &spa, FTAG) == 0) {
+ fatal("cannot import '%s': pool is active; run "
+ "\"zpool export %s\" first\n",
+ g_pool, g_pool);
+ }
+ }
+
+ fatal("cannot import '%s': no such pool available\n", g_pool);
+ }
+
+ elem = nvlist_next_nvpair(pools, NULL);
+ name = nvpair_name(elem);
+ verify(nvpair_value_nvlist(elem, &config) == 0);
+
+ props = NULL;
+ if (readonly) {
+ verify(nvlist_alloc(&props, NV_UNIQUE_NAME, 0) == 0);
+ verify(nvlist_add_uint64(props,
+ zpool_prop_to_name(ZPOOL_PROP_READONLY), 1) == 0);
+ }
+
+ zfeature_checks_disable = B_TRUE;
+ error = spa_import(name, config, props, ZFS_IMPORT_NORMAL);
+ zfeature_checks_disable = B_FALSE;
+ if (error == EEXIST)
+ error = 0;
+
+ if (error)
+ fatal("can't import '%s': %s", name, strerror(error));
+}
+
+static void
+zhack_spa_open(const char *target, boolean_t readonly, void *tag, spa_t **spa)
+{
+ int err;
+
+ import_pool(target, readonly);
+
+ zfeature_checks_disable = B_TRUE;
+ err = spa_open(target, spa, tag);
+ zfeature_checks_disable = B_FALSE;
+
+ if (err != 0)
+ fatal("cannot open '%s': %s", target, strerror(err));
+ if (spa_version(*spa) < SPA_VERSION_FEATURES) {
+ fatal("'%s' has version %d, features not enabled", target,
+ (int)spa_version(*spa));
+ }
+}
+
+static void
+dump_obj(objset_t *os, uint64_t obj, const char *name)
+{
+ zap_cursor_t zc;
+ zap_attribute_t za;
+
+ (void) printf("%s_obj:\n", name);
+
+ for (zap_cursor_init(&zc, os, obj);
+ zap_cursor_retrieve(&zc, &za) == 0;
+ zap_cursor_advance(&zc)) {
+ if (za.za_integer_length == 8) {
+ ASSERT(za.za_num_integers == 1);
+ (void) printf("\t%s = %llu\n",
+ za.za_name, (u_longlong_t)za.za_first_integer);
+ } else {
+ ASSERT(za.za_integer_length == 1);
+ char val[1024];
+ VERIFY(zap_lookup(os, obj, za.za_name,
+ 1, sizeof (val), val) == 0);
+ (void) printf("\t%s = %s\n", za.za_name, val);
+ }
+ }
+ zap_cursor_fini(&zc);
+}
+
+static void
+dump_mos(spa_t *spa)
+{
+ nvlist_t *nv = spa->spa_label_features;
+
+ (void) printf("label config:\n");
+ for (nvpair_t *pair = nvlist_next_nvpair(nv, NULL);
+ pair != NULL;
+ pair = nvlist_next_nvpair(nv, pair)) {
+ (void) printf("\t%s\n", nvpair_name(pair));
+ }
+}
+
+static void
+zhack_do_feature_stat(int argc, char **argv)
+{
+ spa_t *spa;
+ objset_t *os;
+ char *target;
+
+ argc--;
+ argv++;
+
+ if (argc < 1) {
+ (void) fprintf(stderr, "error: missing pool name\n");
+ usage();
+ }
+ target = argv[0];
+
+ zhack_spa_open(target, B_TRUE, FTAG, &spa);
+ os = spa->spa_meta_objset;
+
+ dump_obj(os, spa->spa_feat_for_read_obj, "for_read");
+ dump_obj(os, spa->spa_feat_for_write_obj, "for_write");
+ dump_obj(os, spa->spa_feat_desc_obj, "descriptions");
+ dump_mos(spa);
+
+ spa_close(spa, FTAG);
+}
+
+static void
+feature_enable_sync(void *arg1, void *arg2, dmu_tx_t *tx)
+{
+ spa_t *spa = arg1;
+ zfeature_info_t *feature = arg2;
+
+ spa_feature_enable(spa, feature, tx);
+ spa_history_log_internal(spa, "zhack enable feature", tx,
+ "guid=%s can_readonly=%u",
+ feature->fi_guid, feature->fi_can_readonly);
+}
+
+static void
+zhack_do_feature_enable(int argc, char **argv)
+{
+ char c;
+ char *desc, *target;
+ spa_t *spa;
+ objset_t *mos;
+ zfeature_info_t feature;
+ zfeature_info_t *nodeps[] = { NULL };
+
+ /*
+ * Features are not added to the pool's label until their refcounts
+ * are incremented, so fi_mos can just be left as false for now.
+ */
+ desc = NULL;
+ feature.fi_uname = "zhack";
+ feature.fi_mos = B_FALSE;
+ feature.fi_can_readonly = B_FALSE;
+ feature.fi_depends = nodeps;
+
+ optind = 1;
+ while ((c = getopt(argc, argv, "rmd:")) != -1) {
+ switch (c) {
+ case 'r':
+ feature.fi_can_readonly = B_TRUE;
+ break;
+ case 'd':
+ desc = strdup(optarg);
+ break;
+ default:
+ usage();
+ break;
+ }
+ }
+
+ if (desc == NULL)
+ desc = strdup("zhack injected");
+ feature.fi_desc = desc;
+
+ argc -= optind;
+ argv += optind;
+
+ if (argc < 2) {
+ (void) fprintf(stderr, "error: missing feature or pool name\n");
+ usage();
+ }
+ target = argv[0];
+ feature.fi_guid = argv[1];
+
+ if (!zfeature_is_valid_guid(feature.fi_guid))
+ fatal("invalid feature guid: %s", feature.fi_guid);
+
+ zhack_spa_open(target, B_FALSE, FTAG, &spa);
+ mos = spa->spa_meta_objset;
+
+ if (0 == zfeature_lookup_guid(feature.fi_guid, NULL))
+ fatal("'%s' is a real feature, will not enable");
+ if (0 == zap_contains(mos, spa->spa_feat_desc_obj, feature.fi_guid))
+ fatal("feature already enabled: %s", feature.fi_guid);
+
+ VERIFY3U(0, ==, dsl_sync_task_do(spa->spa_dsl_pool, NULL,
+ feature_enable_sync, spa, &feature, 5));
+
+ spa_close(spa, FTAG);
+
+ free(desc);
+}
+
+static void
+feature_incr_sync(void *arg1, void *arg2, dmu_tx_t *tx)
+{
+ spa_t *spa = arg1;
+ zfeature_info_t *feature = arg2;
+
+ spa_feature_incr(spa, feature, tx);
+ spa_history_log_internal(spa, "zhack feature incr", tx,
+ "guid=%s", feature->fi_guid);
+}
+
+static void
+feature_decr_sync(void *arg1, void *arg2, dmu_tx_t *tx)
+{
+ spa_t *spa = arg1;
+ zfeature_info_t *feature = arg2;
+
+ spa_feature_decr(spa, feature, tx);
+ spa_history_log_internal(spa, "zhack feature decr", tx,
+ "guid=%s", feature->fi_guid);
+}
+
+static void
+zhack_do_feature_ref(int argc, char **argv)
+{
+ char c;
+ char *target;
+ boolean_t decr = B_FALSE;
+ spa_t *spa;
+ objset_t *mos;
+ zfeature_info_t feature;
+ zfeature_info_t *nodeps[] = { NULL };
+
+ /*
+ * fi_desc does not matter here because it was written to disk
+ * when the feature was enabled, but we need to properly set the
+ * feature for read or write based on the information we read off
+ * disk later.
+ */
+ feature.fi_uname = "zhack";
+ feature.fi_mos = B_FALSE;
+ feature.fi_desc = NULL;
+ feature.fi_depends = nodeps;
+
+ optind = 1;
+ while ((c = getopt(argc, argv, "md")) != -1) {
+ switch (c) {
+ case 'm':
+ feature.fi_mos = B_TRUE;
+ break;
+ case 'd':
+ decr = B_TRUE;
+ break;
+ default:
+ usage();
+ break;
+ }
+ }
+ argc -= optind;
+ argv += optind;
+
+ if (argc < 2) {
+ (void) fprintf(stderr, "error: missing feature or pool name\n");
+ usage();
+ }
+ target = argv[0];
+ feature.fi_guid = argv[1];
+
+ if (!zfeature_is_valid_guid(feature.fi_guid))
+ fatal("invalid feature guid: %s", feature.fi_guid);
+
+ zhack_spa_open(target, B_FALSE, FTAG, &spa);
+ mos = spa->spa_meta_objset;
+
+ if (0 == zfeature_lookup_guid(feature.fi_guid, NULL))
+ fatal("'%s' is a real feature, will not change refcount");
+
+ if (0 == zap_contains(mos, spa->spa_feat_for_read_obj,
+ feature.fi_guid)) {
+ feature.fi_can_readonly = B_FALSE;
+ } else if (0 == zap_contains(mos, spa->spa_feat_for_write_obj,
+ feature.fi_guid)) {
+ feature.fi_can_readonly = B_TRUE;
+ } else {
+ fatal("feature is not enabled: %s", feature.fi_guid);
+ }
+
+ if (decr && !spa_feature_is_active(spa, &feature))
+ fatal("feature refcount already 0: %s", feature.fi_guid);
+
+ VERIFY3U(0, ==, dsl_sync_task_do(spa->spa_dsl_pool, NULL,
+ decr ? feature_decr_sync : feature_incr_sync, spa, &feature, 5));
+
+ spa_close(spa, FTAG);
+}
+
+static int
+zhack_do_feature(int argc, char **argv)
+{
+ char *subcommand;
+
+ argc--;
+ argv++;
+ if (argc == 0) {
+ (void) fprintf(stderr,
+ "error: no feature operation specified\n");
+ usage();
+ }
+
+ subcommand = argv[0];
+ if (strcmp(subcommand, "stat") == 0) {
+ zhack_do_feature_stat(argc, argv);
+ } else if (strcmp(subcommand, "enable") == 0) {
+ zhack_do_feature_enable(argc, argv);
+ } else if (strcmp(subcommand, "ref") == 0) {
+ zhack_do_feature_ref(argc, argv);
+ } else {
+ (void) fprintf(stderr, "error: unknown subcommand: %s\n",
+ subcommand);
+ usage();
+ }
+
+ return (0);
+}
+
+#define MAX_NUM_PATHS 1024
+
+int
+main(int argc, char **argv)
+{
+ extern void zfs_prop_init(void);
+
+ char *path[MAX_NUM_PATHS];
+ const char *subcommand;
+ int rv = 0;
+ char c;
+
+ g_importargs.path = path;
+
+ dprintf_setup(&argc, argv);
+ zfs_prop_init();
+
+ while ((c = getopt(argc, argv, "c:d:")) != -1) {
+ switch (c) {
+ case 'c':
+ g_importargs.cachefile = optarg;
+ break;
+ case 'd':
+ assert(g_importargs.paths < MAX_NUM_PATHS);
+ g_importargs.path[g_importargs.paths++] = optarg;
+ break;
+ default:
+ usage();
+ break;
+ }
+ }
+
+ argc -= optind;
+ argv += optind;
+ optind = 1;
+
+ if (argc == 0) {
+ (void) fprintf(stderr, "error: no command specified\n");
+ usage();
+ }
+
+ subcommand = argv[0];
+
+ if (strcmp(subcommand, "feature") == 0) {
+ rv = zhack_do_feature(argc, argv);
+ } else {
+ (void) fprintf(stderr, "error: unknown subcommand: %s\n",
+ subcommand);
+ usage();
+ }
+
+ if (!g_readonly && spa_export(g_pool, NULL, B_TRUE, B_TRUE) != 0) {
+ fatal("pool export failed; "
+ "changes may not be committed to disk\n");
+ }
+
+ libzfs_fini(g_zfs);
+ kernel_fini();
+
+ return (rv);
+}
diff --git a/usr/src/cmd/zpool/zpool_main.c b/usr/src/cmd/zpool/zpool_main.c
index 6df035d97d..f73fd90f3c 100644
--- a/usr/src/cmd/zpool/zpool_main.c
+++ b/usr/src/cmd/zpool/zpool_main.c
@@ -52,6 +52,7 @@
#include "zpool_util.h"
#include "zfs_comutil.h"
+#include "zfeature_common.h"
#include "statcommon.h"
@@ -185,9 +186,9 @@ static zpool_command_t command_table[] = {
#define NCOMMAND (sizeof (command_table) / sizeof (command_table[0]))
-zpool_command_t *current_command;
+static zpool_command_t *current_command;
static char history_str[HIS_MAX_RECORD_LEN];
-
+static boolean_t log_history = B_TRUE;
static uint_t timestamp_fmt = NODATE;
static const char *
@@ -201,7 +202,7 @@ get_usage(zpool_help_t idx) {
case HELP_CLEAR:
return (gettext("\tclear [-nF] <pool> [device]\n"));
case HELP_CREATE:
- return (gettext("\tcreate [-fn] [-o property=value] ... \n"
+ return (gettext("\tcreate [-fnd] [-o property=value] ... \n"
"\t [-O file-system-property=value] ... \n"
"\t [-m mountpoint] [-R root] <pool> <vdev> ...\n"));
case HELP_DESTROY:
@@ -332,6 +333,12 @@ usage(boolean_t requested)
/* Iterate over all properties */
(void) zprop_iter(print_prop_cb, fp, B_FALSE, B_TRUE,
ZFS_TYPE_POOL);
+
+ (void) fprintf(fp, "\t%-15s ", "feature@...");
+ (void) fprintf(fp, "YES disabled | enabled | active\n");
+
+ (void) fprintf(fp, gettext("\nThe feature@ properties must be "
+ "appended with a feature name.\nSee zpool-features(5).\n"));
}
/*
@@ -375,6 +382,18 @@ print_vdev_tree(zpool_handle_t *zhp, const char *name, nvlist_t *nv, int indent,
}
}
+static boolean_t
+prop_list_contains_feature(nvlist_t *proplist)
+{
+ nvpair_t *nvp;
+ for (nvp = nvlist_next_nvpair(proplist, NULL); NULL != nvp;
+ nvp = nvlist_next_nvpair(proplist, nvp)) {
+ if (zpool_prop_feature(nvpair_name(nvp)))
+ return (B_TRUE);
+ }
+ return (B_FALSE);
+}
+
/*
* Add a property pair (name, string-value) into a property nvlist.
*/
@@ -398,12 +417,34 @@ add_prop_list(const char *propname, char *propval, nvlist_t **props,
proplist = *props;
if (poolprop) {
- if ((prop = zpool_name_to_prop(propname)) == ZPROP_INVAL) {
+ const char *vname = zpool_prop_to_name(ZPOOL_PROP_VERSION);
+
+ if ((prop = zpool_name_to_prop(propname)) == ZPROP_INVAL &&
+ !zpool_prop_feature(propname)) {
(void) fprintf(stderr, gettext("property '%s' is "
"not a valid pool property\n"), propname);
return (2);
}
- normnm = zpool_prop_to_name(prop);
+
+ /*
+ * feature@ properties and version should not be specified
+ * at the same time.
+ */
+ if ((prop == ZPROP_INVAL && zpool_prop_feature(propname) &&
+ nvlist_exists(proplist, vname)) ||
+ (prop == ZPOOL_PROP_VERSION &&
+ prop_list_contains_feature(proplist))) {
+ (void) fprintf(stderr, gettext("'feature@' and "
+ "'version' properties cannot be specified "
+ "together\n"));
+ return (2);
+ }
+
+
+ if (zpool_prop_feature(propname))
+ normnm = propname;
+ else
+ normnm = zpool_prop_to_name(prop);
} else {
if ((fprop = zfs_name_to_prop(propname)) != ZPROP_INVAL) {
normnm = zfs_prop_to_name(fprop);
@@ -575,7 +616,7 @@ zpool_do_remove(int argc, char **argv)
}
/*
- * zpool create [-fn] [-o property=value] ...
+ * zpool create [-fnd] [-o property=value] ...
* [-O file-system-property=value] ...
* [-R root] [-m mountpoint] <pool> <dev> ...
*
@@ -584,8 +625,10 @@ zpool_do_remove(int argc, char **argv)
* were to be created.
* -R Create a pool under an alternate root
* -m Set default mountpoint for the root dataset. By default it's
- * '/<pool>'
+ * '/<pool>'
* -o Set property=value.
+ * -d Don't automatically enable all supported pool features
+ * (individual features can be enabled with -o).
* -O Set fsproperty=value in the pool's root file system
*
* Creates the named pool according to the given vdev specification. The
@@ -598,6 +641,7 @@ zpool_do_create(int argc, char **argv)
{
boolean_t force = B_FALSE;
boolean_t dryrun = B_FALSE;
+ boolean_t enable_all_pool_feat = B_TRUE;
int c;
nvlist_t *nvroot = NULL;
char *poolname;
@@ -609,7 +653,7 @@ zpool_do_create(int argc, char **argv)
char *propval;
/* check options */
- while ((c = getopt(argc, argv, ":fnR:m:o:O:")) != -1) {
+ while ((c = getopt(argc, argv, ":fndR:m:o:O:")) != -1) {
switch (c) {
case 'f':
force = B_TRUE;
@@ -617,6 +661,9 @@ zpool_do_create(int argc, char **argv)
case 'n':
dryrun = B_TRUE;
break;
+ case 'd':
+ enable_all_pool_feat = B_FALSE;
+ break;
case 'R':
altroot = optarg;
if (add_prop_list(zpool_prop_to_name(
@@ -644,6 +691,21 @@ zpool_do_create(int argc, char **argv)
if (add_prop_list(optarg, propval, &props, B_TRUE))
goto errout;
+
+ /*
+ * If the user is creating a pool that doesn't support
+ * feature flags, don't enable any features.
+ */
+ if (zpool_name_to_prop(optarg) == ZPOOL_PROP_VERSION) {
+ char *end;
+ u_longlong_t ver;
+
+ ver = strtoull(propval, &end, 10);
+ if (*end == '\0' &&
+ ver < SPA_VERSION_FEATURES) {
+ enable_all_pool_feat = B_FALSE;
+ }
+ }
break;
case 'O':
if ((propval = strchr(optarg, '=')) == NULL) {
@@ -709,7 +771,6 @@ zpool_do_create(int argc, char **argv)
goto errout;
}
-
if (altroot != NULL && altroot[0] != '/') {
(void) fprintf(stderr, gettext("invalid alternate root '%s': "
"must be an absolute path\n"), altroot);
@@ -791,6 +852,27 @@ zpool_do_create(int argc, char **argv)
/*
* Hand off to libzfs.
*/
+ if (enable_all_pool_feat) {
+ int i;
+ for (i = 0; i < SPA_FEATURES; i++) {
+ char propname[MAXPATHLEN];
+ zfeature_info_t *feat = &spa_feature_table[i];
+
+ (void) snprintf(propname, sizeof (propname),
+ "feature@%s", feat->fi_uname);
+
+ /*
+ * Skip feature if user specified it manually
+ * on the command line.
+ */
+ if (nvlist_exists(props, propname))
+ continue;
+
+ if (add_prop_list(propname, ZFS_FEATURE_ENABLED,
+ &props, B_TRUE) != 0)
+ goto errout;
+ }
+ }
if (zpool_create(g_zfs, poolname,
nvroot, props, fsprops) == 0) {
zfs_handle_t *pool = zfs_open(g_zfs, poolname,
@@ -884,7 +966,10 @@ zpool_do_destroy(int argc, char **argv)
return (1);
}
- ret = (zpool_destroy(zhp) != 0);
+ /* The history must be logged as part of the export */
+ log_history = B_FALSE;
+
+ ret = (zpool_destroy(zhp, history_str) != 0);
zpool_close(zhp);
@@ -948,10 +1033,13 @@ zpool_do_export(int argc, char **argv)
continue;
}
+ /* The history must be logged as part of the export */
+ log_history = B_FALSE;
+
if (hardforce) {
- if (zpool_export_force(zhp) != 0)
+ if (zpool_export_force(zhp, history_str) != 0)
ret = 1;
- } else if (zpool_export(zhp, force) != 0) {
+ } else if (zpool_export(zhp, force, history_str) != 0) {
ret = 1;
}
@@ -1122,6 +1210,10 @@ print_status_config(zpool_handle_t *zhp, const char *name, nvlist_t *nv,
(void) printf(gettext("newer version"));
break;
+ case VDEV_AUX_UNSUP_FEAT:
+ (void) printf(gettext("unsupported feature(s)"));
+ break;
+
case VDEV_AUX_SPARED:
verify(nvlist_lookup_uint64(nv, ZPOOL_CONFIG_GUID,
&cb.cb_guid) == 0);
@@ -1239,6 +1331,10 @@ print_import_config(const char *name, nvlist_t *nv, int namewidth, int depth)
(void) printf(gettext("newer version"));
break;
+ case VDEV_AUX_UNSUP_FEAT:
+ (void) printf(gettext("unsupported feature(s)"));
+ break;
+
case VDEV_AUX_ERR_EXCEEDED:
(void) printf(gettext("too many errors"));
break;
@@ -1396,8 +1492,8 @@ show_import(nvlist_t *config)
break;
case ZPOOL_STATUS_VERSION_OLDER:
- (void) printf(gettext(" status: The pool is formatted using an "
- "older on-disk version.\n"));
+ (void) printf(gettext(" status: The pool is formatted using a "
+ "legacy on-disk version.\n"));
break;
case ZPOOL_STATUS_VERSION_NEWER:
@@ -1405,6 +1501,25 @@ show_import(nvlist_t *config)
"incompatible version.\n"));
break;
+ case ZPOOL_STATUS_FEAT_DISABLED:
+ (void) printf(gettext(" status: Some supported features are "
+ "not enabled on the pool.\n"));
+ break;
+
+ case ZPOOL_STATUS_UNSUP_FEAT_READ:
+ (void) printf(gettext("status: The pool uses the following "
+ "feature(s) not supported on this sytem:\n"));
+ zpool_print_unsup_feat(config);
+ break;
+
+ case ZPOOL_STATUS_UNSUP_FEAT_WRITE:
+ (void) printf(gettext("status: The pool can only be accessed "
+ "in read-only mode on this system. It\n\tcannot be "
+ "accessed in read-write mode because it uses the "
+ "following\n\tfeature(s) not supported on this system:\n"));
+ zpool_print_unsup_feat(config);
+ break;
+
case ZPOOL_STATUS_HOSTID_MISMATCH:
(void) printf(gettext(" status: The pool was last accessed by "
"another system.\n"));
@@ -1437,19 +1552,21 @@ show_import(nvlist_t *config)
* Print out an action according to the overall state of the pool.
*/
if (vs->vs_state == VDEV_STATE_HEALTHY) {
- if (reason == ZPOOL_STATUS_VERSION_OLDER)
+ if (reason == ZPOOL_STATUS_VERSION_OLDER ||
+ reason == ZPOOL_STATUS_FEAT_DISABLED) {
(void) printf(gettext(" action: The pool can be "
"imported using its name or numeric identifier, "
"though\n\tsome features will not be available "
"without an explicit 'zpool upgrade'.\n"));
- else if (reason == ZPOOL_STATUS_HOSTID_MISMATCH)
+ } else if (reason == ZPOOL_STATUS_HOSTID_MISMATCH) {
(void) printf(gettext(" action: The pool can be "
"imported using its name or numeric "
"identifier and\n\tthe '-f' flag.\n"));
- else
+ } else {
(void) printf(gettext(" action: The pool can be "
"imported using its name or numeric "
"identifier.\n"));
+ }
} else if (vs->vs_state == VDEV_STATE_DEGRADED) {
(void) printf(gettext(" action: The pool can be imported "
"despite missing or damaged devices. The\n\tfault "
@@ -1462,6 +1579,20 @@ show_import(nvlist_t *config)
"newer\n\tsoftware, or recreate the pool from "
"backup.\n"));
break;
+ case ZPOOL_STATUS_UNSUP_FEAT_READ:
+ (void) printf(gettext("action: The pool cannot be "
+ "imported. Access the pool on a system that "
+ "supports\n\tthe required feature(s), or recreate "
+ "the pool from backup.\n"));
+ break;
+ case ZPOOL_STATUS_UNSUP_FEAT_WRITE:
+ (void) printf(gettext("action: The pool cannot be "
+ "imported in read-write mode. Import the pool "
+ "with\n"
+ "\t\"-o readonly=on\", access the pool on a system "
+ "that supports the\n\trequired feature(s), or "
+ "recreate the pool from backup.\n"));
+ break;
case ZPOOL_STATUS_MISSING_DEV_R:
case ZPOOL_STATUS_MISSING_DEV_NR:
case ZPOOL_STATUS_BAD_GUID_SUM:
@@ -1537,9 +1668,9 @@ do_import(nvlist_t *config, const char *newname, const char *mntopts,
ZPOOL_CONFIG_POOL_STATE, &state) == 0);
verify(nvlist_lookup_uint64(config,
ZPOOL_CONFIG_VERSION, &version) == 0);
- if (version > SPA_VERSION) {
+ if (!SPA_VERSION_IS_SUPPORTED(version)) {
(void) fprintf(stderr, gettext("cannot import '%s': pool "
- "is formatted using a newer ZFS version\n"), name);
+ "is formatted using an unsupported ZFS version\n"), name);
return (1);
} else if (state != POOL_STATE_EXPORTED &&
!(flags & ZFS_IMPORT_ANY_HOST)) {
@@ -2475,15 +2606,13 @@ static void
print_header(list_cbdata_t *cb)
{
zprop_list_t *pl = cb->cb_proplist;
+ char headerbuf[ZPOOL_MAXPROPLEN];
const char *header;
boolean_t first = B_TRUE;
boolean_t right_justify;
size_t width = 0;
for (; pl != NULL; pl = pl->pl_next) {
- if (pl->pl_prop == ZPROP_INVAL)
- continue;
-
width = pl->pl_width;
if (first && cb->cb_verbose) {
/*
@@ -2498,8 +2627,18 @@ print_header(list_cbdata_t *cb)
else
first = B_FALSE;
- header = zpool_prop_column_name(pl->pl_prop);
- right_justify = zpool_prop_align_right(pl->pl_prop);
+ right_justify = B_FALSE;
+ if (pl->pl_prop != ZPROP_INVAL) {
+ header = zpool_prop_column_name(pl->pl_prop);
+ right_justify = zpool_prop_align_right(pl->pl_prop);
+ } else {
+ int i;
+
+ for (i = 0; pl->pl_user_prop[i] != '\0'; i++)
+ headerbuf[i] = toupper(pl->pl_user_prop[i]);
+ headerbuf[i] = '\0';
+ header = headerbuf;
+ }
if (pl->pl_next == NULL && !right_justify)
(void) printf("%s", header);
@@ -2559,6 +2698,11 @@ print_pool(zpool_handle_t *zhp, list_cbdata_t *cb)
propstr = property;
right_justify = zpool_prop_align_right(pl->pl_prop);
+ } else if ((zpool_prop_feature(pl->pl_user_prop) ||
+ zpool_prop_unsupported(pl->pl_user_prop)) &&
+ zpool_prop_get_feature(zhp, pl->pl_user_prop, property,
+ sizeof (property)) == 0) {
+ propstr = property;
} else {
propstr = "-";
}
@@ -3885,12 +4029,13 @@ status_callback(zpool_handle_t *zhp, void *data)
break;
case ZPOOL_STATUS_VERSION_OLDER:
- (void) printf(gettext("status: The pool is formatted using an "
- "older on-disk format. The pool can\n\tstill be used, but "
- "some features are unavailable.\n"));
+ (void) printf(gettext("status: The pool is formatted using a "
+ "legacy on-disk format. The pool can\n\tstill be used, "
+ "but some features are unavailable.\n"));
(void) printf(gettext("action: Upgrade the pool using 'zpool "
"upgrade'. Once this is done, the\n\tpool will no longer "
- "be accessible on older software versions.\n"));
+ "be accessible on software that does not support feature\n"
+ "\tflags.\n"));
break;
case ZPOOL_STATUS_VERSION_NEWER:
@@ -3902,6 +4047,41 @@ status_callback(zpool_handle_t *zhp, void *data)
"backup.\n"));
break;
+ case ZPOOL_STATUS_FEAT_DISABLED:
+ (void) printf(gettext("status: Some supported features are not "
+ "enabled on the pool. The pool can\n\tstill be used, but "
+ "some features are unavailable.\n"));
+ (void) printf(gettext("action: Enable all features using "
+ "'zpool upgrade'. Once this is done,\n\tthe pool may no "
+ "longer be accessible by software that does not support\n\t"
+ "the features. See zpool-features(5) for details.\n"));
+ break;
+
+ case ZPOOL_STATUS_UNSUP_FEAT_READ:
+ (void) printf(gettext("status: The pool cannot be accessed on "
+ "this system because it uses the\n\tfollowing feature(s) "
+ "not supported on this system:\n"));
+ zpool_print_unsup_feat(config);
+ (void) printf("\n");
+ (void) printf(gettext("action: Access the pool from a system "
+ "that supports the required feature(s),\n\tor restore the "
+ "pool from backup.\n"));
+ break;
+
+ case ZPOOL_STATUS_UNSUP_FEAT_WRITE:
+ (void) printf(gettext("status: The pool can only be accessed "
+ "in read-only mode on this system. It\n\tcannot be "
+ "accessed in read-write mode because it uses the "
+ "following\n\tfeature(s) not supported on this system:\n"));
+ zpool_print_unsup_feat(config);
+ (void) printf("\n");
+ (void) printf(gettext("action: The pool cannot be accessed in "
+ "read-write mode. Import the pool with\n"
+ "\t\"-o readonly=on\", access the pool from a system that "
+ "supports the\n\trequired feature(s), or restore the "
+ "pool from backup.\n"));
+ break;
+
case ZPOOL_STATUS_FAULTED_DEV_R:
(void) printf(gettext("status: One or more devices are "
"faulted in response to persistent errors.\n\tSufficient "
@@ -4106,56 +4286,153 @@ zpool_do_status(int argc, char **argv)
}
typedef struct upgrade_cbdata {
- int cb_all;
int cb_first;
- int cb_newer;
int cb_argc;
uint64_t cb_version;
char **cb_argv;
} upgrade_cbdata_t;
static int
+upgrade_version(zpool_handle_t *zhp, uint64_t version)
+{
+ int ret;
+ nvlist_t *config;
+ uint64_t oldversion;
+
+ config = zpool_get_config(zhp, NULL);
+ verify(nvlist_lookup_uint64(config, ZPOOL_CONFIG_VERSION,
+ &oldversion) == 0);
+
+ assert(SPA_VERSION_IS_SUPPORTED(oldversion));
+ assert(oldversion < version);
+
+ ret = zpool_upgrade(zhp, version);
+ if (ret != 0)
+ return (ret);
+
+ if (version >= SPA_VERSION_FEATURES) {
+ (void) printf(gettext("Successfully upgraded "
+ "'%s' from version %llu to feature flags.\n"),
+ zpool_get_name(zhp), oldversion);
+ } else {
+ (void) printf(gettext("Successfully upgraded "
+ "'%s' from version %llu to version %llu.\n"),
+ zpool_get_name(zhp), oldversion, version);
+ }
+
+ return (0);
+}
+
+static int
+upgrade_enable_all(zpool_handle_t *zhp, int *countp)
+{
+ int i, ret, count;
+ boolean_t firstff = B_TRUE;
+ nvlist_t *enabled = zpool_get_features(zhp);
+
+ count = 0;
+ for (i = 0; i < SPA_FEATURES; i++) {
+ const char *fname = spa_feature_table[i].fi_uname;
+ const char *fguid = spa_feature_table[i].fi_guid;
+ if (!nvlist_exists(enabled, fguid)) {
+ char *propname;
+ verify(-1 != asprintf(&propname, "feature@%s", fname));
+ ret = zpool_set_prop(zhp, propname,
+ ZFS_FEATURE_ENABLED);
+ if (ret != 0) {
+ free(propname);
+ return (ret);
+ }
+ count++;
+
+ if (firstff) {
+ (void) printf(gettext("Enabled the "
+ "following features on '%s':\n"),
+ zpool_get_name(zhp));
+ firstff = B_FALSE;
+ }
+ (void) printf(gettext(" %s\n"), fname);
+ free(propname);
+ }
+ }
+
+ if (countp != NULL)
+ *countp = count;
+ return (0);
+}
+
+static int
upgrade_cb(zpool_handle_t *zhp, void *arg)
{
upgrade_cbdata_t *cbp = arg;
nvlist_t *config;
uint64_t version;
- int ret = 0;
+ boolean_t printnl = B_FALSE;
+ int ret;
config = zpool_get_config(zhp, NULL);
verify(nvlist_lookup_uint64(config, ZPOOL_CONFIG_VERSION,
&version) == 0);
- if (!cbp->cb_newer && version < SPA_VERSION) {
- if (!cbp->cb_all) {
- if (cbp->cb_first) {
- (void) printf(gettext("The following pools are "
- "out of date, and can be upgraded. After "
- "being\nupgraded, these pools will no "
- "longer be accessible by older software "
- "versions.\n\n"));
- (void) printf(gettext("VER POOL\n"));
- (void) printf(gettext("--- ------------\n"));
- cbp->cb_first = B_FALSE;
- }
+ assert(SPA_VERSION_IS_SUPPORTED(version));
- (void) printf("%2llu %s\n", (u_longlong_t)version,
- zpool_get_name(zhp));
- } else {
+ if (version < cbp->cb_version) {
+ cbp->cb_first = B_FALSE;
+ ret = upgrade_version(zhp, cbp->cb_version);
+ if (ret != 0)
+ return (ret);
+ printnl = B_TRUE;
+
+ /*
+ * If they did "zpool upgrade -a", then we could
+ * be doing ioctls to different pools. We need
+ * to log this history once to each pool, and bypass
+ * the normal history logging that happens in main().
+ */
+ (void) zpool_log_history(g_zfs, history_str);
+ log_history = B_FALSE;
+ }
+
+ if (cbp->cb_version >= SPA_VERSION_FEATURES) {
+ int count;
+ ret = upgrade_enable_all(zhp, &count);
+ if (ret != 0)
+ return (ret);
+
+ if (count > 0) {
cbp->cb_first = B_FALSE;
- ret = zpool_upgrade(zhp, cbp->cb_version);
- if (!ret) {
- (void) printf(gettext("Successfully upgraded "
- "'%s'\n\n"), zpool_get_name(zhp));
- }
+ printnl = B_TRUE;
}
- } else if (cbp->cb_newer && version > SPA_VERSION) {
- assert(!cbp->cb_all);
+ }
+
+ if (printnl) {
+ (void) printf(gettext("\n"));
+ }
+ return (0);
+}
+
+static int
+upgrade_list_older_cb(zpool_handle_t *zhp, void *arg)
+{
+ upgrade_cbdata_t *cbp = arg;
+ nvlist_t *config;
+ uint64_t version;
+
+ config = zpool_get_config(zhp, NULL);
+ verify(nvlist_lookup_uint64(config, ZPOOL_CONFIG_VERSION,
+ &version) == 0);
+
+ assert(SPA_VERSION_IS_SUPPORTED(version));
+
+ if (version < SPA_VERSION_FEATURES) {
if (cbp->cb_first) {
(void) printf(gettext("The following pools are "
- "formatted using a newer software version and\n"
- "cannot be accessed on the current system.\n\n"));
+ "formatted with legacy version numbers and can\n"
+ "be upgraded to use feature flags. After "
+ "being upgraded, these pools\nwill no "
+ "longer be accessible by software that does not "
+ "support feature\nflags.\n\n"));
(void) printf(gettext("VER POOL\n"));
(void) printf(gettext("--- ------------\n"));
cbp->cb_first = B_FALSE;
@@ -4165,14 +4442,65 @@ upgrade_cb(zpool_handle_t *zhp, void *arg)
zpool_get_name(zhp));
}
- zpool_close(zhp);
- return (ret);
+ return (0);
+}
+
+static int
+upgrade_list_disabled_cb(zpool_handle_t *zhp, void *arg)
+{
+ upgrade_cbdata_t *cbp = arg;
+ nvlist_t *config;
+ uint64_t version;
+
+ config = zpool_get_config(zhp, NULL);
+ verify(nvlist_lookup_uint64(config, ZPOOL_CONFIG_VERSION,
+ &version) == 0);
+
+ if (version >= SPA_VERSION_FEATURES) {
+ int i;
+ boolean_t poolfirst = B_TRUE;
+ nvlist_t *enabled = zpool_get_features(zhp);
+
+ for (i = 0; i < SPA_FEATURES; i++) {
+ const char *fguid = spa_feature_table[i].fi_guid;
+ const char *fname = spa_feature_table[i].fi_uname;
+ if (!nvlist_exists(enabled, fguid)) {
+ if (cbp->cb_first) {
+ (void) printf(gettext("\nSome "
+ "supported features are not "
+ "enabled on the following pools. "
+ "Once a\nfeature is enabled the "
+ "pool may become incompatible with "
+ "software\nthat does not support "
+ "the feature. See "
+ "zpool-features(5) for "
+ "details.\n\n"));
+ (void) printf(gettext("POOL "
+ "FEATURE\n"));
+ (void) printf(gettext("------"
+ "---------\n"));
+ cbp->cb_first = B_FALSE;
+ }
+
+ if (poolfirst) {
+ (void) printf(gettext("%s\n"),
+ zpool_get_name(zhp));
+ poolfirst = B_FALSE;
+ }
+
+ (void) printf(gettext(" %s\n"), fname);
+ }
+ }
+ }
+
+ return (0);
}
/* ARGSUSED */
static int
upgrade_one(zpool_handle_t *zhp, void *data)
{
+ boolean_t printnl = B_FALSE;
upgrade_cbdata_t *cbp = data;
uint64_t cur_version;
int ret;
@@ -4187,26 +4515,45 @@ upgrade_one(zpool_handle_t *zhp, void *data)
cur_version = zpool_get_prop_int(zhp, ZPOOL_PROP_VERSION, NULL);
if (cur_version > cbp->cb_version) {
(void) printf(gettext("Pool '%s' is already formatted "
- "using more current version '%llu'.\n"),
+ "using more current version '%llu'.\n\n"),
zpool_get_name(zhp), cur_version);
return (0);
}
- if (cur_version == cbp->cb_version) {
+
+ if (cbp->cb_version != SPA_VERSION && cur_version == cbp->cb_version) {
(void) printf(gettext("Pool '%s' is already formatted "
- "using the current version.\n"), zpool_get_name(zhp));
+ "using version %llu.\n\n"), zpool_get_name(zhp),
+ cbp->cb_version);
return (0);
}
- ret = zpool_upgrade(zhp, cbp->cb_version);
+ if (cur_version != cbp->cb_version) {
+ printnl = B_TRUE;
+ ret = upgrade_version(zhp, cbp->cb_version);
+ if (ret != 0)
+ return (ret);
+ }
+
+ if (cbp->cb_version >= SPA_VERSION_FEATURES) {
+ int count = 0;
+ ret = upgrade_enable_all(zhp, &count);
+ if (ret != 0)
+ return (ret);
- if (!ret) {
- (void) printf(gettext("Successfully upgraded '%s' "
- "from version %llu to version %llu\n\n"),
- zpool_get_name(zhp), (u_longlong_t)cur_version,
- (u_longlong_t)cbp->cb_version);
+ if (count != 0) {
+ printnl = B_TRUE;
+ } else if (cur_version == SPA_VERSION) {
+ (void) printf(gettext("Pool '%s' already has all "
+ "supported features enabled.\n"),
+ zpool_get_name(zhp));
+ }
+ }
+
+ if (printnl) {
+ (void) printf(gettext("\n"));
}
- return (ret != 0);
+ return (0);
}
/*
@@ -4225,6 +4572,7 @@ zpool_do_upgrade(int argc, char **argv)
upgrade_cbdata_t cb = { 0 };
int ret = 0;
boolean_t showversions = B_FALSE;
+ boolean_t upgradeall = B_FALSE;
char *end;
@@ -4232,15 +4580,15 @@ zpool_do_upgrade(int argc, char **argv)
while ((c = getopt(argc, argv, ":avV:")) != -1) {
switch (c) {
case 'a':
- cb.cb_all = B_TRUE;
+ upgradeall = B_TRUE;
break;
case 'v':
showversions = B_TRUE;
break;
case 'V':
cb.cb_version = strtoll(optarg, &end, 10);
- if (*end != '\0' || cb.cb_version > SPA_VERSION ||
- cb.cb_version < SPA_VERSION_1) {
+ if (*end != '\0' ||
+ !SPA_VERSION_IS_SUPPORTED(cb.cb_version)) {
(void) fprintf(stderr,
gettext("invalid version '%s'\n"), optarg);
usage(B_FALSE);
@@ -4265,19 +4613,19 @@ zpool_do_upgrade(int argc, char **argv)
if (cb.cb_version == 0) {
cb.cb_version = SPA_VERSION;
- } else if (!cb.cb_all && argc == 0) {
+ } else if (!upgradeall && argc == 0) {
(void) fprintf(stderr, gettext("-V option is "
"incompatible with other arguments\n"));
usage(B_FALSE);
}
if (showversions) {
- if (cb.cb_all || argc != 0) {
+ if (upgradeall || argc != 0) {
(void) fprintf(stderr, gettext("-v option is "
"incompatible with other arguments\n"));
usage(B_FALSE);
}
- } else if (cb.cb_all) {
+ } else if (upgradeall) {
if (argc != 0) {
(void) fprintf(stderr, gettext("-a option should not "
"be used along with a pool name\n"));
@@ -4285,11 +4633,27 @@ zpool_do_upgrade(int argc, char **argv)
}
}
- (void) printf(gettext("This system is currently running "
- "ZFS pool version %llu.\n\n"), SPA_VERSION);
- cb.cb_first = B_TRUE;
+ (void) printf(gettext("This system supports ZFS pool feature "
+ "flags.\n\n"));
if (showversions) {
- (void) printf(gettext("The following versions are "
+ int i;
+
+ (void) printf(gettext("The following features are "
+ "supported:\n\n"));
+ (void) printf(gettext("FEAT DESCRIPTION\n"));
+ (void) printf("----------------------------------------------"
+ "---------------\n");
+ for (i = 0; i < SPA_FEATURES; i++) {
+ zfeature_info_t *fi = &spa_feature_table[i];
+ const char *ro = fi->fi_can_readonly ?
+ " (read-only compatible)" : "";
+
+ (void) printf("%-37s%s\n", fi->fi_uname, ro);
+ (void) printf(" %s\n", fi->fi_desc);
+ }
+ (void) printf("\n");
+
+ (void) printf(gettext("The following legacy versions are also "
"supported:\n\n"));
(void) printf(gettext("VER DESCRIPTION\n"));
(void) printf("--- -----------------------------------------"
@@ -4332,32 +4696,44 @@ zpool_do_upgrade(int argc, char **argv)
(void) printf(gettext("\nFor more information on a particular "
"version, including supported releases,\n"));
(void) printf(gettext("see the ZFS Administration Guide.\n\n"));
- } else if (argc == 0) {
- int notfound;
-
+ } else if (argc == 0 && upgradeall) {
+ cb.cb_first = B_TRUE;
ret = zpool_iter(g_zfs, upgrade_cb, &cb);
- notfound = cb.cb_first;
-
- if (!cb.cb_all && ret == 0) {
- if (!cb.cb_first)
- (void) printf("\n");
- cb.cb_first = B_TRUE;
- cb.cb_newer = B_TRUE;
- ret = zpool_iter(g_zfs, upgrade_cb, &cb);
- if (!cb.cb_first) {
- notfound = B_FALSE;
- (void) printf("\n");
+ if (ret == 0 && cb.cb_first) {
+ if (cb.cb_version == SPA_VERSION) {
+ (void) printf(gettext("All pools are already "
+ "formatted using feature flags.\n\n"));
+ (void) printf(gettext("Every feature flags "
+ "pool already has all supported features "
+ "enabled.\n"));
+ } else {
+ (void) printf(gettext("All pools are already "
+ "formatted with version %llu or higher.\n"),
+ cb.cb_version);
}
}
+ } else if (argc == 0) {
+ cb.cb_first = B_TRUE;
+ ret = zpool_iter(g_zfs, upgrade_list_older_cb, &cb);
+ assert(ret == 0);
- if (ret == 0) {
- if (notfound)
- (void) printf(gettext("All pools are formatted "
- "using this version.\n"));
- else if (!cb.cb_all)
- (void) printf(gettext("Use 'zpool upgrade -v' "
- "for a list of available versions and "
- "their associated\nfeatures.\n"));
+ if (cb.cb_first) {
+ (void) printf(gettext("All pools are formatted "
+ "using feature flags.\n\n"));
+ } else {
+ (void) printf(gettext("\nUse 'zpool upgrade -v' "
+ "for a list of available legacy versions.\n"));
+ }
+
+ cb.cb_first = B_TRUE;
+ ret = zpool_iter(g_zfs, upgrade_list_disabled_cb, &cb);
+ assert(ret == 0);
+
+ if (cb.cb_first) {
+ (void) printf(gettext("Every feature flags pool has "
+ "all supported features enabled.\n"));
+ } else {
+ (void) printf(gettext("\n"));
}
} else {
ret = for_each_pool(argc, argv, B_FALSE, NULL,
@@ -4369,8 +4745,8 @@ zpool_do_upgrade(int argc, char **argv)
typedef struct hist_cbdata {
boolean_t first;
- int longfmt;
- int internal;
+ boolean_t longfmt;
+ boolean_t internal;
} hist_cbdata_t;
/*
@@ -4382,21 +4758,8 @@ get_history_one(zpool_handle_t *zhp, void *data)
nvlist_t *nvhis;
nvlist_t **records;
uint_t numrecords;
- char *cmdstr;
- char *pathstr;
- uint64_t dst_time;
- time_t tsec;
- struct tm t;
- char tbuf[30];
int ret, i;
- uint64_t who;
- struct passwd *pwd;
- char *hostname;
- char *zonename;
- char internalstr[MAXPATHLEN];
hist_cbdata_t *cb = (hist_cbdata_t *)data;
- uint64_t txg;
- uint64_t ievent;
cb->first = B_FALSE;
@@ -4408,64 +4771,94 @@ get_history_one(zpool_handle_t *zhp, void *data)
verify(nvlist_lookup_nvlist_array(nvhis, ZPOOL_HIST_RECORD,
&records, &numrecords) == 0);
for (i = 0; i < numrecords; i++) {
- if (nvlist_lookup_uint64(records[i], ZPOOL_HIST_TIME,
- &dst_time) != 0)
- continue;
+ nvlist_t *rec = records[i];
+ char tbuf[30] = "";
- /* is it an internal event or a standard event? */
- if (nvlist_lookup_string(records[i], ZPOOL_HIST_CMD,
- &cmdstr) != 0) {
- if (cb->internal == 0)
- continue;
+ if (nvlist_exists(rec, ZPOOL_HIST_TIME)) {
+ time_t tsec;
+ struct tm t;
- if (nvlist_lookup_uint64(records[i],
- ZPOOL_HIST_INT_EVENT, &ievent) != 0)
+ tsec = fnvlist_lookup_uint64(records[i],
+ ZPOOL_HIST_TIME);
+ (void) localtime_r(&tsec, &t);
+ (void) strftime(tbuf, sizeof (tbuf), "%F.%T", &t);
+ }
+
+ if (nvlist_exists(rec, ZPOOL_HIST_CMD)) {
+ (void) printf("%s %s", tbuf,
+ fnvlist_lookup_string(rec, ZPOOL_HIST_CMD));
+ } else if (nvlist_exists(rec, ZPOOL_HIST_INT_EVENT)) {
+ int ievent =
+ fnvlist_lookup_uint64(rec, ZPOOL_HIST_INT_EVENT);
+ if (!cb->internal)
continue;
- verify(nvlist_lookup_uint64(records[i],
- ZPOOL_HIST_TXG, &txg) == 0);
- verify(nvlist_lookup_string(records[i],
- ZPOOL_HIST_INT_STR, &pathstr) == 0);
- if (ievent >= LOG_END)
+ if (ievent >= ZFS_NUM_LEGACY_HISTORY_EVENTS) {
+ (void) printf("%s unrecognized record:\n",
+ tbuf);
+ dump_nvlist(rec, 4);
+ continue;
+ }
+ (void) printf("%s [internal %s txg:%lld] %s", tbuf,
+ zfs_history_event_names[ievent],
+ fnvlist_lookup_uint64(rec, ZPOOL_HIST_TXG),
+ fnvlist_lookup_string(rec, ZPOOL_HIST_INT_STR));
+ } else if (nvlist_exists(rec, ZPOOL_HIST_INT_NAME)) {
+ if (!cb->internal)
continue;
- (void) snprintf(internalstr,
- sizeof (internalstr),
- "[internal %s txg:%lld] %s",
- zfs_history_event_names[ievent], txg,
- pathstr);
- cmdstr = internalstr;
+ (void) printf("%s [txg:%lld] %s", tbuf,
+ fnvlist_lookup_uint64(rec, ZPOOL_HIST_TXG),
+ fnvlist_lookup_string(rec, ZPOOL_HIST_INT_NAME));
+ if (nvlist_exists(rec, ZPOOL_HIST_DSNAME)) {
+ (void) printf(" %s (%llu)",
+ fnvlist_lookup_string(rec,
+ ZPOOL_HIST_DSNAME),
+ fnvlist_lookup_uint64(rec,
+ ZPOOL_HIST_DSID));
+ }
+ (void) printf(" %s", fnvlist_lookup_string(rec,
+ ZPOOL_HIST_INT_STR));
+ } else if (nvlist_exists(rec, ZPOOL_HIST_IOCTL)) {
+ if (!cb->internal)
+ continue;
+ (void) printf("%s ioctl %s\n", tbuf,
+ fnvlist_lookup_string(rec, ZPOOL_HIST_IOCTL));
+ if (nvlist_exists(rec, ZPOOL_HIST_INPUT_NVL)) {
+ (void) printf(" input:\n");
+ dump_nvlist(fnvlist_lookup_nvlist(rec,
+ ZPOOL_HIST_INPUT_NVL), 8);
+ }
+ if (nvlist_exists(rec, ZPOOL_HIST_OUTPUT_NVL)) {
+ (void) printf(" output:\n");
+ dump_nvlist(fnvlist_lookup_nvlist(rec,
+ ZPOOL_HIST_OUTPUT_NVL), 8);
+ }
+ } else {
+ if (!cb->internal)
+ continue;
+ (void) printf("%s unrecognized record:\n", tbuf);
+ dump_nvlist(rec, 4);
}
- tsec = dst_time;
- (void) localtime_r(&tsec, &t);
- (void) strftime(tbuf, sizeof (tbuf), "%F.%T", &t);
- (void) printf("%s %s", tbuf, cmdstr);
if (!cb->longfmt) {
(void) printf("\n");
continue;
}
(void) printf(" [");
- if (nvlist_lookup_uint64(records[i],
- ZPOOL_HIST_WHO, &who) == 0) {
- pwd = getpwuid((uid_t)who);
- if (pwd)
- (void) printf("user %s on",
- pwd->pw_name);
- else
- (void) printf("user %d on",
- (int)who);
- } else {
- (void) printf(gettext("no info]\n"));
- continue;
+ if (nvlist_exists(rec, ZPOOL_HIST_WHO)) {
+ uid_t who = fnvlist_lookup_uint64(rec, ZPOOL_HIST_WHO);
+ struct passwd *pwd = getpwuid(who);
+ (void) printf("user %d ", (int)who);
+ if (pwd != NULL)
+ (void) printf("(%s) ", pwd->pw_name);
}
- if (nvlist_lookup_string(records[i],
- ZPOOL_HIST_HOST, &hostname) == 0) {
- (void) printf(" %s", hostname);
+ if (nvlist_exists(rec, ZPOOL_HIST_HOST)) {
+ (void) printf("on %s",
+ fnvlist_lookup_string(rec, ZPOOL_HIST_HOST));
}
- if (nvlist_lookup_string(records[i],
- ZPOOL_HIST_ZONE, &zonename) == 0) {
- (void) printf(":%s", zonename);
+ if (nvlist_exists(rec, ZPOOL_HIST_ZONE)) {
+ (void) printf(":%s",
+ fnvlist_lookup_string(rec, ZPOOL_HIST_ZONE));
}
-
(void) printf("]");
(void) printf("\n");
}
@@ -4480,8 +4873,6 @@ get_history_one(zpool_handle_t *zhp, void *data)
*
* Displays the history of commands that modified pools.
*/
-
-
int
zpool_do_history(int argc, char **argv)
{
@@ -4494,10 +4885,10 @@ zpool_do_history(int argc, char **argv)
while ((c = getopt(argc, argv, "li")) != -1) {
switch (c) {
case 'l':
- cbdata.longfmt = 1;
+ cbdata.longfmt = B_TRUE;
break;
case 'i':
- cbdata.internal = 1;
+ cbdata.internal = B_TRUE;
break;
case '?':
(void) fprintf(stderr, gettext("invalid option '%c'\n"),
@@ -4537,13 +4928,26 @@ get_callback(zpool_handle_t *zhp, void *data)
pl == cbp->cb_proplist)
continue;
- if (zpool_get_prop(zhp, pl->pl_prop,
- value, sizeof (value), &srctype, cbp->cb_literal) != 0)
- continue;
+ if (pl->pl_prop == ZPROP_INVAL &&
+ (zpool_prop_feature(pl->pl_user_prop) ||
+ zpool_prop_unsupported(pl->pl_user_prop))) {
+ srctype = ZPROP_SRC_LOCAL;
- zprop_print_one_property(zpool_get_name(zhp), cbp,
- zpool_prop_to_name(pl->pl_prop), value, srctype, NULL,
- NULL);
+ if (zpool_prop_get_feature(zhp, pl->pl_user_prop,
+ value, sizeof (value)) == 0) {
+ zprop_print_one_property(zpool_get_name(zhp),
+ cbp, pl->pl_user_prop, value, srctype,
+ NULL, NULL);
+ }
+ } else {
+ if (zpool_get_prop(zhp, pl->pl_prop, value,
+ sizeof (value), &srctype) != 0)
+ continue;
+
+ zprop_print_one_property(zpool_get_name(zhp), cbp,
+ zpool_prop_to_name(pl->pl_prop), value, srctype,
+ NULL, NULL);
+ }
}
return (0);
}
@@ -4572,8 +4976,11 @@ zpool_do_get(int argc, char **argv)
argc -= optind;
argv += optind;
- if (argc < 2)
+ if (argc < 2) {
+ (void) fprintf(stderr, gettext("missing property "
+ "argument\n"));
usage(B_FALSE);
+ }
cb.cb_first = B_TRUE;
cb.cb_sources = ZPROP_SRC_ALL;
@@ -4583,7 +4990,7 @@ zpool_do_get(int argc, char **argv)
cb.cb_columns[3] = GET_COL_SOURCE;
cb.cb_type = ZFS_TYPE_POOL;
- if (zprop_get_list(g_zfs, argv[0], &cb.cb_proplist,
+ if (zprop_get_list(g_zfs, argv[1], &cb.cb_proplist,
ZFS_TYPE_POOL) != 0)
usage(B_FALSE);
@@ -4723,8 +5130,7 @@ main(int argc, char **argv)
if (strcmp(cmdname, "-?") == 0)
usage(B_TRUE);
- zpool_set_history_str("zpool", argc, argv, history_str);
- verify(zpool_stage_history(g_zfs, history_str) == 0);
+ zfs_save_arguments(argc, argv, history_str, sizeof (history_str));
/*
* Run the appropriate command.
@@ -4751,6 +5157,9 @@ main(int argc, char **argv)
usage(B_FALSE);
}
+ if (ret == 0 && log_history)
+ (void) zpool_log_history(g_zfs, history_str);
+
libzfs_fini(g_zfs);
/*
diff --git a/usr/src/cmd/ztest/Makefile.com b/usr/src/cmd/ztest/Makefile.com
index 5f0a87b53a..0199a68b1e 100644
--- a/usr/src/cmd/ztest/Makefile.com
+++ b/usr/src/cmd/ztest/Makefile.com
@@ -20,6 +20,7 @@
#
#
# Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2012 by Delphix. All rights reserved.
#
PROG= ztest
@@ -29,8 +30,9 @@ SRCS= $(OBJS:%.o=../%.c)
include ../../Makefile.cmd
include ../../Makefile.ctf
-INCS += -I../../../lib/libzpool/common
-INCS += -I../../../uts/common/fs/zfs
+INCS += -I../../../lib/libzpool/common
+INCS += -I../../../uts/common/fs/zfs
+INCS += -I../../../common/zfs
LDLIBS += -lumem -lzpool -lcmdutils -lm -lnvpair
diff --git a/usr/src/cmd/ztest/ztest.c b/usr/src/cmd/ztest/ztest.c
index 9a7e625f95..63acd0c3aa 100644
--- a/usr/src/cmd/ztest/ztest.c
+++ b/usr/src/cmd/ztest/ztest.c
@@ -106,6 +106,7 @@
#include <sys/dsl_scan.h>
#include <sys/zio_checksum.h>
#include <sys/refcount.h>
+#include <sys/zfeature.h>
#include <stdio.h>
#include <stdio_ext.h>
#include <stdlib.h>
@@ -2251,7 +2252,7 @@ ztest_spa_create_destroy(ztest_ds_t *zd, uint64_t id)
*/
nvroot = make_vdev_root("/dev/bogus", NULL, 0, 0, 0, 0, 0, 1);
VERIFY3U(ENOENT, ==,
- spa_create("ztest_bad_file", nvroot, NULL, NULL, NULL));
+ spa_create("ztest_bad_file", nvroot, NULL, NULL));
nvlist_free(nvroot);
/*
@@ -2259,7 +2260,7 @@ ztest_spa_create_destroy(ztest_ds_t *zd, uint64_t id)
*/
nvroot = make_vdev_root("/dev/bogus", NULL, 0, 0, 0, 0, 2, 1);
VERIFY3U(ENOENT, ==,
- spa_create("ztest_bad_mirror", nvroot, NULL, NULL, NULL));
+ spa_create("ztest_bad_mirror", nvroot, NULL, NULL));
nvlist_free(nvroot);
/*
@@ -2268,7 +2269,7 @@ ztest_spa_create_destroy(ztest_ds_t *zd, uint64_t id)
*/
(void) rw_rdlock(&ztest_name_lock);
nvroot = make_vdev_root("/dev/bogus", NULL, 0, 0, 0, 0, 0, 1);
- VERIFY3U(EEXIST, ==, spa_create(zo->zo_pool, nvroot, NULL, NULL, NULL));
+ VERIFY3U(EEXIST, ==, spa_create(zo->zo_pool, nvroot, NULL, NULL));
nvlist_free(nvroot);
VERIFY3U(0, ==, spa_open(zo->zo_pool, &spa, FTAG));
VERIFY3U(EBUSY, ==, spa_destroy(zo->zo_pool));
@@ -3055,8 +3056,7 @@ ztest_snapshot_create(char *osname, uint64_t id)
(void) snprintf(snapname, MAXNAMELEN, "%s@%llu", osname,
(u_longlong_t)id);
- error = dmu_objset_snapshot(osname, strchr(snapname, '@') + 1,
- NULL, NULL, B_FALSE, B_FALSE, -1);
+ error = dmu_objset_snapshot_one(osname, strchr(snapname, '@') + 1);
if (error == ENOSPC) {
ztest_record_enospc(FTAG);
return (B_FALSE);
@@ -3256,8 +3256,7 @@ ztest_dsl_dataset_promote_busy(ztest_ds_t *zd, uint64_t id)
(void) snprintf(clone2name, MAXNAMELEN, "%s/c2_%llu", osname, id);
(void) snprintf(snap3name, MAXNAMELEN, "%s@s3_%llu", clone1name, id);
- error = dmu_objset_snapshot(osname, strchr(snap1name, '@')+1,
- NULL, NULL, B_FALSE, B_FALSE, -1);
+ error = dmu_objset_snapshot_one(osname, strchr(snap1name, '@') + 1);
if (error && error != EEXIST) {
if (error == ENOSPC) {
ztest_record_enospc(FTAG);
@@ -3280,8 +3279,7 @@ ztest_dsl_dataset_promote_busy(ztest_ds_t *zd, uint64_t id)
fatal(0, "dmu_objset_create(%s) = %d", clone1name, error);
}
- error = dmu_objset_snapshot(clone1name, strchr(snap2name, '@')+1,
- NULL, NULL, B_FALSE, B_FALSE, -1);
+ error = dmu_objset_snapshot_one(clone1name, strchr(snap2name, '@') + 1);
if (error && error != EEXIST) {
if (error == ENOSPC) {
ztest_record_enospc(FTAG);
@@ -3290,8 +3288,7 @@ ztest_dsl_dataset_promote_busy(ztest_ds_t *zd, uint64_t id)
fatal(0, "dmu_open_snapshot(%s) = %d", snap2name, error);
}
- error = dmu_objset_snapshot(clone1name, strchr(snap3name, '@')+1,
- NULL, NULL, B_FALSE, B_FALSE, -1);
+ error = dmu_objset_snapshot_one(clone1name, strchr(snap3name, '@') + 1);
if (error && error != EEXIST) {
if (error == ENOSPC) {
ztest_record_enospc(FTAG);
@@ -4479,8 +4476,7 @@ ztest_dmu_snapshot_hold(ztest_ds_t *zd, uint64_t id)
* Create snapshot, clone it, mark snap for deferred destroy,
* destroy clone, verify snap was also destroyed.
*/
- error = dmu_objset_snapshot(osname, snapname, NULL, NULL, FALSE,
- FALSE, -1);
+ error = dmu_objset_snapshot_one(osname, snapname);
if (error) {
if (error == ENOSPC) {
ztest_record_enospc("dmu_objset_snapshot");
@@ -4522,8 +4518,7 @@ ztest_dmu_snapshot_hold(ztest_ds_t *zd, uint64_t id)
* destroy a held snapshot, mark for deferred destroy,
* release hold, verify snapshot was destroyed.
*/
- error = dmu_objset_snapshot(osname, snapname, NULL, NULL, FALSE,
- FALSE, -1);
+ error = dmu_objset_snapshot_one(osname, snapname);
if (error) {
if (error == ENOSPC) {
ztest_record_enospc("dmu_objset_snapshot");
@@ -5572,10 +5567,9 @@ make_random_props()
{
nvlist_t *props;
- if (ztest_random(2) == 0)
- return (NULL);
-
VERIFY(nvlist_alloc(&props, NV_UNIQUE_NAME, 0) == 0);
+ if (ztest_random(2) == 0)
+ return (props);
VERIFY(nvlist_add_uint64(props, "autoreplace", 1) == 0);
return (props);
@@ -5606,13 +5600,19 @@ ztest_init(ztest_shared_t *zs)
nvroot = make_vdev_root(NULL, NULL, ztest_opts.zo_vdev_size, 0,
0, ztest_opts.zo_raidz, zs->zs_mirrors, 1);
props = make_random_props();
- VERIFY3U(0, ==, spa_create(ztest_opts.zo_pool, nvroot, props,
- NULL, NULL));
+ for (int i = 0; i < SPA_FEATURES; i++) {
+ char buf[1024];
+ (void) snprintf(buf, sizeof (buf), "feature@%s",
+ spa_feature_table[i].fi_uname);
+ VERIFY3U(0, ==, nvlist_add_uint64(props, buf, 0));
+ }
+ VERIFY3U(0, ==, spa_create(ztest_opts.zo_pool, nvroot, props, NULL));
nvlist_free(nvroot);
VERIFY3U(0, ==, spa_open(ztest_opts.zo_pool, &spa, FTAG));
zs->zs_metaslab_sz =
1ULL << spa->spa_root_vdev->vdev_child[0]->vdev_ms_shift;
+
spa_close(spa, FTAG);
kernel_fini();
@@ -5642,15 +5642,32 @@ setup_fds(void)
ASSERT3U(fd, ==, ZTEST_FD_RAND);
}
+static int
+shared_data_size(ztest_shared_hdr_t *hdr)
+{
+ int size;
+
+ size = hdr->zh_hdr_size;
+ size += hdr->zh_opts_size;
+ size += hdr->zh_size;
+ size += hdr->zh_stats_size * hdr->zh_stats_count;
+ size += hdr->zh_ds_size * hdr->zh_ds_count;
+
+ return (size);
+}
+
static void
setup_hdr(void)
{
+ int size;
ztest_shared_hdr_t *hdr;
hdr = (void *)mmap(0, P2ROUNDUP(sizeof (*hdr), getpagesize()),
PROT_READ | PROT_WRITE, MAP_SHARED, ZTEST_FD_DATA, 0);
ASSERT(hdr != MAP_FAILED);
+ VERIFY3U(0, ==, ftruncate(ZTEST_FD_DATA, sizeof (ztest_shared_hdr_t)));
+
hdr->zh_hdr_size = sizeof (ztest_shared_hdr_t);
hdr->zh_opts_size = sizeof (ztest_shared_opts_t);
hdr->zh_size = sizeof (ztest_shared_t);
@@ -5659,6 +5676,9 @@ setup_hdr(void)
hdr->zh_ds_size = sizeof (ztest_shared_ds_t);
hdr->zh_ds_count = ztest_opts.zo_datasets;
+ size = shared_data_size(hdr);
+ VERIFY3U(0, ==, ftruncate(ZTEST_FD_DATA, size));
+
(void) munmap((caddr_t)hdr, P2ROUNDUP(sizeof (*hdr), getpagesize()));
}
@@ -5673,11 +5693,7 @@ setup_data(void)
PROT_READ, MAP_SHARED, ZTEST_FD_DATA, 0);
ASSERT(hdr != MAP_FAILED);
- size = hdr->zh_hdr_size;
- size += hdr->zh_opts_size;
- size += hdr->zh_size;
- size += hdr->zh_stats_size * hdr->zh_stats_count;
- size += hdr->zh_ds_size * hdr->zh_ds_count;
+ size = shared_data_size(hdr);
(void) munmap((caddr_t)hdr, P2ROUNDUP(sizeof (*hdr), getpagesize()));
hdr = ztest_shared_hdr = (void *)mmap(0, P2ROUNDUP(size, getpagesize()),
diff --git a/usr/src/common/nvpair/fnvpair.c b/usr/src/common/nvpair/fnvpair.c
new file mode 100644
index 0000000000..8d1bb98be3
--- /dev/null
+++ b/usr/src/common/nvpair/fnvpair.c
@@ -0,0 +1,496 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (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) 2012 by Delphix. All rights reserved.
+ */
+
+#include <sys/nvpair.h>
+#include <sys/kmem.h>
+#include <sys/debug.h>
+#ifndef _KERNEL
+#include <stdlib.h>
+#endif
+
+/*
+ * "Force" nvlist wrapper.
+ *
+ * These functions wrap the nvlist_* functions with assertions that assume
+ * the operation is successful. This allows the caller's code to be much
+ * more readable, especially for the fnvlist_lookup_* and fnvpair_value_*
+ * functions, which can return the requested value (rather than filling in
+ * a pointer).
+ *
+ * These functions use NV_UNIQUE_NAME, encoding NV_ENCODE_NATIVE, and allocate
+ * with KM_SLEEP.
+ *
+ * More wrappers should be added as needed -- for example
+ * nvlist_lookup_*_array and nvpair_value_*_array.
+ */
+
+nvlist_t *
+fnvlist_alloc(void)
+{
+ nvlist_t *nvl;
+ VERIFY3U(nvlist_alloc(&nvl, NV_UNIQUE_NAME, KM_SLEEP), ==, 0);
+ return (nvl);
+}
+
+void
+fnvlist_free(nvlist_t *nvl)
+{
+ nvlist_free(nvl);
+}
+
+size_t
+fnvlist_size(nvlist_t *nvl)
+{
+ size_t size;
+ VERIFY3U(nvlist_size(nvl, &size, NV_ENCODE_NATIVE), ==, 0);
+ return (size);
+}
+
+/*
+ * Returns allocated buffer of size *sizep. Caller must free the buffer with
+ * fnvlist_pack_free().
+ */
+char *
+fnvlist_pack(nvlist_t *nvl, size_t *sizep)
+{
+ char *packed = 0;
+ VERIFY3U(nvlist_pack(nvl, &packed, sizep, NV_ENCODE_NATIVE,
+ KM_SLEEP), ==, 0);
+ return (packed);
+}
+
+/*ARGSUSED*/
+void
+fnvlist_pack_free(char *pack, size_t size)
+{
+#ifdef _KERNEL
+ kmem_free(pack, size);
+#else
+ free(pack);
+#endif
+}
+
+nvlist_t *
+fnvlist_unpack(char *buf, size_t buflen)
+{
+ nvlist_t *rv;
+ VERIFY3U(nvlist_unpack(buf, buflen, &rv, KM_SLEEP), ==, 0);
+ return (rv);
+}
+
+nvlist_t *
+fnvlist_dup(nvlist_t *nvl)
+{
+ nvlist_t *rv;
+ VERIFY3U(nvlist_dup(nvl, &rv, KM_SLEEP), ==, 0);
+ return (rv);
+}
+
+void
+fnvlist_merge(nvlist_t *dst, nvlist_t *src)
+{
+ VERIFY3U(nvlist_merge(dst, src, KM_SLEEP), ==, 0);
+}
+
+void
+fnvlist_add_boolean(nvlist_t *nvl, const char *name)
+{
+ VERIFY3U(nvlist_add_boolean(nvl, name), ==, 0);
+}
+
+void
+fnvlist_add_boolean_value(nvlist_t *nvl, const char *name, boolean_t val)
+{
+ VERIFY3U(nvlist_add_boolean_value(nvl, name, val), ==, 0);
+}
+
+void
+fnvlist_add_byte(nvlist_t *nvl, const char *name, uchar_t val)
+{
+ VERIFY3U(nvlist_add_byte(nvl, name, val), ==, 0);
+}
+
+void
+fnvlist_add_int8(nvlist_t *nvl, const char *name, int8_t val)
+{
+ VERIFY3U(nvlist_add_int8(nvl, name, val), ==, 0);
+}
+
+void
+fnvlist_add_uint8(nvlist_t *nvl, const char *name, uint8_t val)
+{
+ VERIFY3U(nvlist_add_uint8(nvl, name, val), ==, 0);
+}
+
+void
+fnvlist_add_int16(nvlist_t *nvl, const char *name, int16_t val)
+{
+ VERIFY3U(nvlist_add_int16(nvl, name, val), ==, 0);
+}
+
+void
+fnvlist_add_uint16(nvlist_t *nvl, const char *name, uint16_t val)
+{
+ VERIFY3U(nvlist_add_uint16(nvl, name, val), ==, 0);
+}
+
+void
+fnvlist_add_int32(nvlist_t *nvl, const char *name, int32_t val)
+{
+ VERIFY3U(nvlist_add_int32(nvl, name, val), ==, 0);
+}
+
+void
+fnvlist_add_uint32(nvlist_t *nvl, const char *name, uint32_t val)
+{
+ VERIFY3U(nvlist_add_uint32(nvl, name, val), ==, 0);
+}
+
+void
+fnvlist_add_int64(nvlist_t *nvl, const char *name, int64_t val)
+{
+ VERIFY3U(nvlist_add_int64(nvl, name, val), ==, 0);
+}
+
+void
+fnvlist_add_uint64(nvlist_t *nvl, const char *name, uint64_t val)
+{
+ VERIFY3U(nvlist_add_uint64(nvl, name, val), ==, 0);
+}
+
+void
+fnvlist_add_string(nvlist_t *nvl, const char *name, const char *val)
+{
+ VERIFY3U(nvlist_add_string(nvl, name, val), ==, 0);
+}
+
+void
+fnvlist_add_nvlist(nvlist_t *nvl, const char *name, nvlist_t *val)
+{
+ VERIFY3U(nvlist_add_nvlist(nvl, name, val), ==, 0);
+}
+
+void
+fnvlist_add_nvpair(nvlist_t *nvl, nvpair_t *pair)
+{
+ VERIFY3U(nvlist_add_nvpair(nvl, pair), ==, 0);
+}
+
+void
+fnvlist_add_boolean_array(nvlist_t *nvl, const char *name,
+ boolean_t *val, uint_t n)
+{
+ VERIFY3U(nvlist_add_boolean_array(nvl, name, val, n), ==, 0);
+}
+
+void
+fnvlist_add_byte_array(nvlist_t *nvl, const char *name, uchar_t *val, uint_t n)
+{
+ VERIFY3U(nvlist_add_byte_array(nvl, name, val, n), ==, 0);
+}
+
+void
+fnvlist_add_int8_array(nvlist_t *nvl, const char *name, int8_t *val, uint_t n)
+{
+ VERIFY3U(nvlist_add_int8_array(nvl, name, val, n), ==, 0);
+}
+
+void
+fnvlist_add_uint8_array(nvlist_t *nvl, const char *name, uint8_t *val, uint_t n)
+{
+ VERIFY3U(nvlist_add_uint8_array(nvl, name, val, n), ==, 0);
+}
+
+void
+fnvlist_add_int16_array(nvlist_t *nvl, const char *name, int16_t *val, uint_t n)
+{
+ VERIFY3U(nvlist_add_int16_array(nvl, name, val, n), ==, 0);
+}
+
+void
+fnvlist_add_uint16_array(nvlist_t *nvl, const char *name,
+ uint16_t *val, uint_t n)
+{
+ VERIFY3U(nvlist_add_uint16_array(nvl, name, val, n), ==, 0);
+}
+
+void
+fnvlist_add_int32_array(nvlist_t *nvl, const char *name, int32_t *val, uint_t n)
+{
+ VERIFY3U(nvlist_add_int32_array(nvl, name, val, n), ==, 0);
+}
+
+void
+fnvlist_add_uint32_array(nvlist_t *nvl, const char *name,
+ uint32_t *val, uint_t n)
+{
+ VERIFY3U(nvlist_add_uint32_array(nvl, name, val, n), ==, 0);
+}
+
+void
+fnvlist_add_int64_array(nvlist_t *nvl, const char *name, int64_t *val, uint_t n)
+{
+ VERIFY3U(nvlist_add_int64_array(nvl, name, val, n), ==, 0);
+}
+
+void
+fnvlist_add_uint64_array(nvlist_t *nvl, const char *name,
+ uint64_t *val, uint_t n)
+{
+ VERIFY3U(nvlist_add_uint64_array(nvl, name, val, n), ==, 0);
+}
+
+void
+fnvlist_add_string_array(nvlist_t *nvl, const char *name,
+ char * const *val, uint_t n)
+{
+ VERIFY3U(nvlist_add_string_array(nvl, name, val, n), ==, 0);
+}
+
+void
+fnvlist_add_nvlist_array(nvlist_t *nvl, const char *name,
+ nvlist_t **val, uint_t n)
+{
+ VERIFY3U(nvlist_add_nvlist_array(nvl, name, val, n), ==, 0);
+}
+
+void
+fnvlist_remove(nvlist_t *nvl, const char *name)
+{
+ VERIFY3U(nvlist_remove_all(nvl, name), ==, 0);
+}
+
+void
+fnvlist_remove_nvpair(nvlist_t *nvl, nvpair_t *pair)
+{
+ VERIFY3U(nvlist_remove_nvpair(nvl, pair), ==, 0);
+}
+
+nvpair_t *
+fnvlist_lookup_nvpair(nvlist_t *nvl, const char *name)
+{
+ nvpair_t *rv;
+ VERIFY3U(nvlist_lookup_nvpair(nvl, name, &rv), ==, 0);
+ return (rv);
+}
+
+/* returns B_TRUE if the entry exists */
+boolean_t
+fnvlist_lookup_boolean(nvlist_t *nvl, const char *name)
+{
+ return (nvlist_lookup_boolean(nvl, name) == 0);
+}
+
+boolean_t
+fnvlist_lookup_boolean_value(nvlist_t *nvl, const char *name)
+{
+ boolean_t rv;
+ VERIFY3U(nvlist_lookup_boolean_value(nvl, name, &rv), ==, 0);
+ return (rv);
+}
+
+uchar_t
+fnvlist_lookup_byte(nvlist_t *nvl, const char *name)
+{
+ uchar_t rv;
+ VERIFY3U(nvlist_lookup_byte(nvl, name, &rv), ==, 0);
+ return (rv);
+}
+
+int8_t
+fnvlist_lookup_int8(nvlist_t *nvl, const char *name)
+{
+ int8_t rv;
+ VERIFY3U(nvlist_lookup_int8(nvl, name, &rv), ==, 0);
+ return (rv);
+}
+
+int16_t
+fnvlist_lookup_int16(nvlist_t *nvl, const char *name)
+{
+ int16_t rv;
+ VERIFY3U(nvlist_lookup_int16(nvl, name, &rv), ==, 0);
+ return (rv);
+}
+
+int32_t
+fnvlist_lookup_int32(nvlist_t *nvl, const char *name)
+{
+ int32_t rv;
+ VERIFY3U(nvlist_lookup_int32(nvl, name, &rv), ==, 0);
+ return (rv);
+}
+
+int64_t
+fnvlist_lookup_int64(nvlist_t *nvl, const char *name)
+{
+ int64_t rv;
+ VERIFY3U(nvlist_lookup_int64(nvl, name, &rv), ==, 0);
+ return (rv);
+}
+
+uint8_t
+fnvlist_lookup_uint8_t(nvlist_t *nvl, const char *name)
+{
+ uint8_t rv;
+ VERIFY3U(nvlist_lookup_uint8(nvl, name, &rv), ==, 0);
+ return (rv);
+}
+
+uint16_t
+fnvlist_lookup_uint16(nvlist_t *nvl, const char *name)
+{
+ uint16_t rv;
+ VERIFY3U(nvlist_lookup_uint16(nvl, name, &rv), ==, 0);
+ return (rv);
+}
+
+uint32_t
+fnvlist_lookup_uint32(nvlist_t *nvl, const char *name)
+{
+ uint32_t rv;
+ VERIFY3U(nvlist_lookup_uint32(nvl, name, &rv), ==, 0);
+ return (rv);
+}
+
+uint64_t
+fnvlist_lookup_uint64(nvlist_t *nvl, const char *name)
+{
+ uint64_t rv;
+ VERIFY3U(nvlist_lookup_uint64(nvl, name, &rv), ==, 0);
+ return (rv);
+}
+
+char *
+fnvlist_lookup_string(nvlist_t *nvl, const char *name)
+{
+ char *rv;
+ VERIFY3U(nvlist_lookup_string(nvl, name, &rv), ==, 0);
+ return (rv);
+}
+
+nvlist_t *
+fnvlist_lookup_nvlist(nvlist_t *nvl, const char *name)
+{
+ nvlist_t *rv;
+ VERIFY3U(nvlist_lookup_nvlist(nvl, name, &rv), ==, 0);
+ return (rv);
+}
+
+boolean_t
+fnvpair_value_boolean_value(nvpair_t *nvp)
+{
+ boolean_t rv;
+ VERIFY3U(nvpair_value_boolean_value(nvp, &rv), ==, 0);
+ return (rv);
+}
+
+uchar_t
+fnvpair_value_byte(nvpair_t *nvp)
+{
+ uchar_t rv;
+ VERIFY3U(nvpair_value_byte(nvp, &rv), ==, 0);
+ return (rv);
+}
+
+int8_t
+fnvpair_value_int8(nvpair_t *nvp)
+{
+ int8_t rv;
+ VERIFY3U(nvpair_value_int8(nvp, &rv), ==, 0);
+ return (rv);
+}
+
+int16_t
+fnvpair_value_int16(nvpair_t *nvp)
+{
+ int16_t rv;
+ VERIFY3U(nvpair_value_int16(nvp, &rv), ==, 0);
+ return (rv);
+}
+
+int32_t
+fnvpair_value_int32(nvpair_t *nvp)
+{
+ int32_t rv;
+ VERIFY3U(nvpair_value_int32(nvp, &rv), ==, 0);
+ return (rv);
+}
+
+int64_t
+fnvpair_value_int64(nvpair_t *nvp)
+{
+ int64_t rv;
+ VERIFY3U(nvpair_value_int64(nvp, &rv), ==, 0);
+ return (rv);
+}
+
+uint8_t
+fnvpair_value_uint8_t(nvpair_t *nvp)
+{
+ uint8_t rv;
+ VERIFY3U(nvpair_value_uint8(nvp, &rv), ==, 0);
+ return (rv);
+}
+
+uint16_t
+fnvpair_value_uint16(nvpair_t *nvp)
+{
+ uint16_t rv;
+ VERIFY3U(nvpair_value_uint16(nvp, &rv), ==, 0);
+ return (rv);
+}
+
+uint32_t
+fnvpair_value_uint32(nvpair_t *nvp)
+{
+ uint32_t rv;
+ VERIFY3U(nvpair_value_uint32(nvp, &rv), ==, 0);
+ return (rv);
+}
+
+uint64_t
+fnvpair_value_uint64(nvpair_t *nvp)
+{
+ uint64_t rv;
+ VERIFY3U(nvpair_value_uint64(nvp, &rv), ==, 0);
+ return (rv);
+}
+
+char *
+fnvpair_value_string(nvpair_t *nvp)
+{
+ char *rv;
+ VERIFY3U(nvpair_value_string(nvp, &rv), ==, 0);
+ return (rv);
+}
+
+nvlist_t *
+fnvpair_value_nvlist(nvpair_t *nvp)
+{
+ nvlist_t *rv;
+ VERIFY3U(nvpair_value_nvlist(nvp, &rv), ==, 0);
+ return (rv);
+}
diff --git a/usr/src/common/zfs/zfeature_common.c b/usr/src/common/zfs/zfeature_common.c
new file mode 100644
index 0000000000..9c0b67b424
--- /dev/null
+++ b/usr/src/common/zfs/zfeature_common.c
@@ -0,0 +1,156 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (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) 2012 by Delphix. All rights reserved.
+ */
+
+#ifdef _KERNEL
+#include <sys/systm.h>
+#else
+#include <errno.h>
+#include <string.h>
+#endif
+#include <sys/debug.h>
+#include <sys/fs/zfs.h>
+#include <sys/inttypes.h>
+#include <sys/types.h>
+#include "zfeature_common.h"
+
+/*
+ * Set to disable all feature checks while opening pools, allowing pools with
+ * unsupported features to be opened. Set for testing only.
+ */
+boolean_t zfeature_checks_disable = B_FALSE;
+
+zfeature_info_t spa_feature_table[SPA_FEATURES];
+
+/*
+ * Valid characters for feature guids. This list is mainly for aesthetic
+ * purposes and could be expanded in the future. There are different allowed
+ * characters in the guids reverse dns portion (before the colon) and its
+ * short name (after the colon).
+ */
+static int
+valid_char(char c, boolean_t after_colon)
+{
+ return ((c >= 'a' && c <= 'z') ||
+ (c >= '0' && c <= '9') ||
+ c == (after_colon ? '_' : '.'));
+}
+
+/*
+ * Every feature guid must contain exactly one colon which separates a reverse
+ * dns organization name from the feature's "short" name (e.g.
+ * "com.company:feature_name").
+ */
+boolean_t
+zfeature_is_valid_guid(const char *name)
+{
+ int i;
+ boolean_t has_colon = B_FALSE;
+
+ i = 0;
+ while (name[i] != '\0') {
+ char c = name[i++];
+ if (c == ':') {
+ if (has_colon)
+ return (B_FALSE);
+ has_colon = B_TRUE;
+ continue;
+ }
+ if (!valid_char(c, has_colon))
+ return (B_FALSE);
+ }
+
+ return (has_colon);
+}
+
+boolean_t
+zfeature_is_supported(const char *guid)
+{
+ if (zfeature_checks_disable)
+ return (B_TRUE);
+
+ return (0 == zfeature_lookup_guid(guid, NULL));
+}
+
+int
+zfeature_lookup_guid(const char *guid, zfeature_info_t **res)
+{
+ for (int i = 0; i < SPA_FEATURES; i++) {
+ zfeature_info_t *feature = &spa_feature_table[i];
+ if (strcmp(guid, feature->fi_guid) == 0) {
+ if (res != NULL)
+ *res = feature;
+ return (0);
+ }
+ }
+
+ return (ENOENT);
+}
+
+int
+zfeature_lookup_name(const char *name, zfeature_info_t **res)
+{
+ for (int i = 0; i < SPA_FEATURES; i++) {
+ zfeature_info_t *feature = &spa_feature_table[i];
+ if (strcmp(name, feature->fi_uname) == 0) {
+ if (res != NULL)
+ *res = feature;
+ return (0);
+ }
+ }
+
+ return (ENOENT);
+}
+
+static void
+zfeature_register(int fid, const char *guid, const char *name, const char *desc,
+ boolean_t readonly, boolean_t mos, zfeature_info_t **deps)
+{
+ zfeature_info_t *feature = &spa_feature_table[fid];
+ static zfeature_info_t *nodeps[] = { NULL };
+
+ ASSERT(name != NULL);
+ ASSERT(desc != NULL);
+ ASSERT(!readonly || !mos);
+ ASSERT3U(fid, <, SPA_FEATURES);
+ ASSERT(zfeature_is_valid_guid(guid));
+
+ if (deps == NULL)
+ deps = nodeps;
+
+ feature->fi_guid = guid;
+ feature->fi_uname = name;
+ feature->fi_desc = desc;
+ feature->fi_can_readonly = readonly;
+ feature->fi_mos = mos;
+ feature->fi_depends = deps;
+}
+
+void
+zpool_feature_init(void)
+{
+ zfeature_register(SPA_FEATURE_ASYNC_DESTROY,
+ "com.delphix:async_destroy", "async_destroy",
+ "Destroy filesystems asynchronously.", B_TRUE, B_FALSE, NULL);
+}
diff --git a/usr/src/common/zfs/zfeature_common.h b/usr/src/common/zfs/zfeature_common.h
new file mode 100644
index 0000000000..93ba2b76f1
--- /dev/null
+++ b/usr/src/common/zfs/zfeature_common.h
@@ -0,0 +1,71 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (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) 2012 by Delphix. All rights reserved.
+ */
+
+#ifndef _ZFEATURE_COMMON_H
+#define _ZFEATURE_COMMON_H
+
+#include <sys/fs/zfs.h>
+#include <sys/inttypes.h>
+#include <sys/types.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+struct zfeature_info;
+
+typedef struct zfeature_info {
+ const char *fi_uname; /* User-facing feature name */
+ const char *fi_guid; /* On-disk feature identifier */
+ const char *fi_desc; /* Feature description */
+ boolean_t fi_can_readonly; /* Can open pool readonly w/o support? */
+ boolean_t fi_mos; /* Is the feature necessary to read the MOS? */
+ struct zfeature_info **fi_depends; /* array; null terminated */
+} zfeature_info_t;
+
+typedef int (zfeature_func_t)(zfeature_info_t *fi, void *arg);
+
+#define ZFS_FEATURE_DEBUG
+
+enum spa_feature {
+ SPA_FEATURE_ASYNC_DESTROY,
+ SPA_FEATURES
+} spa_feature_t;
+
+extern zfeature_info_t spa_feature_table[SPA_FEATURES];
+
+extern boolean_t zfeature_is_valid_guid(const char *);
+
+extern boolean_t zfeature_is_supported(const char *);
+extern int zfeature_lookup_guid(const char *, zfeature_info_t **res);
+extern int zfeature_lookup_name(const char *, zfeature_info_t **res);
+
+extern void zpool_feature_init(void);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _ZFEATURE_COMMON_H */
diff --git a/usr/src/common/zfs/zfs_comutil.c b/usr/src/common/zfs/zfs_comutil.c
index ed9b67ea3b..7688113e36 100644
--- a/usr/src/common/zfs/zfs_comutil.c
+++ b/usr/src/common/zfs/zfs_comutil.c
@@ -20,6 +20,7 @@
*/
/*
* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012 by Delphix. All rights reserved.
*/
/*
@@ -157,7 +158,11 @@ zfs_spa_version_map(int zpl_version)
return (version);
}
-const char *zfs_history_event_names[LOG_END] = {
+/*
+ * This is the table of legacy internal event names; it should not be modified.
+ * The internal events are now stored in the history log as strings.
+ */
+const char *zfs_history_event_names[ZFS_NUM_LEGACY_HISTORY_EVENTS] = {
"invalid event",
"pool create",
"vdev add",
diff --git a/usr/src/common/zfs/zfs_comutil.h b/usr/src/common/zfs/zfs_comutil.h
index 61327f9aa9..f89054388a 100644
--- a/usr/src/common/zfs/zfs_comutil.h
+++ b/usr/src/common/zfs/zfs_comutil.h
@@ -20,6 +20,7 @@
*/
/*
* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012 by Delphix. All rights reserved.
*/
#ifndef _ZFS_COMUTIL_H
@@ -37,7 +38,8 @@ extern void zpool_get_rewind_policy(nvlist_t *, zpool_rewind_policy_t *);
extern int zfs_zpl_version_map(int spa_version);
extern int zfs_spa_version_map(int zpl_version);
-extern const char *zfs_history_event_names[LOG_END];
+#define ZFS_NUM_LEGACY_HISTORY_EVENTS 41
+extern const char *zfs_history_event_names[ZFS_NUM_LEGACY_HISTORY_EVENTS];
#ifdef __cplusplus
}
diff --git a/usr/src/common/zfs/zpool_prop.c b/usr/src/common/zfs/zpool_prop.c
index 512e067507..72db879371 100644
--- a/usr/src/common/zfs/zpool_prop.c
+++ b/usr/src/common/zfs/zpool_prop.c
@@ -79,6 +79,8 @@ zpool_prop_init(void)
ZFS_TYPE_POOL, "<size>", "SIZE");
zprop_register_number(ZPOOL_PROP_FREE, "free", 0, PROP_READONLY,
ZFS_TYPE_POOL, "<size>", "FREE");
+ zprop_register_number(ZPOOL_PROP_FREEING, "freeing", 0, PROP_READONLY,
+ ZFS_TYPE_POOL, "<size>", "FREEING");
zprop_register_number(ZPOOL_PROP_ALLOCATED, "allocated", 0,
PROP_READONLY, ZFS_TYPE_POOL, "<size>", "ALLOC");
zprop_register_number(ZPOOL_PROP_EXPANDSZ, "expandsize", 0,
@@ -166,6 +168,26 @@ zpool_prop_default_numeric(zpool_prop_t prop)
return (zpool_prop_table[prop].pd_numdefault);
}
+/*
+ * Returns true if this is a valid feature@ property.
+ */
+boolean_t
+zpool_prop_feature(const char *name)
+{
+ static const char *prefix = "feature@";
+ return (strncmp(name, prefix, strlen(prefix)) == 0);
+}
+
+/*
+ * Returns true if this is a valid unsupported@ property.
+ */
+boolean_t
+zpool_prop_unsupported(const char *name)
+{
+ static const char *prefix = "unsupported@";
+ return (strncmp(name, prefix, strlen(prefix)) == 0);
+}
+
int
zpool_prop_string_to_index(zpool_prop_t prop, const char *string,
uint64_t *index)
diff --git a/usr/src/common/zfs/zprop_common.c b/usr/src/common/zfs/zprop_common.c
index 0bbf20d4f0..03919f0e91 100644
--- a/usr/src/common/zfs/zprop_common.c
+++ b/usr/src/common/zfs/zprop_common.c
@@ -22,6 +22,9 @@
* Copyright 2010 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
+/*
+ * Copyright (c) 2012 by Delphix. All rights reserved.
+ */
/*
* Common routines used by zfs and zpool property management.
@@ -129,7 +132,8 @@ zprop_register_hidden(int prop, const char *name, zprop_type_t type,
zprop_attr_t attr, int objset_types, const char *colname)
{
zprop_register_impl(prop, name, type, 0, NULL, attr,
- objset_types, NULL, colname, B_FALSE, B_FALSE, NULL);
+ objset_types, NULL, colname,
+ type == PROP_TYPE_NUMBER, B_FALSE, NULL);
}
diff --git a/usr/src/grub/capability b/usr/src/grub/capability
index 225ce5bb83..44aaae2cb8 100644
--- a/usr/src/grub/capability
+++ b/usr/src/grub/capability
@@ -19,7 +19,7 @@
# CDDL HEADER END
#
# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
-#
+# Copyright (c) 2012 by Delphix. All rights reserved.
#
# This file defines the current capabilities of GRUB over and above that
# supported by the standard distribution
@@ -39,7 +39,7 @@
# This file and the associated version are Solaris specific and are
# not a part of the open source distribution of GRUB.
#
-VERSION=20
+VERSION=21
dboot
xVM
zfs
diff --git a/usr/src/grub/grub-0.97/stage2/fsys_zfs.c b/usr/src/grub/grub-0.97/stage2/fsys_zfs.c
index 4eed0afe9a..3d1129c4ea 100644
--- a/usr/src/grub/grub-0.97/stage2/fsys_zfs.c
+++ b/usr/src/grub/grub-0.97/stage2/fsys_zfs.c
@@ -16,12 +16,17 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
+
/*
* Copyright 2010 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
+ * Copyright (c) 2012 by Delphix. All rights reserved.
+ */
+
+/*
* The zfs plug-in routines for GRUB are:
*
* zfs_mount() - locates a valid uberblock of the root pool and reads
@@ -118,16 +123,16 @@ zio_checksum_off(const void *buf, uint64_t size, zio_cksum_t *zcp)
/* Checksum Table and Values */
zio_checksum_info_t zio_checksum_table[ZIO_CHECKSUM_FUNCTIONS] = {
- NULL, NULL, 0, 0, "inherit",
- NULL, NULL, 0, 0, "on",
- zio_checksum_off, zio_checksum_off, 0, 0, "off",
- zio_checksum_SHA256, zio_checksum_SHA256, 1, 1, "label",
- zio_checksum_SHA256, zio_checksum_SHA256, 1, 1, "gang_header",
- NULL, NULL, 0, 0, "zilog",
- fletcher_2_native, fletcher_2_byteswap, 0, 0, "fletcher2",
- fletcher_4_native, fletcher_4_byteswap, 1, 0, "fletcher4",
- zio_checksum_SHA256, zio_checksum_SHA256, 1, 0, "SHA256",
- NULL, NULL, 0, 0, "zilog2",
+ {{NULL, NULL}, 0, 0, "inherit"},
+ {{NULL, NULL}, 0, 0, "on"},
+ {{zio_checksum_off, zio_checksum_off}, 0, 0, "off"},
+ {{zio_checksum_SHA256, zio_checksum_SHA256}, 1, 1, "label"},
+ {{zio_checksum_SHA256, zio_checksum_SHA256}, 1, 1, "gang_header"},
+ {{NULL, NULL}, 0, 0, "zilog"},
+ {{fletcher_2_native, fletcher_2_byteswap}, 0, 0, "fletcher2"},
+ {{fletcher_4_native, fletcher_4_byteswap}, 1, 0, "fletcher4"},
+ {{zio_checksum_SHA256, zio_checksum_SHA256}, 1, 0, "SHA256"},
+ {{NULL, NULL}, 0, 0, "zilog2"},
};
/*
@@ -217,9 +222,6 @@ vdev_uberblock_compare(uberblock_t *ub1, uberblock_t *ub2)
* Three pieces of information are needed to verify an uberblock: the magic
* number, the version number, and the checksum.
*
- * Currently Implemented: version number, magic number
- * Need to Implement: checksum
- *
* Return:
* 0 - Success
* -1 - Failure
@@ -238,7 +240,7 @@ uberblock_verify(uberblock_t *uber, uint64_t ub_size, uint64_t offset)
return (-1);
if (uber->ub_magic == UBERBLOCK_MAGIC &&
- uber->ub_version > 0 && uber->ub_version <= SPA_VERSION)
+ SPA_VERSION_IS_SUPPORTED(uber->ub_version))
return (0);
return (-1);
@@ -296,7 +298,7 @@ zio_read_gang(blkptr_t *bp, dva_t *dva, void *buf, char *stack)
zio_gb = (zio_gbh_phys_t *)stack;
stack += SPA_GANGBLOCKSIZE;
offset = DVA_GET_OFFSET(dva);
- sector = DVA_OFFSET_TO_PHYS_SECTOR(offset);
+ sector = DVA_OFFSET_TO_PHYS_SECTOR(offset);
/* read in the gang block header */
if (devread(sector, 0, SPA_GANGBLOCKSIZE, (char *)zio_gb) == 0) {
@@ -355,8 +357,8 @@ zio_read_data(blkptr_t *bp, void *buf, char *stack)
} else {
/* read in a data block */
offset = DVA_GET_OFFSET(&bp->blk_dva[i]);
- sector = DVA_OFFSET_TO_PHYS_SECTOR(offset);
- if (devread(sector, 0, psize, buf))
+ sector = DVA_OFFSET_TO_PHYS_SECTOR(offset);
+ if (devread(sector, 0, psize, buf) != 0)
return (0);
}
}
@@ -400,7 +402,7 @@ zio_read(blkptr_t *bp, void *buf, char *stack)
stack += psize;
}
- if (zio_read_data(bp, buf, stack)) {
+ if (zio_read_data(bp, buf, stack) != 0) {
grub_printf("zio_read_data failed\n");
return (ERR_FSYS_CORRUPT);
}
@@ -466,13 +468,13 @@ dmu_read(dnode_phys_t *dn, uint64_t blkid, void *buf, char *stack)
* errnum - failure
*/
static int
-mzap_lookup(mzap_phys_t *zapobj, int objsize, char *name,
+mzap_lookup(mzap_phys_t *zapobj, int objsize, const char *name,
uint64_t *value)
{
int i, chunks;
mzap_ent_phys_t *mzap_ent = zapobj->mz_chunk;
- chunks = objsize/MZAP_ENT_LEN - 1;
+ chunks = objsize / MZAP_ENT_LEN - 1;
for (i = 0; i < chunks; i++) {
if (grub_strcmp(mzap_ent[i].mze_name, name) == 0) {
*value = mzap_ent[i].mze_value;
@@ -512,8 +514,8 @@ zap_hash(uint64_t salt, const char *name)
/*
* Only use 28 bits, since we need 4 bits in the cookie for the
* collision differentiator. We MUST use the high bits, since
- * those are the onces that we first pay attention to when
- * chosing the bucket.
+ * those are the ones that we first pay attention to when
+ * choosing the bucket.
*/
crc &= ~((1ULL << (64 - 28)) - 1);
@@ -618,7 +620,7 @@ zap_leaf_lookup(zap_leaf_phys_t *l, int blksft, uint64_t h,
*/
static int
fzap_lookup(dnode_phys_t *zap_dnode, zap_phys_t *zap,
- char *name, uint64_t *value, char *stack)
+ const char *name, uint64_t *value, char *stack)
{
zap_leaf_phys_t *l;
uint64_t hash, idx, blkid;
@@ -661,7 +663,8 @@ fzap_lookup(dnode_phys_t *zap_dnode, zap_phys_t *zap,
* errnum - failure
*/
static int
-zap_lookup(dnode_phys_t *zap_dnode, char *name, uint64_t *val, char *stack)
+zap_lookup(dnode_phys_t *zap_dnode, const char *name, uint64_t *val,
+ char *stack)
{
uint64_t block_type;
int size;
@@ -672,7 +675,7 @@ zap_lookup(dnode_phys_t *zap_dnode, char *name, uint64_t *val, char *stack)
size = zap_dnode->dn_datablkszsec << SPA_MINBLOCKSHIFT;
stack += size;
- if (errnum = dmu_read(zap_dnode, 0, zapbuf, stack))
+ if ((errnum = dmu_read(zap_dnode, 0, zapbuf, stack)) != 0)
return (errnum);
block_type = *((uint64_t *)zapbuf);
@@ -688,6 +691,56 @@ zap_lookup(dnode_phys_t *zap_dnode, char *name, uint64_t *val, char *stack)
return (ERR_FSYS_CORRUPT);
}
+typedef struct zap_attribute {
+ int za_integer_length;
+ uint64_t za_num_integers;
+ uint64_t za_first_integer;
+ char *za_name;
+} zap_attribute_t;
+
+typedef int (zap_cb_t)(zap_attribute_t *za, void *arg, char *stack);
+
+static int
+zap_iterate(dnode_phys_t *zap_dnode, zap_cb_t *cb, void *arg, char *stack)
+{
+ uint32_t size = zap_dnode->dn_datablkszsec << SPA_MINBLOCKSHIFT;
+ zap_attribute_t za;
+ int i;
+ mzap_phys_t *mzp = (mzap_phys_t *)stack;
+ stack += size;
+
+ if ((errnum = dmu_read(zap_dnode, 0, mzp, stack)) != 0)
+ return (errnum);
+
+ /*
+ * Iteration over fatzap objects has not yet been implemented.
+ * If we encounter a pool in which there are more features for
+ * read than can fit inside a microzap (i.e., more than 2048
+ * features for read), we can add support for fatzap iteration.
+ * For now, fail.
+ */
+ if (mzp->mz_block_type != ZBT_MICRO) {
+ grub_printf("feature information stored in fatzap, pool "
+ "version not supported\n");
+ return (1);
+ }
+
+ za.za_integer_length = 8;
+ za.za_num_integers = 1;
+ for (i = 0; i < size / MZAP_ENT_LEN - 1; i++) {
+ mzap_ent_phys_t *mzep = &mzp->mz_chunk[i];
+ int err;
+
+ za.za_first_integer = mzep->mze_value;
+ za.za_name = mzep->mze_name;
+ err = cb(&za, arg, stack);
+ if (err != 0)
+ return (err);
+ }
+
+ return (0);
+}
+
/*
* Get the dnode of an object number from the metadnode of an object set.
*
@@ -767,6 +820,24 @@ is_top_dataset_file(char *str)
return (0);
}
+static int
+check_feature(zap_attribute_t *za, void *arg, char *stack)
+{
+ const char **names = arg;
+ int i;
+
+ if (za->za_first_integer == 0)
+ return (0);
+
+ for (i = 0; names[i] != NULL; i++) {
+ if (grub_strcmp(za->za_name, names[i]) == 0) {
+ return (0);
+ }
+ }
+ grub_printf("missing feature for read '%s'\n", za->za_name);
+ return (ERR_NEWER_VERSION);
+}
+
/*
* Get the file dnode for a given file name where mdn is the meta dnode
* for this ZFS object set. When found, place the file dnode in dn.
@@ -803,11 +874,11 @@ dnode_get_path(dnode_phys_t *mdn, char *path, dnode_phys_t *dn,
while (*path == '/')
path++;
- while (*path && !isspace(*path)) {
+ while (*path && !grub_isspace(*path)) {
/* get the next component name */
cname = path;
- while (*path && !isspace(*path) && *path != '/')
+ while (*path && !grub_isspace(*path) && *path != '/')
path++;
ch = *path;
*path = 0; /* ensure null termination */
@@ -869,6 +940,53 @@ get_default_bootfsobj(dnode_phys_t *mosmdn, uint64_t *obj, char *stack)
}
/*
+ * List of pool features that the grub implementation of ZFS supports for
+ * read. Note that features that are only required for write do not need
+ * to be listed here since grub opens pools in read-only mode.
+ */
+static const char *spa_feature_names[] = {
+ NULL
+};
+
+/*
+ * Checks whether the MOS features that are active are supported by this
+ * (GRUB's) implementation of ZFS.
+ *
+ * Return:
+ * 0: Success.
+ * errnum: Failure.
+ */
+static int
+check_mos_features(dnode_phys_t *mosmdn, char *stack)
+{
+ uint64_t objnum;
+ dnode_phys_t *dn;
+ uint8_t error = 0;
+
+ dn = (dnode_phys_t *)stack;
+ stack += DNODE_SIZE;
+
+ if ((errnum = dnode_get(mosmdn, DMU_POOL_DIRECTORY_OBJECT,
+ DMU_OT_OBJECT_DIRECTORY, dn, stack)) != 0)
+ return (errnum);
+
+ /*
+ * Find the object number for 'features_for_read' and retrieve its
+ * corresponding dnode. Note that we don't check features_for_write
+ * because GRUB is not opening the pool for write.
+ */
+ if ((errnum = zap_lookup(dn, DMU_POOL_FEATURES_FOR_READ, &objnum,
+ stack)) != 0)
+ return (errnum);
+
+ if ((errnum = dnode_get(mosmdn, objnum, DMU_OTN_ZAP_METADATA,
+ dn, stack)) != 0)
+ return (errnum);
+
+ return (zap_iterate(dn, check_feature, spa_feature_names, stack));
+}
+
+/*
* Given a MOS metadnode, get the metadnode of a given filesystem name (fsname),
* e.g. pool/rootfs, or a given object number (obj), e.g. the object number
* of pool/rootfs.
@@ -915,23 +1033,24 @@ get_objset_mdn(dnode_phys_t *mosmdn, char *fsname, uint64_t *obj,
}
/* take out the pool name */
- while (*fsname && !isspace(*fsname) && *fsname != '/')
+ while (*fsname && !grub_isspace(*fsname) && *fsname != '/')
fsname++;
- while (*fsname && !isspace(*fsname)) {
+ while (*fsname && !grub_isspace(*fsname)) {
uint64_t childobj;
while (*fsname == '/')
fsname++;
cname = fsname;
- while (*fsname && !isspace(*fsname) && *fsname != '/')
+ while (*fsname && !grub_isspace(*fsname) && *fsname != '/')
fsname++;
ch = *fsname;
*fsname = 0;
snapname = cname;
- while (*snapname && !isspace(*snapname) && *snapname != '@')
+ while (*snapname && !grub_isspace(*snapname) && *snapname !=
+ '@')
snapname++;
if (*snapname == '@') {
issnapshot = 1;
@@ -1020,8 +1139,7 @@ nvlist_unpack(char *nvlist, char **out)
if (nvlist[0] != NV_ENCODE_XDR || nvlist[1] != HOST_ENDIAN)
return (1);
- nvlist += 4;
- *out = nvlist;
+ *out = nvlist + 4;
return (0);
}
@@ -1043,72 +1161,162 @@ nvlist_array(char *nvlist, int index)
return (nvlist);
}
+/*
+ * The nvlist_next_nvpair() function returns a handle to the next nvpair in the
+ * list following nvpair. If nvpair is NULL, the first pair is returned. If
+ * nvpair is the last pair in the nvlist, NULL is returned.
+ */
+static char *
+nvlist_next_nvpair(char *nvl, char *nvpair)
+{
+ char *cur, *prev;
+ int encode_size;
+
+ if (nvl == NULL)
+ return (NULL);
+
+ if (nvpair == NULL) {
+ /* skip over nvl_version and nvl_nvflag */
+ nvpair = nvl + 4 * 2;
+ } else {
+ /* skip to the next nvpair */
+ encode_size = BSWAP_32(*(uint32_t *)nvpair);
+ nvpair += encode_size;
+ }
+
+ /* 8 bytes of 0 marks the end of the list */
+ if (*(uint64_t *)nvpair == 0)
+ return (NULL);
+
+ return (nvpair);
+}
+
+/*
+ * This function returns 0 on success and 1 on failure. On success, a string
+ * containing the name of nvpair is saved in buf.
+ */
static int
-nvlist_lookup_value(char *nvlist, char *name, void *val, int valtype,
- int *nelmp)
+nvpair_name(char *nvp, char *buf, int buflen)
+{
+ int len;
+
+ /* skip over encode/decode size */
+ nvp += 4 * 2;
+
+ len = BSWAP_32(*(uint32_t *)nvp);
+ if (buflen < len + 1)
+ return (1);
+
+ grub_memmove(buf, nvp + 4, len);
+ buf[len] = '\0';
+
+ return (0);
+}
+
+/*
+ * This function retrieves the value of the nvpair in the form of enumerated
+ * type data_type_t. This is used to determine the appropriate type to pass to
+ * nvpair_value().
+ */
+static int
+nvpair_type(char *nvp)
{
- int name_len, type, slen, encode_size;
- char *nvpair, *nvp_name, *strval = val;
+ int name_len, type;
+
+ /* skip over encode/decode size */
+ nvp += 4 * 2;
+
+ /* skip over name_len */
+ name_len = BSWAP_32(*(uint32_t *)nvp);
+ nvp += 4;
+
+ /* skip over name */
+ nvp = nvp + ((name_len + 3) & ~3); /* align */
+
+ type = BSWAP_32(*(uint32_t *)nvp);
+
+ return (type);
+}
+
+static int
+nvpair_value(char *nvp, void *val, int valtype, int *nelmp)
+{
+ int name_len, type, slen;
+ char *strval = val;
uint64_t *intval = val;
- /* skip the header, nvl_version, and nvl_nvflag */
- nvlist = nvlist + 4 * 2;
+ /* skip over encode/decode size */
+ nvp += 4 * 2;
- /*
- * Loop thru the nvpair list
- * The XDR representation of an integer is in big-endian byte order.
- */
- while (encode_size = BSWAP_32(*(uint32_t *)nvlist)) {
+ /* skip over name_len */
+ name_len = BSWAP_32(*(uint32_t *)nvp);
+ nvp += 4;
- nvpair = nvlist + 4 * 2; /* skip the encode/decode size */
+ /* skip over name */
+ nvp = nvp + ((name_len + 3) & ~3); /* align */
- name_len = BSWAP_32(*(uint32_t *)nvpair);
- nvpair += 4;
+ /* skip over type */
+ type = BSWAP_32(*(uint32_t *)nvp);
+ nvp += 4;
- nvp_name = nvpair;
- nvpair = nvpair + ((name_len + 3) & ~3); /* align */
+ if (type == valtype) {
+ int nelm;
- type = BSWAP_32(*(uint32_t *)nvpair);
- nvpair += 4;
+ nelm = BSWAP_32(*(uint32_t *)nvp);
+ if (valtype != DATA_TYPE_BOOLEAN && nelm < 1)
+ return (1);
+ nvp += 4;
- if ((grub_strncmp(nvp_name, name, name_len) == 0) &&
- type == valtype) {
- int nelm;
+ switch (valtype) {
+ case DATA_TYPE_BOOLEAN:
+ return (0);
- if ((nelm = BSWAP_32(*(uint32_t *)nvpair)) < 1)
- return (1);
- nvpair += 4;
-
- switch (valtype) {
- case DATA_TYPE_STRING:
- slen = BSWAP_32(*(uint32_t *)nvpair);
- nvpair += 4;
- grub_memmove(strval, nvpair, slen);
- strval[slen] = '\0';
- return (0);
+ case DATA_TYPE_STRING:
+ slen = BSWAP_32(*(uint32_t *)nvp);
+ nvp += 4;
+ grub_memmove(strval, nvp, slen);
+ strval[slen] = '\0';
+ return (0);
- case DATA_TYPE_UINT64:
- *intval = BSWAP_64(*(uint64_t *)nvpair);
- return (0);
+ case DATA_TYPE_UINT64:
+ *intval = BSWAP_64(*(uint64_t *)nvp);
+ return (0);
- case DATA_TYPE_NVLIST:
- *(void **)val = (void *)nvpair;
- return (0);
+ case DATA_TYPE_NVLIST:
+ *(void **)val = (void *)nvp;
+ return (0);
- case DATA_TYPE_NVLIST_ARRAY:
- *(void **)val = (void *)nvpair;
- if (nelmp)
- *nelmp = nelm;
- return (0);
- }
+ case DATA_TYPE_NVLIST_ARRAY:
+ *(void **)val = (void *)nvp;
+ if (nelmp)
+ *nelmp = nelm;
+ return (0);
}
-
- nvlist += encode_size; /* goto the next nvpair */
}
return (1);
}
+static int
+nvlist_lookup_value(char *nvlist, char *name, void *val, int valtype,
+ int *nelmp)
+{
+ char *nvpair;
+
+ for (nvpair = nvlist_next_nvpair(nvlist, NULL);
+ nvpair != NULL;
+ nvpair = nvlist_next_nvpair(nvlist, nvpair)) {
+ int name_len = BSWAP_32(*(uint32_t *)(nvpair + 4 * 2));
+ char *nvp_name = nvpair + 4 * 3;
+
+ if ((grub_strncmp(nvp_name, name, name_len) == 0) &&
+ nvpair_type(nvpair) == valtype) {
+ return (nvpair_value(nvpair, val, valtype, nelmp));
+ }
+ }
+ return (1);
+}
+
/*
* Check if this vdev is online and is in a good state.
*/
@@ -1142,7 +1350,7 @@ vdev_get_bootpath(char *nv, uint64_t inguid, char *devid, char *bootpath,
NULL))
return (ERR_FSYS_CORRUPT);
- if (strcmp(type, VDEV_TYPE_DISK) == 0) {
+ if (grub_strcmp(type, VDEV_TYPE_DISK) == 0) {
uint64_t guid;
if (vdev_validate(nv) != 0)
@@ -1172,15 +1380,15 @@ vdev_get_bootpath(char *nv, uint64_t inguid, char *devid, char *bootpath,
devid, DATA_TYPE_STRING, NULL) != 0)
devid[0] = '\0';
- if (strlen(bootpath) >= MAXPATHLEN ||
- strlen(devid) >= MAXPATHLEN)
+ if (grub_strlen(bootpath) >= MAXPATHLEN ||
+ grub_strlen(devid) >= MAXPATHLEN)
return (ERR_WONT_FIT);
return (0);
- } else if (strcmp(type, VDEV_TYPE_MIRROR) == 0 ||
- strcmp(type, VDEV_TYPE_REPLACING) == 0 ||
- (is_spare = (strcmp(type, VDEV_TYPE_SPARE) == 0))) {
+ } else if (grub_strcmp(type, VDEV_TYPE_MIRROR) == 0 ||
+ grub_strcmp(type, VDEV_TYPE_REPLACING) == 0 ||
+ (is_spare = (grub_strcmp(type, VDEV_TYPE_SPARE) == 0))) {
int nelm, i;
char *child;
@@ -1208,15 +1416,14 @@ vdev_get_bootpath(char *nv, uint64_t inguid, char *devid, char *bootpath,
* 0 - success
* ERR_* - failure
*/
-int
+static int
check_pool_label(uint64_t sector, char *stack, char *outdevid,
- char *outpath, uint64_t *outguid, uint64_t *outashift)
+ char *outpath, uint64_t *outguid, uint64_t *outashift, uint64_t *outversion)
{
vdev_phys_t *vdev;
uint64_t pool_state, txg = 0;
- char *nvlist, *nv;
+ char *nvlist, *nv, *features;
uint64_t diskguid;
- uint64_t version;
sector += (VDEV_SKIP_SIZE >> SPA_MINBLOCKSHIFT);
@@ -1249,10 +1456,10 @@ check_pool_label(uint64_t sector, char *stack, char *outdevid,
if (txg == 0)
return (ERR_NO_BOOTPATH);
- if (nvlist_lookup_value(nvlist, ZPOOL_CONFIG_VERSION, &version,
+ if (nvlist_lookup_value(nvlist, ZPOOL_CONFIG_VERSION, outversion,
DATA_TYPE_UINT64, NULL))
return (ERR_FSYS_CORRUPT);
- if (version > SPA_VERSION)
+ if (!SPA_VERSION_IS_SUPPORTED(*outversion))
return (ERR_NEWER_VERSION);
if (nvlist_lookup_value(nvlist, ZPOOL_CONFIG_VDEV_TREE, &nv,
DATA_TYPE_NVLIST, NULL))
@@ -1268,6 +1475,30 @@ check_pool_label(uint64_t sector, char *stack, char *outdevid,
if (nvlist_lookup_value(nvlist, ZPOOL_CONFIG_POOL_GUID, outguid,
DATA_TYPE_UINT64, NULL))
return (ERR_FSYS_CORRUPT);
+
+ if (nvlist_lookup_value(nvlist, ZPOOL_CONFIG_FEATURES_FOR_READ,
+ &features, DATA_TYPE_NVLIST, NULL) == 0) {
+ char *nvp;
+ char *name = stack;
+ stack += MAXNAMELEN;
+
+ for (nvp = nvlist_next_nvpair(features, NULL);
+ nvp != NULL;
+ nvp = nvlist_next_nvpair(features, nvp)) {
+ zap_attribute_t za;
+
+ if (nvpair_name(nvp, name, MAXNAMELEN) != 0)
+ return (ERR_FSYS_CORRUPT);
+
+ za.za_integer_length = 8;
+ za.za_num_integers = 1;
+ za.za_first_integer = 1;
+ za.za_name = name;
+ if (check_feature(&za, spa_feature_names, stack) != 0)
+ return (ERR_NEWER_VERSION);
+ }
+ }
+
return (0);
}
@@ -1288,7 +1519,7 @@ zfs_mount(void)
objset_phys_t *osp;
char tmp_bootpath[MAXNAMELEN];
char tmp_devid[MAXNAMELEN];
- uint64_t tmp_guid, ashift;
+ uint64_t tmp_guid, ashift, version;
uint64_t adjpl = (uint64_t)part_length << SPA_MINBLOCKSHIFT;
int err = errnum; /* preserve previous errnum state */
@@ -1331,7 +1562,7 @@ zfs_mount(void)
continue;
if (check_pool_label(sector, stack, tmp_devid,
- tmp_bootpath, &tmp_guid, &ashift))
+ tmp_bootpath, &tmp_guid, &ashift, &version))
continue;
if (pool_guid == 0)
@@ -1343,6 +1574,10 @@ zfs_mount(void)
VERIFY_OS_TYPE(osp, DMU_OST_META);
+ if (version >= SPA_VERSION_FEATURES &&
+ check_mos_features(&osp->os_meta_dnode, stack) != 0)
+ continue;
+
if (find_best_root && ((pool_guid != tmp_guid) ||
vdev_uberblock_compare(ubbest, &(current_uberblock)) <= 0))
continue;
@@ -1479,7 +1714,6 @@ int
zfs_read(char *buf, int len)
{
char *stack;
- char *tmpbuf;
int blksz, length, movesize;
if (file_buf == NULL) {
diff --git a/usr/src/grub/grub-0.97/stage2/fsys_zfs.h b/usr/src/grub/grub-0.97/stage2/fsys_zfs.h
index b0fdc6e2e9..11236c33de 100644
--- a/usr/src/grub/grub-0.97/stage2/fsys_zfs.h
+++ b/usr/src/grub/grub-0.97/stage2/fsys_zfs.h
@@ -16,10 +16,16 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
+
/*
* Copyright 2010 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
+
+/*
+ * Copyright (c) 2012 by Delphix. All rights reserved.
+ */
+
#ifndef _FSYS_ZFS_H
#define _FSYS_ZFS_H
@@ -119,10 +125,36 @@ typedef struct uberblock uberblock_t;
#define NV_ENCODE_NATIVE 0
#define NV_ENCODE_XDR 1
#define HOST_ENDIAN 1 /* for x86 machine */
-#define DATA_TYPE_UINT64 8
-#define DATA_TYPE_STRING 9
-#define DATA_TYPE_NVLIST 19
-#define DATA_TYPE_NVLIST_ARRAY 20
+typedef enum {
+ DATA_TYPE_UNKNOWN = 0,
+ DATA_TYPE_BOOLEAN,
+ DATA_TYPE_BYTE,
+ DATA_TYPE_INT16,
+ DATA_TYPE_UINT16,
+ DATA_TYPE_INT32,
+ DATA_TYPE_UINT32,
+ DATA_TYPE_INT64,
+ DATA_TYPE_UINT64,
+ DATA_TYPE_STRING,
+ DATA_TYPE_BYTE_ARRAY,
+ DATA_TYPE_INT16_ARRAY,
+ DATA_TYPE_UINT16_ARRAY,
+ DATA_TYPE_INT32_ARRAY,
+ DATA_TYPE_UINT32_ARRAY,
+ DATA_TYPE_INT64_ARRAY,
+ DATA_TYPE_UINT64_ARRAY,
+ DATA_TYPE_STRING_ARRAY,
+ DATA_TYPE_HRTIME,
+ DATA_TYPE_NVLIST,
+ DATA_TYPE_NVLIST_ARRAY,
+ DATA_TYPE_BOOLEAN_VALUE,
+ DATA_TYPE_INT8,
+ DATA_TYPE_UINT8,
+ DATA_TYPE_BOOLEAN_ARRAY,
+ DATA_TYPE_INT8_ARRAY,
+ DATA_TYPE_UINT8_ARRAY,
+ DATA_TYPE_DOUBLE
+} data_type_t;
/*
* Decompression Entry - lzjb
diff --git a/usr/src/grub/grub-0.97/stage2/zfs-include/dmu.h b/usr/src/grub/grub-0.97/stage2/zfs-include/dmu.h
index 7faa7088b5..0e88a8fcde 100644
--- a/usr/src/grub/grub-0.97/stage2/zfs-include/dmu.h
+++ b/usr/src/grub/grub-0.97/stage2/zfs-include/dmu.h
@@ -16,11 +16,16 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
+
/*
* Copyright 2010 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
+/*
+ * Copyright (c) 2012 by Delphix. All rights reserved.
+ */
+
#ifndef _SYS_DMU_H
#define _SYS_DMU_H
@@ -31,6 +36,41 @@
* The DMU also interacts with the SPA. That interface is described in
* dmu_spa.h.
*/
+
+#define B_FALSE 0
+#define B_TRUE 1
+
+#define DMU_OT_NEWTYPE 0x80
+#define DMU_OT_METADATA 0x40
+#define DMU_OT_BYTESWAP_MASK 0x3f
+
+#define DMU_OT(byteswap, metadata) \
+ (DMU_OT_NEWTYPE | \
+ ((metadata) ? DMU_OT_METADATA : 0) | \
+ ((byteswap) & DMU_OT_BYTESWAP_MASK))
+
+#define DMU_OT_IS_VALID(ot) (((ot) & DMU_OT_NEWTYPE) ? \
+ ((ot) & DMU_OT_BYTESWAP_MASK) < DMU_BSWAP_NUMFUNCS : \
+ (ot) < DMU_OT_NUMTYPES)
+
+#define DMU_OT_IS_METADATA(ot) (((ot) & DMU_OT_NEWTYPE) ? \
+ ((ot) & DMU_OT_METADATA) : \
+ dmu_ot[(ot)].ot_metadata)
+
+typedef enum dmu_object_byteswap {
+ DMU_BSWAP_UINT8,
+ DMU_BSWAP_UINT16,
+ DMU_BSWAP_UINT32,
+ DMU_BSWAP_UINT64,
+ DMU_BSWAP_ZAP,
+ DMU_BSWAP_DNODE,
+ DMU_BSWAP_OBJSET,
+ DMU_BSWAP_ZNODE,
+ DMU_BSWAP_OLDACL,
+ DMU_BSWAP_ACL,
+ DMU_BSWAP_NUMFUNCS
+} dmu_object_byteswap_t;
+
typedef enum dmu_object_type {
DMU_OT_NONE,
/* general: */
@@ -38,8 +78,8 @@ typedef enum dmu_object_type {
DMU_OT_OBJECT_ARRAY, /* UINT64 */
DMU_OT_PACKED_NVLIST, /* UINT8 (XDR by nvlist_pack/unpack) */
DMU_OT_PACKED_NVLIST_SIZE, /* UINT64 */
- DMU_OT_BPLIST, /* UINT64 */
- DMU_OT_BPLIST_HDR, /* UINT64 */
+ DMU_OT_BPOBJ, /* UINT64 */
+ DMU_OT_BPOBJ_HDR, /* UINT64 */
/* spa: */
DMU_OT_SPACE_MAP_HEADER, /* UINT64 */
DMU_OT_SPACE_MAP, /* UINT64 */
@@ -56,7 +96,7 @@ typedef enum dmu_object_type {
DMU_OT_DSL_DATASET, /* UINT64 */
/* zpl: */
DMU_OT_ZNODE, /* ZNODE */
- DMU_OT_OLDACL, /* OLD ACL */
+ DMU_OT_OLDACL, /* Old ACL */
DMU_OT_PLAIN_FILE_CONTENTS, /* UINT8 */
DMU_OT_DIRECTORY_CONTENTS, /* ZAP */
DMU_OT_MASTER_NODE, /* ZAP */
@@ -79,7 +119,7 @@ typedef enum dmu_object_type {
DMU_OT_FUID, /* FUID table (Packed NVLIST UINT8) */
DMU_OT_FUID_SIZE, /* FUID table size UINT64 */
DMU_OT_NEXT_CLONES, /* ZAP */
- DMU_OT_SCRUB_QUEUE, /* ZAP */
+ DMU_OT_SCAN_QUEUE, /* ZAP */
DMU_OT_USERGROUP_USED, /* ZAP */
DMU_OT_USERGROUP_QUOTA, /* ZAP */
DMU_OT_USERREFS, /* ZAP */
@@ -89,7 +129,24 @@ typedef enum dmu_object_type {
DMU_OT_SA_MASTER_NODE, /* ZAP */
DMU_OT_SA_ATTR_REGISTRATION, /* ZAP */
DMU_OT_SA_ATTR_LAYOUTS, /* ZAP */
- DMU_OT_NUMTYPES
+ DMU_OT_SCAN_XLATE, /* ZAP */
+ DMU_OT_DEDUP, /* fake dedup BP from ddt_bp_create() */
+ DMU_OT_DEADLIST, /* ZAP */
+ DMU_OT_DEADLIST_HDR, /* UINT64 */
+ DMU_OT_DSL_CLONES, /* ZAP */
+ DMU_OT_BPOBJ_SUBOBJ, /* UINT64 */
+ DMU_OT_NUMTYPES,
+
+ DMU_OTN_UINT8_DATA = DMU_OT(DMU_BSWAP_UINT8, B_FALSE),
+ DMU_OTN_UINT8_METADATA = DMU_OT(DMU_BSWAP_UINT8, B_TRUE),
+ DMU_OTN_UINT16_DATA = DMU_OT(DMU_BSWAP_UINT16, B_FALSE),
+ DMU_OTN_UINT16_METADATA = DMU_OT(DMU_BSWAP_UINT16, B_TRUE),
+ DMU_OTN_UINT32_DATA = DMU_OT(DMU_BSWAP_UINT32, B_FALSE),
+ DMU_OTN_UINT32_METADATA = DMU_OT(DMU_BSWAP_UINT32, B_TRUE),
+ DMU_OTN_UINT64_DATA = DMU_OT(DMU_BSWAP_UINT64, B_FALSE),
+ DMU_OTN_UINT64_METADATA = DMU_OT(DMU_BSWAP_UINT64, B_TRUE),
+ DMU_OTN_ZAP_DATA = DMU_OT(DMU_BSWAP_ZAP, B_FALSE),
+ DMU_OTN_ZAP_METADATA = DMU_OT(DMU_BSWAP_ZAP, B_TRUE),
} dmu_object_type_t;
typedef enum dmu_objset_type {
@@ -107,6 +164,9 @@ typedef enum dmu_objset_type {
*/
#define DMU_POOL_DIRECTORY_OBJECT 1
#define DMU_POOL_CONFIG "config"
+#define DMU_POOL_FEATURES_FOR_READ "features_for_read"
+#define DMU_POOL_FEATURES_FOR_WRITE "features_for_write"
+#define DMU_POOL_FEATURE_DESCRIPTIONS "feature_descriptions"
#define DMU_POOL_ROOT_DATASET "root_dataset"
#define DMU_POOL_SYNC_BPLIST "sync_bplist"
#define DMU_POOL_ERRLOG_SCRUB "errlog_scrub"
diff --git a/usr/src/grub/grub-0.97/stage2/zfs-include/spa.h b/usr/src/grub/grub-0.97/stage2/zfs-include/spa.h
index 4c943310dc..4cb53c2d51 100644
--- a/usr/src/grub/grub-0.97/stage2/zfs-include/spa.h
+++ b/usr/src/grub/grub-0.97/stage2/zfs-include/spa.h
@@ -16,11 +16,16 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
+
/*
* Copyright 2010 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
+/*
+ * Copyright (c) 2012 by Delphix. All rights reserved.
+ */
+
#ifndef _SYS_SPA_H
#define _SYS_SPA_H
@@ -65,7 +70,7 @@
/*
* Size of block to hold the configuration data (a packed nvlist)
*/
-#define SPA_CONFIG_BLOCKSIZE (1 << 14)
+#define SPA_CONFIG_BLOCKSIZE (1ULL << 14)
/*
* The DVA size encodings for LSIZE and PSIZE support blocks up to 32MB.
diff --git a/usr/src/grub/grub-0.97/stage2/zfs-include/zfs.h b/usr/src/grub/grub-0.97/stage2/zfs-include/zfs.h
index 9ad1367ed3..7180d8a515 100644
--- a/usr/src/grub/grub-0.97/stage2/zfs-include/zfs.h
+++ b/usr/src/grub/grub-0.97/stage2/zfs-include/zfs.h
@@ -16,8 +16,10 @@
* along with this program; if not, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
+
/*
* Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012 by Delphix. All rights reserved.
*/
#ifndef _SYS_FS_ZFS_H
@@ -26,7 +28,14 @@
/*
* On-disk version number.
*/
-#define SPA_VERSION 28ULL
+#define SPA_VERSION_INITIAL 1ULL
+#define SPA_VERSION_BEFORE_FEATURES 28ULL
+#define SPA_VERSION 5000ULL
+#define SPA_VERSION_FEATURES 5000ULL
+
+#define SPA_VERSION_IS_SUPPORTED(v) \
+ (((v) >= SPA_VERSION_INITIAL && (v) <= SPA_VERSION_BEFORE_FEATURES) || \
+ ((v) >= SPA_VERSION_FEATURES && (v) <= SPA_VERSION))
/*
* The following are configuration names used in the nvlist describing a pool's
@@ -66,6 +75,7 @@
#define ZPOOL_CONFIG_DDT_HISTOGRAM "ddt_histogram"
#define ZPOOL_CONFIG_DDT_OBJ_STATS "ddt_object_stats"
#define ZPOOL_CONFIG_DDT_STATS "ddt_stats"
+#define ZPOOL_CONFIG_FEATURES_FOR_READ "features_for_read"
/*
* The persistent vdev state is stored as separate values rather than a single
* 'vdev_state' entry. This is because a device can be in multiple states, such
diff --git a/usr/src/head/iso/setjmp_iso.h b/usr/src/head/iso/setjmp_iso.h
index 5edbdf4ecf..d22c4b4e0e 100644
--- a/usr/src/head/iso/setjmp_iso.h
+++ b/usr/src/head/iso/setjmp_iso.h
@@ -43,9 +43,6 @@
#ifndef _ISO_SETJMP_ISO_H
#define _ISO_SETJMP_ISO_H
-#pragma ident "%Z%%M% %I% %E% SMI"
-/* SVr4.0 1.9.2.9 */
-
#include <sys/feature_tests.h>
#ifdef __cplusplus
@@ -92,18 +89,18 @@ typedef int jmp_buf[_JBLEN];
#if defined(__STDC__)
-extern int setjmp(jmp_buf);
+extern int setjmp(jmp_buf) __RETURNS_TWICE;
#pragma unknown_control_flow(setjmp)
-extern int _setjmp(jmp_buf);
+extern int _setjmp(jmp_buf) __RETURNS_TWICE;
#pragma unknown_control_flow(_setjmp)
extern void longjmp(jmp_buf, int) __NORETURN;
extern void _longjmp(jmp_buf, int) __NORETURN;
#else
-extern int setjmp();
+extern int setjmp() __RETURNS_TWICE;
#pragma unknown_control_flow(setjmp)
-extern int _setjmp();
+extern int _setjmp() __RETURNS_TWICE;
#pragma unknown_control_flow(_setjmp)
extern void longjmp();
extern void _longjmp();
diff --git a/usr/src/head/setjmp.h b/usr/src/head/setjmp.h
index 0a7f65224d..fe85be6b84 100644
--- a/usr/src/head/setjmp.h
+++ b/usr/src/head/setjmp.h
@@ -31,8 +31,6 @@
#ifndef _SETJMP_H
#define _SETJMP_H
-#pragma ident "%Z%%M% %I% %E% SMI" /* SVr4.0 1.9.2.9 */
-
#include <iso/setjmp_iso.h>
/*
@@ -60,7 +58,7 @@ typedef long sigjmp_buf[_SIGJBLEN];
typedef int sigjmp_buf[_SIGJBLEN];
#endif
-extern int sigsetjmp(sigjmp_buf, int);
+extern int sigsetjmp(sigjmp_buf, int) __RETURNS_TWICE;
#pragma unknown_control_flow(sigsetjmp)
extern void siglongjmp(sigjmp_buf, int) __NORETURN;
#endif
@@ -73,7 +71,7 @@ typedef long sigjmp_buf[_SIGJBLEN];
typedef int sigjmp_buf[_SIGJBLEN];
#endif
-extern int sigsetjmp();
+extern int sigsetjmp() __RETURNS_TWICE;
#pragma unknown_control_flow(sigsetjmp)
extern void siglongjmp();
diff --git a/usr/src/head/ucontext.h b/usr/src/head/ucontext.h
index b76062b77b..1c291a5ce0 100644
--- a/usr/src/head/ucontext.h
+++ b/usr/src/head/ucontext.h
@@ -30,8 +30,6 @@
#ifndef _UCONTEXT_H
#define _UCONTEXT_H
-#pragma ident "%Z%%M% %I% %E% SMI"
-
#include <sys/ucontext.h>
#if !defined(_XPG4_2) || defined(__EXTENSIONS__)
@@ -52,7 +50,7 @@ extern "C" {
#if defined(__STDC__)
-extern int getcontext(ucontext_t *);
+extern int getcontext(ucontext_t *) __RETURNS_TWICE;
#pragma unknown_control_flow(getcontext)
extern int setcontext(const ucontext_t *) __NORETURN;
extern int swapcontext(ucontext_t *_RESTRICT_KYWD,
@@ -75,7 +73,7 @@ extern void *_stack_grow(void *);
#endif
#else
-extern int getcontext();
+extern int getcontext() __RETURNS_TWICE;
#pragma unknown_control_flow(getcontext)
extern int setcontext();
extern int swapcontext();
diff --git a/usr/src/head/unistd.h b/usr/src/head/unistd.h
index 2ea8c42c15..75078dd318 100644
--- a/usr/src/head/unistd.h
+++ b/usr/src/head/unistd.h
@@ -536,7 +536,7 @@ extern int unlink(const char *);
extern int usleep(useconds_t);
#endif /* !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2)... */
#if !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2) || defined(__EXTENSIONS__)
-extern pid_t vfork(void);
+extern pid_t vfork(void) __RETURNS_TWICE;
#endif /* !defined(__XOPEN_OR_POSIX) || defined(_XPG4_2)... */
#if !defined(__XOPEN_OR_POSIX) || defined(__EXTENSIONS__)
extern void vhangup(void);
diff --git a/usr/src/lib/Makefile b/usr/src/lib/Makefile
index 5b2de48852..d3d33fa287 100644
--- a/usr/src/lib/Makefile
+++ b/usr/src/lib/Makefile
@@ -22,6 +22,7 @@
# Copyright 2011 Nexenta Systems, Inc. All rights reserved.
# Copyright (c) 1989, 2010, Oracle and/or its affiliates. All rights reserved.
# Copyright (c) 2012, Joyent, Inc. All rights reserved.
+# Copyright (c) 2012 by Delphix. All rights reserved.
include ../Makefile.master
@@ -128,7 +129,6 @@ SUBDIRS += \
libumem \
libnvpair .WAIT \
libexacct \
- libldap4 \
libsasl \
libldap5 \
libsldap .WAIT \
@@ -238,8 +238,10 @@ SUBDIRS += \
sasl_plugins \
udapl \
libzpool \
+ libzfs_core \
libzfs \
- libbe \
+ libbe \
+ pylibbe \
libzfs_jni \
libmapid \
brand \
@@ -472,6 +474,7 @@ HDRSUBDIRS= \
libwrap \
libxcurses2 \
libzfs \
+ libzfs_core \
libzfs_jni \
libzoneinfo \
libzonestat \
@@ -635,7 +638,8 @@ librestart: libuutil libscf
../cmd/sgs/libelf: ../cmd/sgs/libconv
udapl/udapl_tavor: udapl/libdat
libzfs: libdevid libgen libnvpair libuutil \
- libadm libavl libefi libidmap libmd
+ libadm libavl libefi libidmap libmd libzfs_core
+libzfs_core: libnvpair
libzfs_jni: libdiskmgt libnvpair libzfs
libzpool: libavl libumem libnvpair libcmdutils
libsec: libavl libidmap
diff --git a/usr/src/lib/fm/topo/modules/common/ses/ses.c b/usr/src/lib/fm/topo/modules/common/ses/ses.c
index 81171621a3..d8d7b5e24b 100644
--- a/usr/src/lib/fm/topo/modules/common/ses/ses.c
+++ b/usr/src/lib/fm/topo/modules/common/ses/ses.c
@@ -545,19 +545,19 @@ ses_contract_thread(void *arg)
/* if this is the negend, then abandon the contract */
ses_ct_print("got contract negend");
if (stp->set_ctid) {
- snprintf(buf, sizeof (buf),
+ (void) snprintf(buf, sizeof (buf),
"abandon old contract %d", stp->set_ctid);
ses_ct_print(buf);
stp->set_ctid = NULL;
}
(void) ct_ctl_abandon(ctlfd);
}
- close(ctlfd);
+ (void) close(ctlfd);
(void) pthread_mutex_unlock(&stp->set_lock);
ct_event_free(ev);
(void) pthread_mutex_unlock(&ses_sslmt);
}
- close(efd);
+ (void) close(efd);
return (NULL);
}
@@ -692,7 +692,7 @@ ses_create_contract(topo_mod_t *mod, ses_enum_target_t *stp)
topo_mod_dprintf(mod, "failed to create ctid rval = %d", rval);
else
topo_mod_dprintf(mod, "created ctid=%d", stp->set_ctid);
- close(tfd);
+ (void) close(tfd);
}
static void
@@ -715,8 +715,8 @@ ses_target_free(topo_mod_t *mod, ses_enum_target_t *stp)
(void) snprintf(path, PATH_MAX,
CTFS_ROOT "/device/%ld/ctl", stp->set_ctid);
ctlfd = open64(path, O_WRONLY);
- ct_ctl_abandon(ctlfd);
- close(ctlfd);
+ (void) ct_ctl_abandon(ctlfd);
+ (void) close(ctlfd);
stp->set_ctid = NULL;
}
(void) pthread_mutex_unlock(&stp->set_lock);
diff --git a/usr/src/lib/fm/topo/modules/i86pc/chip/chip_amd.c b/usr/src/lib/fm/topo/modules/i86pc/chip/chip_amd.c
index d9b35b52ff..23052a2356 100644
--- a/usr/src/lib/fm/topo/modules/i86pc/chip/chip_amd.c
+++ b/usr/src/lib/fm/topo/modules/i86pc/chip/chip_amd.c
@@ -144,11 +144,11 @@ amd_generic_mc_create(topo_mod_t *mod, uint16_t smbid, tnode_t *cnode,
/*
* Elsewhere we have already returned for families less than 0xf.
* This "generic" topology is adequate for all of family 0xf and
- * for revisions A to D of family 0x10 (for the list of models
+ * for revisions A to E of family 0x10 (for the list of models
* in each revision, refer to usr/src/uts/i86pc/os/cpuid_subr.c).
- * We cover all family 0x10 models, till model 9.
+ * We cover all family 0x10 models, till model 10.
*/
- if (family > 0x10 || (family == 0x10 && model > 9))
+ if (family > 0x10 || (family == 0x10 && model > 10))
return (1);
if (topo_node_range_create(mod, mcnode, CHAN_NODE_NAME, 0,
diff --git a/usr/src/lib/hal/libhal/common/libhal.c b/usr/src/lib/hal/libhal/common/libhal.c
index 4dd771559e..fa8765ef49 100644
--- a/usr/src/lib/hal/libhal/common/libhal.c
+++ b/usr/src/lib/hal/libhal/common/libhal.c
@@ -73,6 +73,30 @@
} \
} while(0)
+/**
+ * LIBHAL_CHECK_UDI_VALID:
+ * @_udi_: the UID to check for
+ * @_ret_: what to use for return value if udi is invalid
+ *
+ * Handy macro for checking whether a UID is valid and not NULL.
+ */
+#define LIBHAL_CHECK_UDI_VALID(_udi_,_ret_) \
+ do { \
+ if (_udi_ == NULL) { \
+ fprintf (stderr, \
+ "%s %d : invalid udi %s. udi is NULL.\n", \
+ __FILE__, __LINE__, _udi_); \
+ return _ret_; \
+ } else { \
+ if(strncmp(_udi_, "/org/freedesktop/Hal/devices/", 29) != 0) { \
+ fprintf (stderr, \
+ "%s %d : invalid udi: %s doesn't start" \
+ "with '/org/freedesktop/Hal/devices/'. \n", \
+ __FILE__, __LINE__, _udi_); \
+ return _ret_; \
+ } \
+ } \
+ } while(0)
static char **libhal_get_string_array_from_iter (DBusMessageIter *iter, int *num_elements);
@@ -115,6 +139,7 @@ libhal_get_string_array_from_iter (DBusMessageIter *iter, int *num_elements)
{
int count;
char **buffer;
+ char **t;
count = 0;
buffer = (char **)malloc (sizeof (char *) * 8);
@@ -128,9 +153,11 @@ libhal_get_string_array_from_iter (DBusMessageIter *iter, int *num_elements)
char *str;
if ((count % 8) == 0 && count != 0) {
- buffer = realloc (buffer, sizeof (char *) * (count + 8));
- if (buffer == NULL)
+ t = realloc (buffer, sizeof (char *) * (count + 8));
+ if (t == NULL)
goto oom;
+ else
+ buffer = t;
}
dbus_message_iter_get_basic (iter, &value);
@@ -145,9 +172,11 @@ libhal_get_string_array_from_iter (DBusMessageIter *iter, int *num_elements)
}
if ((count % 8) == 0) {
- buffer = realloc (buffer, sizeof (char *) * (count + 1));
- if (buffer == NULL)
+ t = realloc (buffer, sizeof (char *) * (count + 1));
+ if (t == NULL)
goto oom;
+ else
+ buffer = t;
}
buffer[count] = NULL;
@@ -156,6 +185,8 @@ libhal_get_string_array_from_iter (DBusMessageIter *iter, int *num_elements)
return buffer;
oom:
+ if (buffer != NULL)
+ free (buffer);
fprintf (stderr, "%s %d : error allocating memory\n", __FILE__, __LINE__);
return NULL;
@@ -196,8 +227,8 @@ struct LibHalPropertySet_s {
* Represents a property. Opaque.
*/
struct LibHalProperty_s {
- int type; /**< Type of property */
- char *key; /**< ASCII string */
+ LibHalPropertyType type; /**< Type of property */
+ char *key; /**< ASCII string */
/** Possible values of the property */
union {
@@ -297,6 +328,10 @@ static dbus_bool_t
libhal_property_fill_value_from_variant (LibHalProperty *p, DBusMessageIter *var_iter)
{
DBusMessageIter iter_array;
+
+ LIBHAL_CHECK_PARAM_VALID(p, "LibHalProperty *p", FALSE);
+ LIBHAL_CHECK_PARAM_VALID(var_iter, "DBusMessageIter *var_iter", FALSE);
+
switch (p->type) {
case DBUS_TYPE_ARRAY:
if (dbus_message_iter_get_element_type (var_iter) != DBUS_TYPE_STRING)
@@ -395,6 +430,7 @@ libhal_device_get_all_properties (LibHalContext *ctx, const char *udi, DBusError
DBusError _error;
LIBHAL_CHECK_LIBHALCONTEXT(ctx, NULL);
+ LIBHAL_CHECK_UDI_VALID(udi, NULL);
message = dbus_message_new_method_call ("org.freedesktop.Hal", udi,
"org.freedesktop.Hal.Device",
@@ -555,8 +591,7 @@ libhal_property_set_get_num_elems (LibHalPropertySet *set)
unsigned int num_elems;
LibHalProperty *p;
- if (set == NULL)
- return 0;
+ LIBHAL_CHECK_PARAM_VALID(set, "*set", 0);
num_elems = 0;
for (p = set->properties_head; p != NULL; p = p->next)
@@ -923,7 +958,12 @@ filter_func (DBusConnection * connection,
object_path = dbus_message_get_path (message);
- /*printf("*** in filter_func, object_path=%s\n", object_path);*/
+ /*fprintf (stderr, "*** libhal filer_func: connection=%p obj_path=%s interface=%s method=%s\n",
+ connection,
+ dbus_message_get_path (message),
+ dbus_message_get_interface (message),
+ dbus_message_get_member (message));
+ */
if (dbus_message_is_signal (message, "org.freedesktop.Hal.Manager",
"DeviceAdded")) {
@@ -1106,10 +1146,12 @@ libhal_device_get_property_type (LibHalContext *ctx, const char *udi, const char
DBusMessage *message;
DBusMessage *reply;
DBusMessageIter iter, reply_iter;
- int type;
+ LibHalPropertyType type;
DBusError _error;
LIBHAL_CHECK_LIBHALCONTEXT(ctx, LIBHAL_PROPERTY_TYPE_INVALID); /* or return NULL? */
+ LIBHAL_CHECK_UDI_VALID(udi, LIBHAL_PROPERTY_TYPE_INVALID);
+ LIBHAL_CHECK_PARAM_VALID(key, "*key", LIBHAL_PROPERTY_TYPE_INVALID);
message = dbus_message_new_method_call ("org.freedesktop.Hal", udi,
"org.freedesktop.Hal.Device",
@@ -1168,6 +1210,8 @@ libhal_device_get_property_strlist (LibHalContext *ctx, const char *udi, const c
DBusError _error;
LIBHAL_CHECK_LIBHALCONTEXT(ctx, NULL);
+ LIBHAL_CHECK_UDI_VALID(udi, NULL);
+ LIBHAL_CHECK_PARAM_VALID(key, "*key", NULL);
message = dbus_message_new_method_call ("org.freedesktop.Hal", udi,
"org.freedesktop.Hal.Device",
@@ -1238,6 +1282,8 @@ libhal_device_get_property_string (LibHalContext *ctx,
DBusError _error;
LIBHAL_CHECK_LIBHALCONTEXT(ctx, NULL);
+ LIBHAL_CHECK_UDI_VALID(udi, NULL);
+ LIBHAL_CHECK_PARAM_VALID(key, "*key", NULL);
message = dbus_message_new_method_call ("org.freedesktop.Hal", udi,
"org.freedesktop.Hal.Device",
@@ -1310,6 +1356,8 @@ libhal_device_get_property_int (LibHalContext *ctx,
DBusError _error;
LIBHAL_CHECK_LIBHALCONTEXT(ctx, -1);
+ LIBHAL_CHECK_UDI_VALID(udi, -1);
+ LIBHAL_CHECK_PARAM_VALID(key, "*key", -1);
message = dbus_message_new_method_call ("org.freedesktop.Hal", udi,
"org.freedesktop.Hal.Device",
@@ -1379,6 +1427,8 @@ libhal_device_get_property_uint64 (LibHalContext *ctx,
DBusError _error;
LIBHAL_CHECK_LIBHALCONTEXT(ctx, -1);
+ LIBHAL_CHECK_UDI_VALID(udi, -1);
+ LIBHAL_CHECK_PARAM_VALID(key, "*key", -1);
message = dbus_message_new_method_call ("org.freedesktop.Hal", udi,
"org.freedesktop.Hal.Device",
@@ -1447,6 +1497,8 @@ libhal_device_get_property_double (LibHalContext *ctx,
DBusError _error;
LIBHAL_CHECK_LIBHALCONTEXT(ctx, -1.0);
+ LIBHAL_CHECK_UDI_VALID(udi, -1.0);
+ LIBHAL_CHECK_PARAM_VALID(key, "*key", -1.0);
message = dbus_message_new_method_call ("org.freedesktop.Hal", udi,
"org.freedesktop.Hal.Device",
@@ -1515,6 +1567,8 @@ libhal_device_get_property_bool (LibHalContext *ctx,
DBusError _error;
LIBHAL_CHECK_LIBHALCONTEXT(ctx, FALSE);
+ LIBHAL_CHECK_UDI_VALID(udi, FALSE);
+ LIBHAL_CHECK_PARAM_VALID(key, "*key", FALSE);
message = dbus_message_new_method_call ("org.freedesktop.Hal", udi,
"org.freedesktop.Hal.Device",
@@ -1581,6 +1635,8 @@ libhal_device_set_property_helper (LibHalContext *ctx,
char *method_name = NULL;
LIBHAL_CHECK_LIBHALCONTEXT(ctx, FALSE);
+ LIBHAL_CHECK_UDI_VALID(udi, FALSE);
+ LIBHAL_CHECK_PARAM_VALID(key, "*key", FALSE);
/** @todo sanity check incoming params */
switch (type) {
@@ -1675,6 +1731,11 @@ libhal_device_set_property_string (LibHalContext *ctx,
const char *value,
DBusError *error)
{
+ LIBHAL_CHECK_LIBHALCONTEXT(ctx, FALSE);
+ LIBHAL_CHECK_UDI_VALID(udi, FALSE);
+ LIBHAL_CHECK_PARAM_VALID(key, "*key", FALSE);
+ LIBHAL_CHECK_PARAM_VALID(value, "*value", FALSE);
+
return libhal_device_set_property_helper (ctx, udi, key,
DBUS_TYPE_STRING,
value, 0, 0, 0.0f, FALSE, error);
@@ -1697,6 +1758,10 @@ dbus_bool_t
libhal_device_set_property_int (LibHalContext *ctx, const char *udi,
const char *key, dbus_int32_t value, DBusError *error)
{
+ LIBHAL_CHECK_LIBHALCONTEXT(ctx, FALSE);
+ LIBHAL_CHECK_UDI_VALID(udi, FALSE);
+ LIBHAL_CHECK_PARAM_VALID(key, "*key", FALSE);
+
return libhal_device_set_property_helper (ctx, udi, key,
DBUS_TYPE_INT32,
NULL, value, 0, 0.0f, FALSE, error);
@@ -1719,6 +1784,10 @@ dbus_bool_t
libhal_device_set_property_uint64 (LibHalContext *ctx, const char *udi,
const char *key, dbus_uint64_t value, DBusError *error)
{
+ LIBHAL_CHECK_LIBHALCONTEXT(ctx, FALSE);
+ LIBHAL_CHECK_UDI_VALID(udi, FALSE);
+ LIBHAL_CHECK_PARAM_VALID(key, "*key", FALSE);
+
return libhal_device_set_property_helper (ctx, udi, key,
DBUS_TYPE_UINT64,
NULL, 0, value, 0.0f, FALSE, error);
@@ -1741,6 +1810,10 @@ dbus_bool_t
libhal_device_set_property_double (LibHalContext *ctx, const char *udi,
const char *key, double value, DBusError *error)
{
+ LIBHAL_CHECK_LIBHALCONTEXT(ctx, FALSE);
+ LIBHAL_CHECK_UDI_VALID(udi, FALSE);
+ LIBHAL_CHECK_PARAM_VALID(key, "*key", FALSE);
+
return libhal_device_set_property_helper (ctx, udi, key,
DBUS_TYPE_DOUBLE,
NULL, 0, 0, value, FALSE, error);
@@ -1763,6 +1836,10 @@ dbus_bool_t
libhal_device_set_property_bool (LibHalContext *ctx, const char *udi,
const char *key, dbus_bool_t value, DBusError *error)
{
+ LIBHAL_CHECK_LIBHALCONTEXT(ctx, FALSE);
+ LIBHAL_CHECK_UDI_VALID(udi, FALSE);
+ LIBHAL_CHECK_PARAM_VALID(key, "*key", FALSE);
+
return libhal_device_set_property_helper (ctx, udi, key,
DBUS_TYPE_BOOLEAN,
NULL, 0, 0, 0.0f, value, error);
@@ -1785,6 +1862,10 @@ dbus_bool_t
libhal_device_remove_property (LibHalContext *ctx,
const char *udi, const char *key, DBusError *error)
{
+ LIBHAL_CHECK_LIBHALCONTEXT(ctx, FALSE);
+ LIBHAL_CHECK_UDI_VALID(udi, FALSE);
+ LIBHAL_CHECK_PARAM_VALID(key, "*key", FALSE);
+
return libhal_device_set_property_helper (ctx, udi, key, DBUS_TYPE_INVALID,
/* DBUS_TYPE_INVALID means remove */
NULL, 0, 0, 0.0f, FALSE, error);
@@ -1815,6 +1896,9 @@ libhal_device_property_strlist_append (LibHalContext *ctx,
DBusMessageIter iter;
LIBHAL_CHECK_LIBHALCONTEXT(ctx, FALSE);
+ LIBHAL_CHECK_UDI_VALID(udi, FALSE);
+ LIBHAL_CHECK_PARAM_VALID(key, "*key", FALSE);
+ LIBHAL_CHECK_PARAM_VALID(value, "*value", FALSE);
message = dbus_message_new_method_call ("org.freedesktop.Hal", udi,
"org.freedesktop.Hal.Device",
@@ -1871,6 +1955,9 @@ libhal_device_property_strlist_prepend (LibHalContext *ctx,
DBusMessageIter iter;
LIBHAL_CHECK_LIBHALCONTEXT(ctx, FALSE);
+ LIBHAL_CHECK_UDI_VALID(udi, FALSE);
+ LIBHAL_CHECK_PARAM_VALID(key, "*key", FALSE);
+ LIBHAL_CHECK_PARAM_VALID(value, "*value", FALSE);
message = dbus_message_new_method_call ("org.freedesktop.Hal", udi,
"org.freedesktop.Hal.Device",
@@ -1927,6 +2014,8 @@ libhal_device_property_strlist_remove_index (LibHalContext *ctx,
DBusMessageIter iter;
LIBHAL_CHECK_LIBHALCONTEXT(ctx, FALSE);
+ LIBHAL_CHECK_UDI_VALID(udi, FALSE);
+ LIBHAL_CHECK_PARAM_VALID(key, "*key", FALSE);
message = dbus_message_new_method_call ("org.freedesktop.Hal", udi,
"org.freedesktop.Hal.Device",
@@ -1982,6 +2071,9 @@ libhal_device_property_strlist_remove (LibHalContext *ctx,
DBusMessageIter iter;
LIBHAL_CHECK_LIBHALCONTEXT(ctx, FALSE);
+ LIBHAL_CHECK_UDI_VALID(udi, FALSE);
+ LIBHAL_CHECK_PARAM_VALID(key, "*key", FALSE);
+ LIBHAL_CHECK_PARAM_VALID(value, "*value", FALSE);
message = dbus_message_new_method_call ("org.freedesktop.Hal", udi,
"org.freedesktop.Hal.Device",
@@ -2037,6 +2129,7 @@ libhal_device_lock (LibHalContext *ctx,
DBusMessage *reply;
LIBHAL_CHECK_LIBHALCONTEXT(ctx, FALSE);
+ LIBHAL_CHECK_UDI_VALID(udi, FALSE);
if (reason_why_locked != NULL)
*reason_why_locked = NULL;
@@ -2104,6 +2197,7 @@ libhal_device_unlock (LibHalContext *ctx,
DBusMessage *reply;
LIBHAL_CHECK_LIBHALCONTEXT(ctx, FALSE);
+ LIBHAL_CHECK_UDI_VALID(udi, FALSE);
message = dbus_message_new_method_call ("org.freedesktop.Hal",
udi,
@@ -2237,6 +2331,8 @@ libhal_device_commit_to_gdl (LibHalContext *ctx,
DBusMessageIter iter;
LIBHAL_CHECK_LIBHALCONTEXT(ctx, FALSE);
+ LIBHAL_CHECK_UDI_VALID(temp_udi, FALSE);
+ LIBHAL_CHECK_UDI_VALID(udi, FALSE);
message = dbus_message_new_method_call ("org.freedesktop.Hal",
"/org/freedesktop/Hal/Manager",
@@ -2294,6 +2390,7 @@ libhal_remove_device (LibHalContext *ctx, const char *udi, DBusError *error)
DBusMessageIter iter;
LIBHAL_CHECK_LIBHALCONTEXT(ctx, FALSE);
+ LIBHAL_CHECK_UDI_VALID(udi, FALSE);
message = dbus_message_new_method_call ("org.freedesktop.Hal",
"/org/freedesktop/Hal/Manager",
@@ -2347,6 +2444,7 @@ libhal_device_exists (LibHalContext *ctx, const char *udi, DBusError *error)
DBusError _error;
LIBHAL_CHECK_LIBHALCONTEXT(ctx, FALSE);
+ LIBHAL_CHECK_UDI_VALID(udi, FALSE);
message = dbus_message_new_method_call ("org.freedesktop.Hal",
"/org/freedesktop/Hal/Manager",
@@ -2416,6 +2514,8 @@ libhal_device_property_exists (LibHalContext *ctx,
DBusError _error;
LIBHAL_CHECK_LIBHALCONTEXT(ctx, FALSE);
+ LIBHAL_CHECK_UDI_VALID(udi, FALSE);
+ LIBHAL_CHECK_PARAM_VALID(key, "*key", FALSE);
message = dbus_message_new_method_call ("org.freedesktop.Hal", udi,
"org.freedesktop.Hal.Device",
@@ -2481,6 +2581,8 @@ libhal_merge_properties (LibHalContext *ctx,
DBusMessageIter iter;
LIBHAL_CHECK_LIBHALCONTEXT(ctx, FALSE);
+ LIBHAL_CHECK_UDI_VALID(target_udi, FALSE);
+ LIBHAL_CHECK_UDI_VALID(source_udi, FALSE);
message = dbus_message_new_method_call ("org.freedesktop.Hal",
"/org/freedesktop/Hal/Manager",
@@ -2548,6 +2650,9 @@ libhal_device_matches (LibHalContext *ctx,
DBusError _error;
LIBHAL_CHECK_LIBHALCONTEXT(ctx, FALSE);
+ LIBHAL_CHECK_UDI_VALID(udi1, FALSE);
+ LIBHAL_CHECK_UDI_VALID(udi2, FALSE);
+ LIBHAL_CHECK_PARAM_VALID(property_namespace, "*property_namespace", FALSE);
message = dbus_message_new_method_call ("org.freedesktop.Hal",
"/org/freedesktop/Hal/Manager",
@@ -2615,6 +2720,7 @@ libhal_device_print (LibHalContext *ctx, const char *udi, DBusError *error)
LibHalPropertySetIterator i;
LIBHAL_CHECK_LIBHALCONTEXT(ctx, FALSE);
+ LIBHAL_CHECK_UDI_VALID(udi, FALSE);
printf ("device_id = %s\n", udi);
@@ -2702,6 +2808,8 @@ libhal_manager_find_device_string_match (LibHalContext *ctx,
DBusError _error;
LIBHAL_CHECK_LIBHALCONTEXT(ctx, NULL);
+ LIBHAL_CHECK_PARAM_VALID(key, "*key", NULL);
+ LIBHAL_CHECK_PARAM_VALID(value, "*value", NULL);
message = dbus_message_new_method_call ("org.freedesktop.Hal",
"/org/freedesktop/Hal/Manager",
@@ -2769,6 +2877,8 @@ libhal_device_add_capability (LibHalContext *ctx,
DBusMessageIter iter;
LIBHAL_CHECK_LIBHALCONTEXT(ctx, FALSE);
+ LIBHAL_CHECK_UDI_VALID(udi, FALSE);
+ LIBHAL_CHECK_PARAM_VALID(capability, "*capability", FALSE);
message = dbus_message_new_method_call ("org.freedesktop.Hal", udi,
"org.freedesktop.Hal.Device",
@@ -2821,6 +2931,8 @@ libhal_device_query_capability (LibHalContext *ctx, const char *udi, const char
dbus_bool_t ret;
LIBHAL_CHECK_LIBHALCONTEXT(ctx, FALSE);
+ LIBHAL_CHECK_UDI_VALID(udi, FALSE);
+ LIBHAL_CHECK_PARAM_VALID(capability, "*capability", FALSE);
ret = FALSE;
@@ -2860,6 +2972,7 @@ libhal_find_device_by_capability (LibHalContext *ctx,
DBusError _error;
LIBHAL_CHECK_LIBHALCONTEXT(ctx, NULL);
+ LIBHAL_CHECK_PARAM_VALID(capability, "*capability", NULL);
message = dbus_message_new_method_call ("org.freedesktop.Hal",
"/org/freedesktop/Hal/Manager",
@@ -2951,6 +3064,7 @@ libhal_device_add_property_watch (LibHalContext *ctx, const char *udi, DBusError
char buf[512];
LIBHAL_CHECK_LIBHALCONTEXT(ctx, FALSE);
+ LIBHAL_CHECK_UDI_VALID(udi, FALSE);
snprintf (buf, 512,
"type='signal',"
@@ -2981,6 +3095,7 @@ libhal_device_remove_property_watch (LibHalContext *ctx, const char *udi, DBusEr
char buf[512];
LIBHAL_CHECK_LIBHALCONTEXT(ctx, FALSE);
+ LIBHAL_CHECK_UDI_VALID(udi, FALSE);
snprintf (buf, 512,
"type='signal',"
@@ -3387,6 +3502,7 @@ libhal_device_rescan (LibHalContext *ctx, const char *udi, DBusError *error)
dbus_bool_t result;
LIBHAL_CHECK_LIBHALCONTEXT(ctx, FALSE);
+ LIBHAL_CHECK_UDI_VALID(udi, FALSE);
message = dbus_message_new_method_call ("org.freedesktop.Hal", udi,
"org.freedesktop.Hal.Device",
@@ -3443,6 +3559,7 @@ libhal_device_reprobe (LibHalContext *ctx, const char *udi, DBusError *error)
dbus_bool_t result;
LIBHAL_CHECK_LIBHALCONTEXT(ctx, FALSE);
+ LIBHAL_CHECK_UDI_VALID(udi, FALSE);
message = dbus_message_new_method_call ("org.freedesktop.Hal",
udi,
@@ -3507,6 +3624,9 @@ dbus_bool_t libhal_device_emit_condition (LibHalContext *ctx,
dbus_bool_t result;
LIBHAL_CHECK_LIBHALCONTEXT(ctx, FALSE);
+ LIBHAL_CHECK_UDI_VALID(udi, FALSE);
+ LIBHAL_CHECK_PARAM_VALID(condition_name, "*condition_name", FALSE);
+ LIBHAL_CHECK_PARAM_VALID(condition_details, "*condition_details", FALSE);
message = dbus_message_new_method_call ("org.freedesktop.Hal",
udi,
@@ -3563,7 +3683,7 @@ dbus_bool_t libhal_device_emit_condition (LibHalContext *ctx,
/**
* libhal_device_addon_is_ready:
* @ctx: the context for the connection to hald
- * @udi: the Unique Device Id
+ * @udi: the Unique Device Id this addon is handling
* @error: pointer to an initialized dbus error object for returning errors or NULL
*
* HAL addon's must call this method when they are done initializing the device object. The HAL
@@ -3583,6 +3703,7 @@ libhal_device_addon_is_ready (LibHalContext *ctx, const char *udi, DBusError *er
dbus_bool_t result;
LIBHAL_CHECK_LIBHALCONTEXT(ctx, FALSE);
+ LIBHAL_CHECK_UDI_VALID(udi, FALSE);
message = dbus_message_new_method_call ("org.freedesktop.Hal",
udi,
@@ -3649,6 +3770,8 @@ libhal_device_claim_interface (LibHalContext *ctx,
dbus_bool_t result;
LIBHAL_CHECK_LIBHALCONTEXT(ctx, FALSE);
+ LIBHAL_CHECK_UDI_VALID(udi, FALSE);
+ LIBHAL_CHECK_PARAM_VALID(interface_name, "*interface_name", FALSE);
message = dbus_message_new_method_call ("org.freedesktop.Hal",
udi,
@@ -3732,6 +3855,8 @@ libhal_device_new_changeset (const char *udi)
{
LibHalChangeSet *changeset;
+ LIBHAL_CHECK_UDI_VALID(udi, NULL);
+
changeset = calloc (1, sizeof (LibHalChangeSet));
if (changeset == NULL)
goto out;
@@ -3753,6 +3878,9 @@ out:
static void
libhal_changeset_append (LibHalChangeSet *changeset, LibHalChangeSetElement *elem)
{
+ LIBHAL_CHECK_PARAM_VALID(changeset, "*changeset", );
+ LIBHAL_CHECK_PARAM_VALID(elem, "*elem", );
+
if (changeset->head == NULL) {
changeset->head = elem;
changeset->tail = elem;
@@ -3782,6 +3910,10 @@ libhal_changeset_set_property_string (LibHalChangeSet *changeset, const char *ke
{
LibHalChangeSetElement *elem;
+ LIBHAL_CHECK_PARAM_VALID(changeset, "*changeset", FALSE);
+ LIBHAL_CHECK_PARAM_VALID(key, "*key", FALSE);
+ LIBHAL_CHECK_PARAM_VALID(value, "*value", FALSE);
+
elem = calloc (1, sizeof (LibHalChangeSetElement));
if (elem == NULL)
goto out;
@@ -3821,6 +3953,9 @@ libhal_changeset_set_property_int (LibHalChangeSet *changeset, const char *key,
{
LibHalChangeSetElement *elem;
+ LIBHAL_CHECK_PARAM_VALID(changeset, "*changeset", FALSE);
+ LIBHAL_CHECK_PARAM_VALID(key, "*key", FALSE);
+
elem = calloc (1, sizeof (LibHalChangeSetElement));
if (elem == NULL)
goto out;
@@ -3854,6 +3989,9 @@ libhal_changeset_set_property_uint64 (LibHalChangeSet *changeset, const char *ke
{
LibHalChangeSetElement *elem;
+ LIBHAL_CHECK_PARAM_VALID(changeset, "*changeset", FALSE);
+ LIBHAL_CHECK_PARAM_VALID(key, "*key", FALSE);
+
elem = calloc (1, sizeof (LibHalChangeSetElement));
if (elem == NULL)
goto out;
@@ -3887,6 +4025,9 @@ libhal_changeset_set_property_double (LibHalChangeSet *changeset, const char *ke
{
LibHalChangeSetElement *elem;
+ LIBHAL_CHECK_PARAM_VALID(changeset, "*changeset", FALSE);
+ LIBHAL_CHECK_PARAM_VALID(key, "*key", FALSE);
+
elem = calloc (1, sizeof (LibHalChangeSetElement));
if (elem == NULL)
goto out;
@@ -3920,6 +4061,9 @@ libhal_changeset_set_property_bool (LibHalChangeSet *changeset, const char *key,
{
LibHalChangeSetElement *elem;
+ LIBHAL_CHECK_PARAM_VALID(changeset, "*changeset", FALSE);
+ LIBHAL_CHECK_PARAM_VALID(key, "*key", FALSE);
+
elem = calloc (1, sizeof (LibHalChangeSetElement));
if (elem == NULL)
goto out;
@@ -3956,6 +4100,9 @@ libhal_changeset_set_property_strlist (LibHalChangeSet *changeset, const char *k
int len;
int i, j;
+ LIBHAL_CHECK_PARAM_VALID(changeset, "*changeset", FALSE);
+ LIBHAL_CHECK_PARAM_VALID(key, "*key", FALSE);
+
elem = calloc (1, sizeof (LibHalChangeSetElement));
if (elem == NULL)
goto out;
@@ -4026,6 +4173,7 @@ libhal_device_commit_changeset (LibHalContext *ctx, LibHalChangeSet *changeset,
int i;
LIBHAL_CHECK_LIBHALCONTEXT(ctx, FALSE);
+ LIBHAL_CHECK_UDI_VALID(changeset->udi, FALSE);
if (changeset->head == NULL) {
return TRUE;
diff --git a/usr/src/lib/libc/inc/thr_inlines.h b/usr/src/lib/libc/inc/thr_inlines.h
index 7376109aa5..66d811f25b 100644
--- a/usr/src/lib/libc/inc/thr_inlines.h
+++ b/usr/src/lib/libc/inc/thr_inlines.h
@@ -33,6 +33,17 @@
/* inlines for gcc */
+/*
+ * ON-usable GCC 4.x emits register pseudo-ops declaring %g7 as ignored, rather
+ * than scratch, GCC 3 does the reverse. All uses, both ones it generated
+ * (_curthread) and ones it didn't (__curthread) must agree.
+ */
+#if __GNUC__ > 3
+#define SPARC_REG_SPEC "#ignore"
+#else
+#define SPARC_REG_SPEC "#scratch"
+#endif
+
extern __GNU_INLINE ulwp_t *
_curthread(void)
{
@@ -62,17 +73,15 @@ __curthread(void)
#elif defined(__i386)
"movl %%gs:0, %0\n\t"
#elif defined(__sparcv9)
- ".register %%g7, #scratch\n\t"
+ ".register %%g7, " SPARC_REG_SPEC "\n\t"
"ldx [%%g7 + 80], %0\n\t"
#elif defined(__sparc)
- ".register %%g7, #scratch\n\t"
+ ".register %%g7, " SPARC_REG_SPEC "\n\t"
"ld [%%g7 + 80], %0\n\t"
#else
#error "port me"
#endif
- "1:"
- : "=r" (__value)
- : : "cc");
+ : "=r" (__value));
return (__value);
}
diff --git a/usr/src/lib/libc/port/gen/privlib.c b/usr/src/lib/libc/port/gen/privlib.c
index b490434997..9d5bbe88ce 100644
--- a/usr/src/lib/libc/port/gen/privlib.c
+++ b/usr/src/lib/libc/port/gen/privlib.c
@@ -757,7 +757,7 @@ __priv_getbyname(const priv_data_t *d, const char *name)
int
priv_getbyname(const char *name)
{
- WITHPRIVLOCKED(int, -1, __priv_getbyname(GETPRIVDATA(), name));
+ WITHPRIVLOCKED(int, -1, __priv_getbyname(GETPRIVDATA(), name))
}
int
@@ -806,7 +806,7 @@ __priv_getbynum(const priv_data_t *d, int num)
const char *
priv_getbynum(int num)
{
- WITHPRIVLOCKED(const char *, NULL, __priv_getbynum(GETPRIVDATA(), num));
+ WITHPRIVLOCKED(const char *, NULL, __priv_getbynum(GETPRIVDATA(), num))
}
const char *
diff --git a/usr/src/lib/libc/port/mapfile-vers b/usr/src/lib/libc/port/mapfile-vers
index 81199991b7..6715f006b4 100644
--- a/usr/src/lib/libc/port/mapfile-vers
+++ b/usr/src/lib/libc/port/mapfile-vers
@@ -24,8 +24,8 @@
# Copyright 2010 Nexenta Systems, Inc. All rights reserved.
# Use is subject to license terms.
#
-# Copyright (c) 2011 by Delphix. All rights reserved.
# Copyright (c) 2012, Joyent, Inc. All rights reserved.
+# Copyright (c) 2012 by Delphix. All rights reserved.
#
#
@@ -91,6 +91,11 @@ $if _x86 && _ELF64
$add amd64
$endif
+SYMBOL_VERSION ILLUMOS_0.3 { # Illumos additions
+ protected:
+ assfail3;
+} ILLUMOS_0.2;
+
SYMBOL_VERSION ILLUMOS_0.2 { # Illumos additions
protected:
posix_spawn_pipe_np;
diff --git a/usr/src/lib/libc/port/threads/assfail.c b/usr/src/lib/libc/port/threads/assfail.c
index 8a6440abc2..7cf0ea98e6 100644
--- a/usr/src/lib/libc/port/threads/assfail.c
+++ b/usr/src/lib/libc/port/threads/assfail.c
@@ -23,6 +23,9 @@
* Copyright 2010 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
+/*
+ * Copyright (c) 2012 by Delphix. All rights reserved.
+ */
#include "lint.h"
#include "thr_uberdata.h"
@@ -442,3 +445,19 @@ assfail(const char *assertion, const char *filename, int line_num)
{
__assfail(assertion, filename, line_num);
}
+
+void
+assfail3(const char *assertion, uintmax_t lv, const char *op, uintmax_t rv,
+ const char *filename, int line_num)
+{
+ char buf[1000];
+ (void) strcpy(buf, assertion);
+ (void) strcat(buf, " (0x");
+ ultos((uint64_t)lv, 16, buf + strlen(buf));
+ (void) strcat(buf, " ");
+ (void) strcat(buf, op);
+ (void) strcat(buf, " 0x");
+ ultos((uint64_t)rv, 16, buf + strlen(buf));
+ (void) strcat(buf, ")");
+ __assfail(buf, filename, line_num);
+}
diff --git a/usr/src/lib/libc/port/unwind/unwind.c b/usr/src/lib/libc/port/unwind/unwind.c
index 2a7f0ccc0f..e457f8df5c 100644
--- a/usr/src/lib/libc/port/unwind/unwind.c
+++ b/usr/src/lib/libc/port/unwind/unwind.c
@@ -24,8 +24,6 @@
* Use is subject to license terms.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
#include "lint.h"
#include "thr_uberdata.h"
#include <dlfcn.h>
@@ -40,9 +38,13 @@
* _ex_unwind() is provided by libC, but if libC is not loaded we
* need to call a local version of _ex_unwind() which does exactly
* the same thing except for calling C++ destructors.
+ *
+ * Note that neither of these literally "returns twice" as, for eg, setjmp
+ * does, but they induce unusual control flow which the compiler should treat
+ * in the same manner (make all registers dead, etc.).
*/
-extern void _ex_clnup_handler(void *, void (*)(void *));
-extern void _ex_unwind_local(void);
+extern void _ex_clnup_handler(void *, void (*)(void *)) __RETURNS_TWICE;
+extern void _ex_unwind_local(void) __RETURNS_TWICE;
#pragma unknown_control_flow(_ex_clnup_handler)
#pragma unknown_control_flow(_ex_unwind_local)
diff --git a/usr/src/lib/libc/sparc/crt/_rtboot.s b/usr/src/lib/libc/sparc/crt/_rtboot.s
index 7764d40507..3e4a2b72ef 100644
--- a/usr/src/lib/libc/sparc/crt/_rtboot.s
+++ b/usr/src/lib/libc/sparc/crt/_rtboot.s
@@ -74,7 +74,7 @@
.section ".text"
.volatile
.global __rtboot
- .local __rtld
+ .global __rtld
.local s.LDSO, s.ZERO
.local f.PANIC, f.OPENAT, f.MMAP, f.FSTATAT, f.SYSCONFIG
.local f.CLOSE, f.EXIT, f.MUNMAP
diff --git a/usr/src/lib/libc/sparc/crt/_rtld.c b/usr/src/lib/libc/sparc/crt/_rtld.c
index caa2919674..843cfe03a5 100644
--- a/usr/src/lib/libc/sparc/crt/_rtld.c
+++ b/usr/src/lib/libc/sparc/crt/_rtld.c
@@ -79,7 +79,7 @@
* order to maintain the "no bootstrapping" requirement -- it calls only
* local functions, uses no intrinsics, etc.
*/
-static void * __USED
+void *
__rtld(Elf32_Boot *ebp, const char *strings[], int (*funcs[])())
{
int i, p; /* working */
diff --git a/usr/src/lib/libctf/common/ctf_lib.c b/usr/src/lib/libctf/common/ctf_lib.c
index 03eb55b6e6..1c5c3f1d5f 100644
--- a/usr/src/lib/libctf/common/ctf_lib.c
+++ b/usr/src/lib/libctf/common/ctf_lib.c
@@ -24,8 +24,6 @@
* Use is subject to license terms.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
-
#include <sys/types.h>
#include <sys/stat.h>
#include <sys/mman.h>
diff --git a/usr/src/lib/libdtrace/Makefile.com b/usr/src/lib/libdtrace/Makefile.com
index 095659d9ea..48b2001e62 100644
--- a/usr/src/lib/libdtrace/Makefile.com
+++ b/usr/src/lib/libdtrace/Makefile.com
@@ -20,7 +20,7 @@
#
#
# Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
-# Copyright (c) 2011 by Delphix. All rights reserved.
+# Copyright (c) 2012 by Delphix. All rights reserved.
#
LIBRARY = libdtrace.a
@@ -52,6 +52,7 @@ LIBSRCS = \
dt_parser.c \
dt_pcb.c \
dt_pid.c \
+ dt_pq.c \
dt_pragma.c \
dt_print.c \
dt_printf.c \
diff --git a/usr/src/lib/libdtrace/common/dt_aggregate.c b/usr/src/lib/libdtrace/common/dt_aggregate.c
index bb766f71c4..1d78f086db 100644
--- a/usr/src/lib/libdtrace/common/dt_aggregate.c
+++ b/usr/src/lib/libdtrace/common/dt_aggregate.c
@@ -26,6 +26,7 @@
/*
* Copyright (c) 2011, Joyent, Inc. All rights reserved.
+ * Copyright (c) 2012 by Delphix. All rights reserved.
*/
#include <stdlib.h>
@@ -884,33 +885,14 @@ dt_aggregate_valcmp(const void *lhs, const void *rhs)
caddr_t rdata = rh->dtahe_data.dtada_data;
dtrace_recdesc_t *lrec, *rrec;
int64_t *laddr, *raddr;
- int rval, i;
-
- if ((rval = dt_aggregate_hashcmp(lhs, rhs)) != 0)
- return (rval);
-
- if (lagg->dtagd_nrecs > ragg->dtagd_nrecs)
- return (DT_GREATERTHAN);
-
- if (lagg->dtagd_nrecs < ragg->dtagd_nrecs)
- return (DT_LESSTHAN);
+ int rval;
- for (i = 0; i < lagg->dtagd_nrecs; i++) {
- lrec = &lagg->dtagd_rec[i];
- rrec = &ragg->dtagd_rec[i];
+ assert(lagg->dtagd_nrecs == ragg->dtagd_nrecs);
- if (lrec->dtrd_offset < rrec->dtrd_offset)
- return (DT_LESSTHAN);
-
- if (lrec->dtrd_offset > rrec->dtrd_offset)
- return (DT_GREATERTHAN);
+ lrec = &lagg->dtagd_rec[lagg->dtagd_nrecs - 1];
+ rrec = &ragg->dtagd_rec[ragg->dtagd_nrecs - 1];
- if (lrec->dtrd_action < rrec->dtrd_action)
- return (DT_LESSTHAN);
-
- if (lrec->dtrd_action > rrec->dtrd_action)
- return (DT_GREATERTHAN);
- }
+ assert(lrec->dtrd_action == rrec->dtrd_action);
laddr = (int64_t *)(uintptr_t)(ldata + lrec->dtrd_offset);
raddr = (int64_t *)(uintptr_t)(rdata + rrec->dtrd_offset);
diff --git a/usr/src/lib/libdtrace/common/dt_cc.c b/usr/src/lib/libdtrace/common/dt_cc.c
index 8b98b6d6f8..88e22274e3 100644
--- a/usr/src/lib/libdtrace/common/dt_cc.c
+++ b/usr/src/lib/libdtrace/common/dt_cc.c
@@ -22,7 +22,7 @@
/*
* Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, Joyent Inc. All rights reserved.
- * Copyright (c) 2011 by Delphix. All rights reserved.
+ * Copyright (c) 2012 by Delphix. All rights reserved.
*/
/*
@@ -663,63 +663,48 @@ static void
dt_action_trace(dtrace_hdl_t *dtp, dt_node_t *dnp, dtrace_stmtdesc_t *sdp)
{
dtrace_actdesc_t *ap = dt_stmt_action(dtp, sdp);
+ boolean_t istrace = (dnp->dn_ident->di_id == DT_ACT_TRACE);
+ const char *act = istrace ? "trace" : "print";
if (dt_node_is_void(dnp->dn_args)) {
- dnerror(dnp->dn_args, D_TRACE_VOID,
- "trace( ) may not be applied to a void expression\n");
+ dnerror(dnp->dn_args, istrace ? D_TRACE_VOID : D_PRINT_VOID,
+ "%s( ) may not be applied to a void expression\n", act);
}
- if (dt_node_is_dynamic(dnp->dn_args)) {
- dnerror(dnp->dn_args, D_TRACE_DYN,
- "trace( ) may not be applied to a dynamic expression\n");
+ if (dt_node_resolve(dnp->dn_args, DT_IDENT_XLPTR) != NULL) {
+ dnerror(dnp->dn_args, istrace ? D_TRACE_DYN : D_PRINT_DYN,
+ "%s( ) may not be applied to a translated pointer\n", act);
}
dt_cg(yypcb, dnp->dn_args);
- ap->dtad_difo = dt_as(yypcb);
- ap->dtad_kind = DTRACEACT_DIFEXPR;
-}
-/*
- * The print() action behaves identically to trace(), except that it stores the
- * CTF type of the argument (if present) within the DOF for the DIFEXPR action.
- * To do this, we set the 'dtsd_strdata' to point to the fully-qualified CTF
- * type ID for the result of the DIF action. We use the ID instead of the name
- * to handles complex types like arrays and function pointers that can't be
- * resolved by ctf_type_lookup(). This is later processed by
- * dtrace_dof_create() and turned into a reference into the string table so
- * that we can get the type information when we process the data after the
- * fact.
- */
-static void
-dt_action_print(dtrace_hdl_t *dtp, dt_node_t *dnp, dtrace_stmtdesc_t *sdp)
-{
- dtrace_actdesc_t *ap = dt_stmt_action(dtp, sdp);
- dt_node_t *dret;
- size_t len;
- dt_module_t *dmp;
+ /*
+ * The print() action behaves identically to trace(), except that it
+ * stores the CTF type of the argument (if present) within the DOF for
+ * the DIFEXPR action. To do this, we set the 'dtsd_strdata' to point
+ * to the fully-qualified CTF type ID for the result of the DIF
+ * action. We use the ID instead of the name to handles complex types
+ * like arrays and function pointers that can't be resolved by
+ * ctf_type_lookup(). This is later processed by dtrace_dof_create()
+ * and turned into a reference into the string table so that we can
+ * get the type information when we process the data after the fact.
+ */
+ if (dnp->dn_ident->di_id == DT_ACT_PRINT) {
+ dt_node_t *dret;
+ size_t n;
+ dt_module_t *dmp;
- if (dt_node_is_void(dnp->dn_args)) {
- dnerror(dnp->dn_args, D_PRINT_VOID,
- "print( ) may not be applied to a void expression\n");
- }
+ dret = yypcb->pcb_dret;
+ dmp = dt_module_lookup_by_ctf(dtp, dret->dn_ctfp);
- if (dt_node_is_dynamic(dnp->dn_args)) {
- dnerror(dnp->dn_args, D_PRINT_DYN,
- "print( ) may not be applied to a dynamic expression\n");
+ n = snprintf(NULL, 0, "%s`%d", dmp->dm_name, dret->dn_type) + 1;
+ sdp->dtsd_strdata = dt_alloc(dtp, n);
+ if (sdp->dtsd_strdata == NULL)
+ longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM);
+ (void) snprintf(sdp->dtsd_strdata, n, "%s`%d", dmp->dm_name,
+ dret->dn_type);
}
- dt_cg(yypcb, dnp->dn_args);
-
- dret = yypcb->pcb_dret;
- dmp = dt_module_lookup_by_ctf(dtp, dret->dn_ctfp);
-
- len = snprintf(NULL, 0, "%s`%d", dmp->dm_name, dret->dn_type) + 1;
- sdp->dtsd_strdata = dt_alloc(dtp, len);
- if (sdp->dtsd_strdata == NULL)
- longjmp(yypcb->pcb_jmpbuf, EDT_NOMEM);
- (void) snprintf(sdp->dtsd_strdata, len, "%s`%d", dmp->dm_name,
- dret->dn_type);
-
ap->dtad_difo = dt_as(yypcb);
ap->dtad_kind = DTRACEACT_DIFEXPR;
}
@@ -1073,6 +1058,9 @@ dt_compile_fun(dtrace_hdl_t *dtp, dt_node_t *dnp, dtrace_stmtdesc_t *sdp)
case DT_ACT_PANIC:
dt_action_panic(dtp, dnp->dn_expr, sdp);
break;
+ case DT_ACT_PRINT:
+ dt_action_trace(dtp, dnp->dn_expr, sdp);
+ break;
case DT_ACT_PRINTA:
dt_action_printa(dtp, dnp->dn_expr, sdp);
break;
@@ -1103,9 +1091,6 @@ dt_compile_fun(dtrace_hdl_t *dtp, dt_node_t *dnp, dtrace_stmtdesc_t *sdp)
case DT_ACT_TRACE:
dt_action_trace(dtp, dnp->dn_expr, sdp);
break;
- case DT_ACT_PRINT:
- dt_action_print(dtp, dnp->dn_expr, sdp);
- break;
case DT_ACT_TRACEMEM:
dt_action_tracemem(dtp, dnp->dn_expr, sdp);
break;
@@ -2467,7 +2452,8 @@ dt_compile(dtrace_hdl_t *dtp, int context, dtrace_probespec_t pspec, void *arg,
}
out:
- if (context != DT_CTX_DTYPE && DT_TREEDUMP_PASS(dtp, 3))
+ if (context != DT_CTX_DTYPE && yypcb->pcb_root != NULL &&
+ DT_TREEDUMP_PASS(dtp, 3))
dt_node_printr(yypcb->pcb_root, stderr, 0);
if (dtp->dt_cdefs_fd != -1 && (ftruncate64(dtp->dt_cdefs_fd, 0) == -1 ||
diff --git a/usr/src/lib/libdtrace/common/dt_cg.c b/usr/src/lib/libdtrace/common/dt_cg.c
index 4557c6f85c..3103106d27 100644
--- a/usr/src/lib/libdtrace/common/dt_cg.c
+++ b/usr/src/lib/libdtrace/common/dt_cg.c
@@ -19,12 +19,15 @@
*
* CDDL HEADER END
*/
+
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
+/*
+ * Copyright (c) 2012 by Delphix. All rights reserved.
+ */
#include <sys/types.h>
#include <sys/sysmacros.h>
@@ -193,9 +196,6 @@ dt_cg_ptrsize(dt_node_t *dnp, dt_irlist_t *dlp, dt_regset_t *drp,
ssize_t size;
int sreg;
- if ((sreg = dt_regset_alloc(drp)) == -1)
- longjmp(yypcb->pcb_jmpbuf, EDT_NOREG);
-
type = ctf_type_resolve(ctfp, dnp->dn_type);
kind = ctf_type_kind(ctfp, type);
assert(kind == CTF_K_POINTER || kind == CTF_K_ARRAY);
@@ -212,6 +212,7 @@ dt_cg_ptrsize(dt_node_t *dnp, dt_irlist_t *dlp, dt_regset_t *drp,
if ((size = ctf_type_size(ctfp, type)) == 1)
return; /* multiply or divide by one can be omitted */
+ sreg = dt_regset_alloc(drp);
dt_cg_setx(dlp, sreg, size);
instr = DIF_INSTR_FMT(op, dreg, sreg, dreg);
dt_irlist_append(dlp, dt_cg_node_alloc(DT_LBL_NONE, instr));
@@ -251,9 +252,7 @@ dt_cg_field_get(dt_node_t *dnp, dt_irlist_t *dlp, dt_regset_t *drp,
assert(dnp->dn_op == DT_TOK_PTR || dnp->dn_op == DT_TOK_DOT);
r1 = dnp->dn_left->dn_reg;
-
- if ((r2 = dt_regset_alloc(drp)) == -1)
- longjmp(yypcb->pcb_jmpbuf, EDT_NOREG);
+ r2 = dt_regset_alloc(drp);
/*
* On little-endian architectures, ctm_offset counts from the right so
@@ -356,10 +355,9 @@ dt_cg_field_set(dt_node_t *src, dt_irlist_t *dlp,
"bits %u\n", m.ctm_offset, m.ctm_type, e.cte_bits);
}
- if ((r1 = dt_regset_alloc(drp)) == -1 ||
- (r2 = dt_regset_alloc(drp)) == -1 ||
- (r3 = dt_regset_alloc(drp)) == -1)
- longjmp(yypcb->pcb_jmpbuf, EDT_NOREG);
+ r1 = dt_regset_alloc(drp);
+ r2 = dt_regset_alloc(drp);
+ r3 = dt_regset_alloc(drp);
/*
* Compute shifts and masks. We need to compute "shift" as the amount
@@ -423,8 +421,7 @@ dt_cg_store(dt_node_t *src, dt_irlist_t *dlp, dt_regset_t *drp, dt_node_t *dst)
size = dt_node_type_size(src);
if (src->dn_flags & DT_NF_REF) {
- if ((reg = dt_regset_alloc(drp)) == -1)
- longjmp(yypcb->pcb_jmpbuf, EDT_NOREG);
+ reg = dt_regset_alloc(drp);
dt_cg_setx(dlp, reg, size);
instr = DIF_INSTR_COPYS(src->dn_reg, reg, dst->dn_reg);
dt_irlist_append(dlp, dt_cg_node_alloc(DT_LBL_NONE, instr));
@@ -474,30 +471,58 @@ dt_cg_typecast(const dt_node_t *src, const dt_node_t *dst,
size_t dstsize = dt_node_type_size(dst);
dif_instr_t instr;
- int reg, n;
+ int rg;
- if (dt_node_is_scalar(dst) && (dstsize < srcsize ||
- (src->dn_flags & DT_NF_SIGNED) ^ (dst->dn_flags & DT_NF_SIGNED))) {
- if ((reg = dt_regset_alloc(drp)) == -1)
- longjmp(yypcb->pcb_jmpbuf, EDT_NOREG);
+ if (!dt_node_is_scalar(dst))
+ return; /* not a scalar */
+ if (dstsize == srcsize &&
+ ((src->dn_flags ^ dst->dn_flags) & DT_NF_SIGNED) != 0)
+ return; /* not narrowing or changing signed-ness */
+ if (dstsize > srcsize && (src->dn_flags & DT_NF_SIGNED) == 0)
+ return; /* nothing to do in this case */
- if (dstsize < srcsize)
- n = sizeof (uint64_t) * NBBY - dstsize * NBBY;
- else
- n = sizeof (uint64_t) * NBBY - srcsize * NBBY;
+ rg = dt_regset_alloc(drp);
+
+ if (dstsize > srcsize) {
+ int n = sizeof (uint64_t) * NBBY - srcsize * NBBY;
+ int s = (dstsize - srcsize) * NBBY;
- dt_cg_setx(dlp, reg, n);
+ dt_cg_setx(dlp, rg, n);
- instr = DIF_INSTR_FMT(DIF_OP_SLL,
- src->dn_reg, reg, dst->dn_reg);
+ instr = DIF_INSTR_FMT(DIF_OP_SLL, src->dn_reg, rg, dst->dn_reg);
dt_irlist_append(dlp, dt_cg_node_alloc(DT_LBL_NONE, instr));
- instr = DIF_INSTR_FMT((dst->dn_flags & DT_NF_SIGNED) ?
- DIF_OP_SRA : DIF_OP_SRL, dst->dn_reg, reg, dst->dn_reg);
+ if ((dst->dn_flags & DT_NF_SIGNED) || n == s) {
+ instr = DIF_INSTR_FMT(DIF_OP_SRA,
+ dst->dn_reg, rg, dst->dn_reg);
+ dt_irlist_append(dlp,
+ dt_cg_node_alloc(DT_LBL_NONE, instr));
+ } else {
+ dt_cg_setx(dlp, rg, s);
+ instr = DIF_INSTR_FMT(DIF_OP_SRA,
+ dst->dn_reg, rg, dst->dn_reg);
+ dt_irlist_append(dlp,
+ dt_cg_node_alloc(DT_LBL_NONE, instr));
+ dt_cg_setx(dlp, rg, n - s);
+ instr = DIF_INSTR_FMT(DIF_OP_SRL,
+ dst->dn_reg, rg, dst->dn_reg);
+ dt_irlist_append(dlp,
+ dt_cg_node_alloc(DT_LBL_NONE, instr));
+ }
+ } else if (dstsize != sizeof (uint64_t)) {
+ int n = sizeof (uint64_t) * NBBY - dstsize * NBBY;
+
+ dt_cg_setx(dlp, rg, n);
+ instr = DIF_INSTR_FMT(DIF_OP_SLL, src->dn_reg, rg, dst->dn_reg);
+ dt_irlist_append(dlp, dt_cg_node_alloc(DT_LBL_NONE, instr));
+
+ instr = DIF_INSTR_FMT((dst->dn_flags & DT_NF_SIGNED) ?
+ DIF_OP_SRA : DIF_OP_SRL, dst->dn_reg, rg, dst->dn_reg);
dt_irlist_append(dlp, dt_cg_node_alloc(DT_LBL_NONE, instr));
- dt_regset_free(drp, reg);
}
+
+ dt_regset_free(drp, rg);
}
/*
@@ -523,8 +548,7 @@ dt_cg_arglist(dt_ident_t *idp, dt_node_t *args,
for (dnp = args; dnp != NULL; dnp = dnp->dn_list)
dt_cg_node(dnp, dlp, drp);
- dt_irlist_append(dlp,
- dt_cg_node_alloc(DT_LBL_NONE, DIF_INSTR_FLUSHTS));
+ dt_irlist_append(dlp, dt_cg_node_alloc(DT_LBL_NONE, DIF_INSTR_FLUSHTS));
for (dnp = args; dnp != NULL; dnp = dnp->dn_list, i++) {
dtrace_diftype_t t;
@@ -538,17 +562,18 @@ dt_cg_arglist(dt_ident_t *idp, dt_node_t *args,
dt_cg_typecast(dnp, &isp->dis_args[i], dlp, drp);
isp->dis_args[i].dn_reg = -1;
- if (t.dtdt_flags & DIF_TF_BYREF)
+ if (t.dtdt_flags & DIF_TF_BYREF) {
op = DIF_OP_PUSHTR;
- else
+ if (t.dtdt_size != 0) {
+ reg = dt_regset_alloc(drp);
+ dt_cg_setx(dlp, reg, t.dtdt_size);
+ } else {
+ reg = DIF_REG_R0;
+ }
+ } else {
op = DIF_OP_PUSHTV;
-
- if (t.dtdt_size != 0) {
- if ((reg = dt_regset_alloc(drp)) == -1)
- longjmp(yypcb->pcb_jmpbuf, EDT_NOREG);
- dt_cg_setx(dlp, reg, t.dtdt_size);
- } else
reg = DIF_REG_R0;
+ }
instr = DIF_INSTR_PUSHTS(op, t.dtdt_kind, reg, dnp->dn_reg);
dt_irlist_append(dlp, dt_cg_node_alloc(DT_LBL_NONE, instr));
@@ -629,9 +654,7 @@ dt_cg_prearith_op(dt_node_t *dnp, dt_irlist_t *dlp, dt_regset_t *drp, uint_t op)
dt_cg_node(dnp->dn_child, dlp, drp);
dnp->dn_reg = dnp->dn_child->dn_reg;
- if ((reg = dt_regset_alloc(drp)) == -1)
- longjmp(yypcb->pcb_jmpbuf, EDT_NOREG);
-
+ reg = dt_regset_alloc(drp);
dt_cg_setx(dlp, reg, size);
instr = DIF_INSTR_FMT(op, dnp->dn_reg, reg, dnp->dn_reg);
@@ -688,9 +711,7 @@ dt_cg_postarith_op(dt_node_t *dnp, dt_irlist_t *dlp,
dt_cg_node(dnp->dn_child, dlp, drp);
dnp->dn_reg = dnp->dn_child->dn_reg;
- if ((nreg = dt_regset_alloc(drp)) == -1)
- longjmp(yypcb->pcb_jmpbuf, EDT_NOREG);
-
+ nreg = dt_regset_alloc(drp);
dt_cg_setx(dlp, nreg, size);
instr = DIF_INSTR_FMT(op, dnp->dn_reg, nreg, nreg);
dt_irlist_append(dlp, dt_cg_node_alloc(DT_LBL_NONE, instr));
@@ -1008,9 +1029,7 @@ dt_cg_asgn_op(dt_node_t *dnp, dt_irlist_t *dlp, dt_regset_t *drp)
* set it to the size of our data structure, and then replace
* it with the result of an allocs of the specified size.
*/
- if ((r1 = dt_regset_alloc(drp)) == -1)
- longjmp(yypcb->pcb_jmpbuf, EDT_NOREG);
-
+ r1 = dt_regset_alloc(drp);
dt_cg_setx(dlp, r1,
ctf_type_size(dxp->dx_dst_ctfp, dxp->dx_dst_base));
@@ -1054,8 +1073,7 @@ dt_cg_asgn_op(dt_node_t *dnp, dt_irlist_t *dlp, dt_regset_t *drp)
* and add r1 to it before storing the result.
*/
if (ctm.ctm_offset != 0) {
- if ((r2 = dt_regset_alloc(drp)) == -1)
- longjmp(yypcb->pcb_jmpbuf, EDT_NOREG);
+ r2 = dt_regset_alloc(drp);
/*
* Add the member offset rounded down to the
@@ -1142,8 +1160,7 @@ dt_cg_assoc_op(dt_node_t *dnp, dt_irlist_t *dlp, dt_regset_t *drp)
dt_cg_arglist(dnp->dn_ident, dnp->dn_args, dlp, drp);
- if ((dnp->dn_reg = dt_regset_alloc(drp)) == -1)
- longjmp(yypcb->pcb_jmpbuf, EDT_NOREG);
+ dnp->dn_reg = dt_regset_alloc(drp);
if (dnp->dn_ident->di_flags & DT_IDFLG_TLS)
op = DIF_OP_LDTAA;
@@ -1273,9 +1290,7 @@ dt_cg_array_op(dt_node_t *dnp, dt_irlist_t *dlp, dt_regset_t *drp)
if ((size = dt_node_type_size(dnp)) == sizeof (uint64_t))
return;
- if ((reg = dt_regset_alloc(drp)) == -1)
- longjmp(yypcb->pcb_jmpbuf, EDT_NOREG);
-
+ reg = dt_regset_alloc(drp);
assert(size < sizeof (uint64_t));
n = sizeof (uint64_t) * NBBY - size * NBBY;
@@ -1338,6 +1353,162 @@ dt_cg_inline(dt_node_t *dnp, dt_irlist_t *dlp, dt_regset_t *drp)
}
}
+typedef struct dt_xlmemb {
+ dt_ident_t *dtxl_idp; /* translated ident */
+ dt_irlist_t *dtxl_dlp; /* instruction list */
+ dt_regset_t *dtxl_drp; /* register set */
+ int dtxl_sreg; /* location of the translation input */
+ int dtxl_dreg; /* location of our allocated buffer */
+} dt_xlmemb_t;
+
+/*ARGSUSED*/
+static int
+dt_cg_xlate_member(const char *name, ctf_id_t type, ulong_t off, void *arg)
+{
+ dt_xlmemb_t *dx = arg;
+ dt_ident_t *idp = dx->dtxl_idp;
+ dt_irlist_t *dlp = dx->dtxl_dlp;
+ dt_regset_t *drp = dx->dtxl_drp;
+
+ dt_node_t *mnp;
+ dt_xlator_t *dxp;
+
+ int reg, treg;
+ uint32_t instr;
+ size_t size;
+
+ /* Generate code for the translation. */
+ dxp = idp->di_data;
+ mnp = dt_xlator_member(dxp, name);
+
+ /* If there's no translator for the given member, skip it. */
+ if (mnp == NULL)
+ return (0);
+
+ dxp->dx_ident->di_flags |= DT_IDFLG_CGREG;
+ dxp->dx_ident->di_id = dx->dtxl_sreg;
+
+ dt_cg_node(mnp->dn_membexpr, dlp, drp);
+
+ dxp->dx_ident->di_flags &= ~DT_IDFLG_CGREG;
+ dxp->dx_ident->di_id = 0;
+
+ treg = mnp->dn_membexpr->dn_reg;
+
+ /* Compute the offset into our buffer and store the result there. */
+ reg = dt_regset_alloc(drp);
+
+ dt_cg_setx(dlp, reg, off / NBBY);
+ instr = DIF_INSTR_FMT(DIF_OP_ADD, dx->dtxl_dreg, reg, reg);
+ dt_irlist_append(dlp, dt_cg_node_alloc(DT_LBL_NONE, instr));
+
+ size = ctf_type_size(mnp->dn_membexpr->dn_ctfp,
+ mnp->dn_membexpr->dn_type);
+ if (dt_node_is_scalar(mnp->dn_membexpr)) {
+ /*
+ * Copying scalars is simple.
+ */
+ switch (size) {
+ case 1:
+ instr = DIF_INSTR_STORE(DIF_OP_STB, treg, reg);
+ break;
+ case 2:
+ instr = DIF_INSTR_STORE(DIF_OP_STH, treg, reg);
+ break;
+ case 4:
+ instr = DIF_INSTR_STORE(DIF_OP_STW, treg, reg);
+ break;
+ case 8:
+ instr = DIF_INSTR_STORE(DIF_OP_STX, treg, reg);
+ break;
+ default:
+ xyerror(D_UNKNOWN, "internal error -- unexpected "
+ "size: %lu\n", (ulong_t)size);
+ }
+
+ dt_irlist_append(dlp, dt_cg_node_alloc(DT_LBL_NONE, instr));
+
+ } else if (dt_node_is_string(mnp->dn_membexpr)) {
+ int szreg;
+
+ /*
+ * Use the copys instruction for strings.
+ */
+ szreg = dt_regset_alloc(drp);
+ dt_cg_setx(dlp, szreg, size);
+ instr = DIF_INSTR_COPYS(treg, szreg, reg);
+ dt_irlist_append(dlp, dt_cg_node_alloc(DT_LBL_NONE, instr));
+ dt_regset_free(drp, szreg);
+ } else {
+ int szreg;
+
+ /*
+ * If it's anything else then we'll just bcopy it.
+ */
+ szreg = dt_regset_alloc(drp);
+ dt_cg_setx(dlp, szreg, size);
+ dt_irlist_append(dlp,
+ dt_cg_node_alloc(DT_LBL_NONE, DIF_INSTR_FLUSHTS));
+ instr = DIF_INSTR_PUSHTS(DIF_OP_PUSHTV, DIF_TYPE_CTF,
+ DIF_REG_R0, treg);
+ dt_irlist_append(dlp, dt_cg_node_alloc(DT_LBL_NONE, instr));
+ instr = DIF_INSTR_PUSHTS(DIF_OP_PUSHTV, DIF_TYPE_CTF,
+ DIF_REG_R0, reg);
+ dt_irlist_append(dlp, dt_cg_node_alloc(DT_LBL_NONE, instr));
+ instr = DIF_INSTR_PUSHTS(DIF_OP_PUSHTV, DIF_TYPE_CTF,
+ DIF_REG_R0, szreg);
+ dt_irlist_append(dlp, dt_cg_node_alloc(DT_LBL_NONE, instr));
+ instr = DIF_INSTR_CALL(DIF_SUBR_BCOPY, szreg);
+ dt_irlist_append(dlp, dt_cg_node_alloc(DT_LBL_NONE, instr));
+ dt_regset_free(drp, szreg);
+ }
+
+ dt_regset_free(drp, reg);
+ dt_regset_free(drp, treg);
+
+ return (0);
+}
+
+/*
+ * If we're expanding a translated type, we create an appropriately sized
+ * buffer with alloca() and then translate each member into it.
+ */
+static int
+dt_cg_xlate_expand(dt_node_t *dnp, dt_ident_t *idp, dt_irlist_t *dlp,
+ dt_regset_t *drp)
+{
+ dt_xlmemb_t dlm;
+ uint32_t instr;
+ int dreg;
+ size_t size;
+
+ dreg = dt_regset_alloc(drp);
+ size = ctf_type_size(dnp->dn_ident->di_ctfp, dnp->dn_ident->di_type);
+
+ /* Call alloca() to create the buffer. */
+ dt_cg_setx(dlp, dreg, size);
+
+ dt_irlist_append(dlp, dt_cg_node_alloc(DT_LBL_NONE, DIF_INSTR_FLUSHTS));
+
+ instr = DIF_INSTR_PUSHTS(DIF_OP_PUSHTV, DIF_TYPE_CTF, DIF_REG_R0, dreg);
+ dt_irlist_append(dlp, dt_cg_node_alloc(DT_LBL_NONE, instr));
+
+ instr = DIF_INSTR_CALL(DIF_SUBR_ALLOCA, dreg);
+ dt_irlist_append(dlp, dt_cg_node_alloc(DT_LBL_NONE, instr));
+
+ /* Generate the translation for each member. */
+ dlm.dtxl_idp = idp;
+ dlm.dtxl_dlp = dlp;
+ dlm.dtxl_drp = drp;
+ dlm.dtxl_sreg = dnp->dn_reg;
+ dlm.dtxl_dreg = dreg;
+ (void) ctf_member_iter(dnp->dn_ident->di_ctfp,
+ dnp->dn_ident->di_type, dt_cg_xlate_member,
+ &dlm);
+
+ return (dreg);
+}
+
static void
dt_cg_node(dt_node_t *dnp, dt_irlist_t *dlp, dt_regset_t *drp)
{
@@ -1350,7 +1521,6 @@ dt_cg_node(dt_node_t *dnp, dt_irlist_t *dlp, dt_regset_t *drp)
dt_ident_t *idp;
ssize_t stroff;
uint_t op;
- int reg;
switch (dnp->dn_op) {
case DT_TOK_COMMA:
@@ -1552,7 +1722,16 @@ dt_cg_node(dt_node_t *dnp, dt_irlist_t *dlp, dt_regset_t *drp)
dt_cg_node(dnp->dn_child, dlp, drp);
dnp->dn_reg = dnp->dn_child->dn_reg;
- if (!(dnp->dn_flags & DT_NF_REF)) {
+ if (dt_node_is_dynamic(dnp->dn_child)) {
+ int reg;
+ idp = dt_node_resolve(dnp->dn_child, DT_IDENT_XLPTR);
+ assert(idp != NULL);
+ reg = dt_cg_xlate_expand(dnp, idp, dlp, drp);
+
+ dt_regset_free(drp, dnp->dn_child->dn_reg);
+ dnp->dn_reg = reg;
+
+ } else if (!(dnp->dn_flags & DT_NF_REF)) {
uint_t ubit = dnp->dn_flags & DT_NF_USERLAND;
/*
@@ -1588,10 +1767,7 @@ dt_cg_node(dt_node_t *dnp, dt_irlist_t *dlp, dt_regset_t *drp)
case DT_TOK_SIZEOF: {
size_t size = dt_node_sizeof(dnp->dn_child);
-
- if ((dnp->dn_reg = dt_regset_alloc(drp)) == -1)
- longjmp(yypcb->pcb_jmpbuf, EDT_NOREG);
-
+ dnp->dn_reg = dt_regset_alloc(drp);
assert(size != 0);
dt_cg_setx(dlp, dnp->dn_reg, size);
break;
@@ -1616,8 +1792,7 @@ dt_cg_node(dt_node_t *dnp, dt_irlist_t *dlp, dt_regset_t *drp)
assert(dxp->dx_ident->di_flags & DT_IDFLG_CGREG);
assert(dxp->dx_ident->di_id != 0);
- if ((dnp->dn_reg = dt_regset_alloc(drp)) == -1)
- longjmp(yypcb->pcb_jmpbuf, EDT_NOREG);
+ dnp->dn_reg = dt_regset_alloc(drp);
if (dxp->dx_arg == -1) {
instr = DIF_INSTR_MOV(
@@ -1701,8 +1876,9 @@ dt_cg_node(dt_node_t *dnp, dt_irlist_t *dlp, dt_regset_t *drp)
}
if (m.ctm_offset != 0) {
- if ((reg = dt_regset_alloc(drp)) == -1)
- longjmp(yypcb->pcb_jmpbuf, EDT_NOREG);
+ int reg;
+
+ reg = dt_regset_alloc(drp);
/*
* If the offset is not aligned on a byte boundary, it
@@ -1748,8 +1924,7 @@ dt_cg_node(dt_node_t *dnp, dt_irlist_t *dlp, dt_regset_t *drp)
break;
case DT_TOK_STRING:
- if ((dnp->dn_reg = dt_regset_alloc(drp)) == -1)
- longjmp(yypcb->pcb_jmpbuf, EDT_NOREG);
+ dnp->dn_reg = dt_regset_alloc(drp);
assert(dnp->dn_kind == DT_NODE_STRING);
stroff = dt_strtab_insert(yypcb->pcb_strtab, dnp->dn_string);
@@ -1772,8 +1947,7 @@ dt_cg_node(dt_node_t *dnp, dt_irlist_t *dlp, dt_regset_t *drp)
*/
if (dnp->dn_kind == DT_NODE_VAR &&
(dnp->dn_ident->di_flags & DT_IDFLG_CGREG)) {
- if ((dnp->dn_reg = dt_regset_alloc(drp)) == -1)
- longjmp(yypcb->pcb_jmpbuf, EDT_NOREG);
+ dnp->dn_reg = dt_regset_alloc(drp);
instr = DIF_INSTR_MOV(dnp->dn_ident->di_id,
dnp->dn_reg);
dt_irlist_append(dlp,
@@ -1803,11 +1977,9 @@ dt_cg_node(dt_node_t *dnp, dt_irlist_t *dlp, dt_regset_t *drp)
dt_cg_arglist(dnp->dn_ident, dnp->dn_args, dlp, drp);
- if ((dnp->dn_reg = dt_regset_alloc(drp)) == -1)
- longjmp(yypcb->pcb_jmpbuf, EDT_NOREG);
-
- instr = DIF_INSTR_CALL(
- dnp->dn_ident->di_id, dnp->dn_reg);
+ dnp->dn_reg = dt_regset_alloc(drp);
+ instr = DIF_INSTR_CALL(dnp->dn_ident->di_id,
+ dnp->dn_reg);
dt_irlist_append(dlp,
dt_cg_node_alloc(DT_LBL_NONE, instr));
@@ -1834,8 +2006,7 @@ dt_cg_node(dt_node_t *dnp, dt_irlist_t *dlp, dt_regset_t *drp)
break;
}
- if ((dnp->dn_reg = dt_regset_alloc(drp)) == -1)
- longjmp(yypcb->pcb_jmpbuf, EDT_NOREG);
+ dnp->dn_reg = dt_regset_alloc(drp);
if (dnp->dn_ident->di_flags & DT_IDFLG_LOCAL)
op = DIF_OP_LDLS;
@@ -1865,9 +2036,7 @@ dt_cg_node(dt_node_t *dnp, dt_irlist_t *dlp, dt_regset_t *drp)
dtrace_errmsg(dtp, dtrace_errno(dtp)));
}
- if ((dnp->dn_reg = dt_regset_alloc(drp)) == -1)
- longjmp(yypcb->pcb_jmpbuf, EDT_NOREG);
-
+ dnp->dn_reg = dt_regset_alloc(drp);
dt_cg_xsetx(dlp, dnp->dn_ident,
DT_LBL_NONE, dnp->dn_reg, sym.st_value);
@@ -1887,9 +2056,7 @@ dt_cg_node(dt_node_t *dnp, dt_irlist_t *dlp, dt_regset_t *drp)
break;
case DT_TOK_INT:
- if ((dnp->dn_reg = dt_regset_alloc(drp)) == -1)
- longjmp(yypcb->pcb_jmpbuf, EDT_NOREG);
-
+ dnp->dn_reg = dt_regset_alloc(drp);
dt_cg_setx(dlp, dnp->dn_reg, dnp->dn_value);
break;
@@ -1904,6 +2071,7 @@ dt_cg(dt_pcb_t *pcb, dt_node_t *dnp)
{
dif_instr_t instr;
dt_xlator_t *dxp;
+ dt_ident_t *idp;
if (pcb->pcb_regs == NULL && (pcb->pcb_regs =
dt_regset_create(pcb->pcb_hdl->dt_conf.dtc_difintregs)) == NULL)
@@ -1930,9 +2098,9 @@ dt_cg(dt_pcb_t *pcb, dt_node_t *dnp)
assert(pcb->pcb_dret == NULL);
pcb->pcb_dret = dnp;
- if (dt_node_is_dynamic(dnp)) {
+ if (dt_node_resolve(dnp, DT_IDENT_XLPTR) != NULL) {
dnerror(dnp, D_CG_DYN, "expression cannot evaluate to result "
- "of dynamic type\n");
+ "of a translated pointer\n");
}
/*
@@ -1948,6 +2116,14 @@ dt_cg(dt_pcb_t *pcb, dt_node_t *dnp)
}
dt_cg_node(dnp, &pcb->pcb_ir, pcb->pcb_regs);
+
+ if ((idp = dt_node_resolve(dnp, DT_IDENT_XLSOU)) != NULL) {
+ int reg = dt_cg_xlate_expand(dnp, idp,
+ &pcb->pcb_ir, pcb->pcb_regs);
+ dt_regset_free(pcb->pcb_regs, dnp->dn_reg);
+ dnp->dn_reg = reg;
+ }
+
instr = DIF_INSTR_RET(dnp->dn_reg);
dt_regset_free(pcb->pcb_regs, dnp->dn_reg);
dt_irlist_append(&pcb->pcb_ir, dt_cg_node_alloc(DT_LBL_NONE, instr));
@@ -1957,4 +2133,7 @@ dt_cg(dt_pcb_t *pcb, dt_node_t *dnp)
dxp->dx_ident->di_id = 0;
dxp->dx_ident->di_flags &= ~DT_IDFLG_CGREG;
}
+
+ dt_regset_free(pcb->pcb_regs, 0);
+ dt_regset_assert_free(pcb->pcb_regs);
}
diff --git a/usr/src/lib/libdtrace/common/dt_consume.c b/usr/src/lib/libdtrace/common/dt_consume.c
index d3a554c1c6..f12a39991a 100644
--- a/usr/src/lib/libdtrace/common/dt_consume.c
+++ b/usr/src/lib/libdtrace/common/dt_consume.c
@@ -25,7 +25,7 @@
/*
* Copyright (c) 2011, Joyent, Inc. All rights reserved.
- * Copyright (c) 2011 by Delphix. All rights reserved.
+ * Copyright (c) 2012 by Delphix. All rights reserved.
*/
#include <stdlib.h>
@@ -37,6 +37,7 @@
#include <ctype.h>
#include <alloca.h>
#include <dt_impl.h>
+#include <dt_pq.h>
#define DT_MASK_LO 0x00000000FFFFFFFFULL
@@ -438,17 +439,8 @@ dt_flowindent(dtrace_hdl_t *dtp, dtrace_probedata_t *data, dtrace_epid_t last,
offs += epd->dtepd_size;
do {
- if (offs >= buf->dtbd_size) {
- /*
- * We're at the end -- maybe. If the oldest
- * record is non-zero, we need to wrap.
- */
- if (buf->dtbd_oldest != 0) {
- offs = 0;
- } else {
- goto out;
- }
- }
+ if (offs >= buf->dtbd_size)
+ goto out;
next = *(uint32_t *)((uintptr_t)buf->dtbd_data + offs);
@@ -1700,26 +1692,27 @@ dt_setopt(dtrace_hdl_t *dtp, const dtrace_probedata_t *data,
}
static int
-dt_consume_cpu(dtrace_hdl_t *dtp, FILE *fp, int cpu, dtrace_bufdesc_t *buf,
+dt_consume_cpu(dtrace_hdl_t *dtp, FILE *fp, int cpu,
+ dtrace_bufdesc_t *buf, boolean_t just_one,
dtrace_consume_probe_f *efunc, dtrace_consume_rec_f *rfunc, void *arg)
{
dtrace_epid_t id;
- size_t offs, start = buf->dtbd_oldest, end = buf->dtbd_size;
+ size_t offs;
int flow = (dtp->dt_options[DTRACEOPT_FLOWINDENT] != DTRACEOPT_UNSET);
int quiet = (dtp->dt_options[DTRACEOPT_QUIET] != DTRACEOPT_UNSET);
int rval, i, n;
- dtrace_epid_t last = DTRACE_EPIDNONE;
uint64_t tracememsize = 0;
dtrace_probedata_t data;
uint64_t drops;
- caddr_t addr;
bzero(&data, sizeof (data));
data.dtpda_handle = dtp;
data.dtpda_cpu = cpu;
+ data.dtpda_flow = dtp->dt_flow;
+ data.dtpda_indent = dtp->dt_indent;
+ data.dtpda_prefix = dtp->dt_prefix;
-again:
- for (offs = start; offs < end; ) {
+ for (offs = buf->dtbd_oldest; offs < buf->dtbd_size; ) {
dtrace_eprobedesc_t *epd;
/*
@@ -1754,7 +1747,8 @@ again:
}
if (flow)
- (void) dt_flowindent(dtp, &data, last, buf, offs);
+ (void) dt_flowindent(dtp, &data, dtp->dt_last_epid,
+ buf, offs);
rval = (*efunc)(&data, arg);
@@ -1773,6 +1767,7 @@ again:
return (dt_set_errno(dtp, EDT_BADRVAL));
for (i = 0; i < epd->dtepd_nrecs; i++) {
+ caddr_t addr;
dtrace_recdesc_t *rec = &epd->dtepd_rec[i];
dtrace_actkind_t act = rec->dtrd_action;
@@ -2132,14 +2127,16 @@ nextrec:
rval = (*rfunc)(&data, NULL, arg);
nextepid:
offs += epd->dtepd_size;
- last = id;
+ dtp->dt_last_epid = id;
+ if (just_one) {
+ buf->dtbd_oldest = offs;
+ break;
+ }
}
- if (buf->dtbd_oldest != 0 && start == buf->dtbd_oldest) {
- end = buf->dtbd_oldest;
- start = 0;
- goto again;
- }
+ dtp->dt_flow = data.dtpda_flow;
+ dtp->dt_indent = data.dtpda_indent;
+ dtp->dt_prefix = data.dtpda_prefix;
if ((drops = buf->dtbd_drops) == 0)
return (0);
@@ -2152,6 +2149,126 @@ nextepid:
return (dt_handle_cpudrop(dtp, cpu, DTRACEDROP_PRINCIPAL, drops));
}
+/*
+ * Reduce memory usage by shrinking the buffer if it's no more than half full.
+ * Note, we need to preserve the alignment of the data at dtbd_oldest, which is
+ * only 4-byte aligned.
+ */
+static void
+dt_realloc_buf(dtrace_hdl_t *dtp, dtrace_bufdesc_t *buf, int cursize)
+{
+ uint64_t used = buf->dtbd_size - buf->dtbd_oldest;
+ if (used < cursize / 2) {
+ int misalign = buf->dtbd_oldest & (sizeof (uint64_t) - 1);
+ char *newdata = dt_alloc(dtp, used + misalign);
+ if (newdata == NULL)
+ return;
+ bzero(newdata, misalign);
+ bcopy(buf->dtbd_data + buf->dtbd_oldest,
+ newdata + misalign, used);
+ dt_free(dtp, buf->dtbd_data);
+ buf->dtbd_oldest = misalign;
+ buf->dtbd_size = used + misalign;
+ buf->dtbd_data = newdata;
+ }
+}
+
+/*
+ * If the ring buffer has wrapped, the data is not in order. Rearrange it
+ * so that it is. Note, we need to preserve the alignment of the data at
+ * dtbd_oldest, which is only 4-byte aligned.
+ */
+static int
+dt_unring_buf(dtrace_hdl_t *dtp, dtrace_bufdesc_t *buf)
+{
+ int misalign;
+ char *newdata, *ndp;
+
+ if (buf->dtbd_oldest == 0)
+ return (0);
+
+ misalign = buf->dtbd_oldest & (sizeof (uint64_t) - 1);
+ newdata = ndp = dt_alloc(dtp, buf->dtbd_size + misalign);
+
+ if (newdata == NULL)
+ return (-1);
+
+ assert(0 == (buf->dtbd_size & (sizeof (uint64_t) - 1)));
+
+ bzero(ndp, misalign);
+ ndp += misalign;
+
+ bcopy(buf->dtbd_data + buf->dtbd_oldest, ndp,
+ buf->dtbd_size - buf->dtbd_oldest);
+ ndp += buf->dtbd_size - buf->dtbd_oldest;
+
+ bcopy(buf->dtbd_data, ndp, buf->dtbd_oldest);
+
+ dt_free(dtp, buf->dtbd_data);
+ buf->dtbd_oldest = 0;
+ buf->dtbd_data = newdata;
+ buf->dtbd_size += misalign;
+
+ return (0);
+}
+
+static void
+dt_put_buf(dtrace_hdl_t *dtp, dtrace_bufdesc_t *buf)
+{
+ dt_free(dtp, buf->dtbd_data);
+ dt_free(dtp, buf);
+}
+
+/*
+ * Returns 0 on success, in which case *cbp will be filled in if we retrieved
+ * data, or NULL if there is no data for this CPU.
+ * Returns -1 on failure and sets dt_errno.
+ */
+static int
+dt_get_buf(dtrace_hdl_t *dtp, int cpu, dtrace_bufdesc_t **bufp)
+{
+ dtrace_optval_t size;
+ dtrace_bufdesc_t *buf = dt_zalloc(dtp, sizeof (*buf));
+ int error;
+
+ if (buf == NULL)
+ return (-1);
+
+ (void) dtrace_getopt(dtp, "bufsize", &size);
+ buf->dtbd_data = dt_alloc(dtp, size);
+ if (buf->dtbd_data == NULL) {
+ dt_free(dtp, buf);
+ return (-1);
+ }
+ buf->dtbd_size = size;
+ buf->dtbd_cpu = cpu;
+
+ if (dt_ioctl(dtp, DTRACEIOC_BUFSNAP, buf) == -1) {
+ dt_put_buf(dtp, buf);
+ /*
+ * If we failed with ENOENT, it may be because the
+ * CPU was unconfigured -- this is okay. Any other
+ * error, however, is unexpected.
+ */
+ if (errno == ENOENT) {
+ *bufp = NULL;
+ return (0);
+ }
+
+ return (dt_set_errno(dtp, errno));
+ }
+
+ error = dt_unring_buf(dtp, buf);
+ if (error != 0) {
+ dt_put_buf(dtp, buf);
+ return (error);
+ }
+ dt_realloc_buf(dtp, buf, size);
+
+ *bufp = buf;
+ return (0);
+}
+
typedef struct dt_begin {
dtrace_consume_probe_f *dtbgn_probefunc;
dtrace_consume_rec_f *dtbgn_recfunc;
@@ -2164,7 +2281,7 @@ typedef struct dt_begin {
static int
dt_consume_begin_probe(const dtrace_probedata_t *data, void *arg)
{
- dt_begin_t *begin = (dt_begin_t *)arg;
+ dt_begin_t *begin = arg;
dtrace_probedesc_t *pd = data->dtpda_pdesc;
int r1 = (strcmp(pd->dtpd_provider, "dtrace") == 0);
@@ -2189,7 +2306,7 @@ static int
dt_consume_begin_record(const dtrace_probedata_t *data,
const dtrace_recdesc_t *rec, void *arg)
{
- dt_begin_t *begin = (dt_begin_t *)arg;
+ dt_begin_t *begin = arg;
return (begin->dtbgn_recfunc(data, rec, begin->dtbgn_arg));
}
@@ -2215,7 +2332,7 @@ dt_consume_begin_error(const dtrace_errdata_t *data, void *arg)
}
static int
-dt_consume_begin(dtrace_hdl_t *dtp, FILE *fp, dtrace_bufdesc_t *buf,
+dt_consume_begin(dtrace_hdl_t *dtp, FILE *fp,
dtrace_consume_probe_f *pf, dtrace_consume_rec_f *rf, void *arg)
{
/*
@@ -2239,26 +2356,19 @@ dt_consume_begin(dtrace_hdl_t *dtp, FILE *fp, dtrace_bufdesc_t *buf,
* first pass, and that we only process ERROR enablings _not_ induced
* by BEGIN enablings in the second pass.
*/
+
dt_begin_t begin;
processorid_t cpu = dtp->dt_beganon;
- dtrace_bufdesc_t nbuf;
int rval, i;
static int max_ncpus;
- dtrace_optval_t size;
+ dtrace_bufdesc_t *buf;
dtp->dt_beganon = -1;
- if (dt_ioctl(dtp, DTRACEIOC_BUFSNAP, buf) == -1) {
- /*
- * We really don't expect this to fail, but it is at least
- * technically possible for this to fail with ENOENT. In this
- * case, we just drive on...
- */
- if (errno == ENOENT)
- return (0);
-
- return (dt_set_errno(dtp, errno));
- }
+ if (dt_get_buf(dtp, cpu, &buf) != 0)
+ return (-1);
+ if (buf == NULL)
+ return (0);
if (!dtp->dt_stopped || buf->dtbd_cpu != dtp->dt_endedon) {
/*
@@ -2266,7 +2376,10 @@ dt_consume_begin(dtrace_hdl_t *dtp, FILE *fp, dtrace_bufdesc_t *buf,
* we are, we actually processed any END probes on another
* CPU. We can simply consume this buffer and return.
*/
- return (dt_consume_cpu(dtp, fp, cpu, buf, pf, rf, arg));
+ rval = dt_consume_cpu(dtp, fp, cpu, buf, B_FALSE,
+ pf, rf, arg);
+ dt_put_buf(dtp, buf);
+ return (rval);
}
begin.dtbgn_probefunc = pf;
@@ -2283,56 +2396,41 @@ dt_consume_begin(dtrace_hdl_t *dtp, FILE *fp, dtrace_bufdesc_t *buf,
dtp->dt_errhdlr = dt_consume_begin_error;
dtp->dt_errarg = &begin;
- rval = dt_consume_cpu(dtp, fp, cpu, buf, dt_consume_begin_probe,
- dt_consume_begin_record, &begin);
+ rval = dt_consume_cpu(dtp, fp, cpu, buf, B_FALSE,
+ dt_consume_begin_probe, dt_consume_begin_record, &begin);
dtp->dt_errhdlr = begin.dtbgn_errhdlr;
dtp->dt_errarg = begin.dtbgn_errarg;
- if (rval != 0)
+ if (rval != 0) {
+ dt_put_buf(dtp, buf);
return (rval);
-
- /*
- * Now allocate a new buffer. We'll use this to deal with every other
- * CPU.
- */
- bzero(&nbuf, sizeof (dtrace_bufdesc_t));
- (void) dtrace_getopt(dtp, "bufsize", &size);
- if ((nbuf.dtbd_data = malloc(size)) == NULL)
- return (dt_set_errno(dtp, EDT_NOMEM));
+ }
if (max_ncpus == 0)
max_ncpus = dt_sysconf(dtp, _SC_CPUID_MAX) + 1;
for (i = 0; i < max_ncpus; i++) {
- nbuf.dtbd_cpu = i;
-
+ dtrace_bufdesc_t *nbuf;
if (i == cpu)
continue;
- if (dt_ioctl(dtp, DTRACEIOC_BUFSNAP, &nbuf) == -1) {
- /*
- * If we failed with ENOENT, it may be because the
- * CPU was unconfigured -- this is okay. Any other
- * error, however, is unexpected.
- */
- if (errno == ENOENT)
- continue;
-
- free(nbuf.dtbd_data);
-
- return (dt_set_errno(dtp, errno));
+ if (dt_get_buf(dtp, i, &nbuf) != 0) {
+ dt_put_buf(dtp, buf);
+ return (-1);
}
+ if (nbuf == NULL)
+ continue;
- if ((rval = dt_consume_cpu(dtp, fp,
- i, &nbuf, pf, rf, arg)) != 0) {
- free(nbuf.dtbd_data);
+ rval = dt_consume_cpu(dtp, fp, i, nbuf, B_FALSE,
+ pf, rf, arg);
+ dt_put_buf(dtp, nbuf);
+ if (rval != 0) {
+ dt_put_buf(dtp, buf);
return (rval);
}
}
- free(nbuf.dtbd_data);
-
/*
* Okay -- we're done with the other buffers. Now we want to
* reconsume the first buffer -- but this time we're looking for
@@ -2347,8 +2445,8 @@ dt_consume_begin(dtrace_hdl_t *dtp, FILE *fp, dtrace_bufdesc_t *buf,
dtp->dt_errhdlr = dt_consume_begin_error;
dtp->dt_errarg = &begin;
- rval = dt_consume_cpu(dtp, fp, cpu, buf, dt_consume_begin_probe,
- dt_consume_begin_record, &begin);
+ rval = dt_consume_cpu(dtp, fp, cpu, buf, B_FALSE,
+ dt_consume_begin_probe, dt_consume_begin_record, &begin);
dtp->dt_errhdlr = begin.dtbgn_errhdlr;
dtp->dt_errarg = begin.dtbgn_errarg;
@@ -2356,11 +2454,31 @@ dt_consume_begin(dtrace_hdl_t *dtp, FILE *fp, dtrace_bufdesc_t *buf,
return (rval);
}
+/* ARGSUSED */
+static uint64_t
+dt_buf_oldest(void *elem, void *arg)
+{
+ dtrace_bufdesc_t *buf = elem;
+ size_t offs = buf->dtbd_oldest;
+
+ while (offs < buf->dtbd_size) {
+ dtrace_rechdr_t *dtrh =
+ (dtrace_rechdr_t *)(buf->dtbd_data + offs);
+ if (dtrh->dtrh_epid == DTRACE_EPIDNONE) {
+ offs += sizeof (dtrace_epid_t);
+ } else {
+ return (DTRACE_RECORD_LOAD_TIMESTAMP(dtrh));
+ }
+ }
+
+ /* There are no records left; use the time the buffer was retrieved. */
+ return (buf->dtbd_timestamp);
+}
+
int
dtrace_consume(dtrace_hdl_t *dtp, FILE *fp,
dtrace_consume_probe_f *pf, dtrace_consume_rec_f *rf, void *arg)
{
- dtrace_bufdesc_t *buf = &dtp->dt_buf;
dtrace_optval_t size;
static int max_ncpus;
int i, rval;
@@ -2388,71 +2506,158 @@ dtrace_consume(dtrace_hdl_t *dtp, FILE *fp,
if (rf == NULL)
rf = (dtrace_consume_rec_f *)dt_nullrec;
- if (buf->dtbd_data == NULL) {
- (void) dtrace_getopt(dtp, "bufsize", &size);
- if ((buf->dtbd_data = malloc(size)) == NULL)
- return (dt_set_errno(dtp, EDT_NOMEM));
-
- buf->dtbd_size = size;
- }
-
- /*
- * If we have just begun, we want to first process the CPU that
- * executed the BEGIN probe (if any).
- */
- if (dtp->dt_active && dtp->dt_beganon != -1) {
- buf->dtbd_cpu = dtp->dt_beganon;
- if ((rval = dt_consume_begin(dtp, fp, buf, pf, rf, arg)) != 0)
- return (rval);
- }
-
- for (i = 0; i < max_ncpus; i++) {
- buf->dtbd_cpu = i;
-
+ if (dtp->dt_options[DTRACEOPT_TEMPORAL] == DTRACEOPT_UNSET) {
/*
- * If we have stopped, we want to process the CPU on which the
- * END probe was processed only _after_ we have processed
- * everything else.
+ * The output will not be in the order it was traced. Rather,
+ * we will consume all of the data from each CPU's buffer in
+ * turn. We apply special handling for the records from BEGIN
+ * and END probes so that they are consumed first and last,
+ * respectively.
+ *
+ * If we have just begun, we want to first process the CPU that
+ * executed the BEGIN probe (if any).
*/
- if (dtp->dt_stopped && (i == dtp->dt_endedon))
- continue;
+ if (dtp->dt_active && dtp->dt_beganon != -1 &&
+ (rval = dt_consume_begin(dtp, fp, pf, rf, arg)) != 0)
+ return (rval);
+
+ for (i = 0; i < max_ncpus; i++) {
+ dtrace_bufdesc_t *buf;
- if (dt_ioctl(dtp, DTRACEIOC_BUFSNAP, buf) == -1) {
/*
- * If we failed with ENOENT, it may be because the
- * CPU was unconfigured -- this is okay. Any other
- * error, however, is unexpected.
+ * If we have stopped, we want to process the CPU on
+ * which the END probe was processed only _after_ we
+ * have processed everything else.
*/
- if (errno == ENOENT)
+ if (dtp->dt_stopped && (i == dtp->dt_endedon))
continue;
- return (dt_set_errno(dtp, errno));
+ if (dt_get_buf(dtp, i, &buf) != 0)
+ return (-1);
+ if (buf == NULL)
+ continue;
+
+ dtp->dt_flow = 0;
+ dtp->dt_indent = 0;
+ dtp->dt_prefix = NULL;
+ rval = dt_consume_cpu(dtp, fp, i,
+ buf, B_FALSE, pf, rf, arg);
+ dt_put_buf(dtp, buf);
+ if (rval != 0)
+ return (rval);
}
+ if (dtp->dt_stopped) {
+ dtrace_bufdesc_t *buf;
+
+ if (dt_get_buf(dtp, dtp->dt_endedon, &buf) != 0)
+ return (-1);
+ if (buf == NULL)
+ return (0);
- if ((rval = dt_consume_cpu(dtp, fp, i, buf, pf, rf, arg)) != 0)
+ rval = dt_consume_cpu(dtp, fp, dtp->dt_endedon,
+ buf, B_FALSE, pf, rf, arg);
+ dt_put_buf(dtp, buf);
return (rval);
- }
+ }
+ } else {
+ /*
+ * The output will be in the order it was traced (or for
+ * speculations, when it was committed). We retrieve a buffer
+ * from each CPU and put it into a priority queue, which sorts
+ * based on the first entry in the buffer. This is sufficient
+ * because entries within a buffer are already sorted.
+ *
+ * We then consume records one at a time, always consuming the
+ * oldest record, as determined by the priority queue. When
+ * we reach the end of the time covered by these buffers,
+ * we need to stop and retrieve more records on the next pass.
+ * The kernel tells us the time covered by each buffer, in
+ * dtbd_timestamp. The first buffer's timestamp tells us the
+ * time covered by all buffers, as subsequently retrieved
+ * buffers will cover to a more recent time.
+ */
- if (!dtp->dt_stopped)
- return (0);
+ uint64_t *drops = alloca(max_ncpus * sizeof (uint64_t));
+ uint64_t first_timestamp = 0;
+ uint_t cookie = 0;
+ dtrace_bufdesc_t *buf;
- buf->dtbd_cpu = dtp->dt_endedon;
+ bzero(drops, max_ncpus * sizeof (uint64_t));
+
+ if (dtp->dt_bufq == NULL) {
+ dtp->dt_bufq = dt_pq_init(dtp, max_ncpus * 2,
+ dt_buf_oldest, NULL);
+ if (dtp->dt_bufq == NULL) /* ENOMEM */
+ return (-1);
+ }
+
+ /* Retrieve data from each CPU. */
+ (void) dtrace_getopt(dtp, "bufsize", &size);
+ for (i = 0; i < max_ncpus; i++) {
+ dtrace_bufdesc_t *buf;
+
+ if (dt_get_buf(dtp, i, &buf) != 0)
+ return (-1);
+ if (buf != NULL) {
+ if (first_timestamp == 0)
+ first_timestamp = buf->dtbd_timestamp;
+ assert(buf->dtbd_timestamp >= first_timestamp);
+
+ dt_pq_insert(dtp->dt_bufq, buf);
+ drops[i] = buf->dtbd_drops;
+ buf->dtbd_drops = 0;
+ }
+ }
+
+ /* Consume records. */
+ for (;;) {
+ dtrace_bufdesc_t *buf = dt_pq_pop(dtp->dt_bufq);
+ uint64_t timestamp;
+
+ if (buf == NULL)
+ break;
+
+ timestamp = dt_buf_oldest(buf, dtp);
+ assert(timestamp >= dtp->dt_last_timestamp);
+ dtp->dt_last_timestamp = timestamp;
+
+ if (timestamp == buf->dtbd_timestamp) {
+ /*
+ * We've reached the end of the time covered
+ * by this buffer. If this is the oldest
+ * buffer, we must do another pass
+ * to retrieve more data.
+ */
+ dt_put_buf(dtp, buf);
+ if (timestamp == first_timestamp &&
+ !dtp->dt_stopped)
+ break;
+ continue;
+ }
+
+ if ((rval = dt_consume_cpu(dtp, fp,
+ buf->dtbd_cpu, buf, B_TRUE, pf, rf, arg)) != 0)
+ return (rval);
+ dt_pq_insert(dtp->dt_bufq, buf);
+ }
+
+ /* Consume drops. */
+ for (i = 0; i < max_ncpus; i++) {
+ if (drops[i] != 0) {
+ int error = dt_handle_cpudrop(dtp, i,
+ DTRACEDROP_PRINCIPAL, drops[i]);
+ if (error != 0)
+ return (error);
+ }
+ }
- if (dt_ioctl(dtp, DTRACEIOC_BUFSNAP, buf) == -1) {
/*
- * This _really_ shouldn't fail, but it is strictly speaking
- * possible for this to return ENOENT if the CPU that called
- * the END enabling somehow managed to become unconfigured.
- * It's unclear how the user can possibly expect anything
- * rational to happen in this case -- the state has been thrown
- * out along with the unconfigured CPU -- so we'll just drive
- * on...
+ * Reduce memory usage by re-allocating smaller buffers
+ * for the "remnants".
*/
- if (errno == ENOENT)
- return (0);
-
- return (dt_set_errno(dtp, errno));
+ while (buf = dt_pq_walk(dtp->dt_bufq, &cookie))
+ dt_realloc_buf(dtp, buf, buf->dtbd_size);
}
- return (dt_consume_cpu(dtp, fp, dtp->dt_endedon, buf, pf, rf, arg));
+ return (0);
}
diff --git a/usr/src/lib/libdtrace/common/dt_dis.c b/usr/src/lib/libdtrace/common/dt_dis.c
index f4bb0c4bba..fff4235a6b 100644
--- a/usr/src/lib/libdtrace/common/dt_dis.c
+++ b/usr/src/lib/libdtrace/common/dt_dis.c
@@ -19,12 +19,15 @@
*
* CDDL HEADER END
*/
+
/*
* Copyright 2005 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
+/*
+ * Copyright (c) 2012 by Delphix. All rights reserved.
+ */
#include <strings.h>
#include <stdio.h>
@@ -212,12 +215,22 @@ dt_dis_pushts(const dtrace_difo_t *dp,
{
static const char *const tnames[] = { "D type", "string" };
uint_t type = DIF_INSTR_TYPE(in);
+ const char *pad;
- (void) fprintf(fp, "%-4s DT_TYPE(%u), %%r%u, %%r%u",
- name, type, DIF_INSTR_R2(in), DIF_INSTR_RS(in));
+ if (DIF_INSTR_OP(in) == DIF_OP_PUSHTV) {
+ (void) fprintf(fp, "%-4s DT_TYPE(%u), %%r%u",
+ name, type, DIF_INSTR_RS(in));
+ pad = "\t\t";
+ } else {
+ (void) fprintf(fp, "%-4s DT_TYPE(%u), %%r%u, %%r%u",
+ name, type, DIF_INSTR_R2(in), DIF_INSTR_RS(in));
+ pad = "\t";
+ }
- if (type < sizeof (tnames) / sizeof (tnames[0]))
- (void) fprintf(fp, "\t! DT_TYPE(%u) = %s", type, tnames[type]);
+ if (type < sizeof (tnames) / sizeof (tnames[0])) {
+ (void) fprintf(fp, "%s! DT_TYPE(%u) = %s", pad,
+ type, tnames[type]);
+ }
}
static void
diff --git a/usr/src/lib/libdtrace/common/dt_error.c b/usr/src/lib/libdtrace/common/dt_error.c
index 0bfabc919c..9c1cbd73bc 100644
--- a/usr/src/lib/libdtrace/common/dt_error.c
+++ b/usr/src/lib/libdtrace/common/dt_error.c
@@ -18,11 +18,16 @@
*
* CDDL HEADER END
*/
+
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
+/*
+ * Copyright (c) 2012 by Delphix. All rights reserved.
+ */
+
#include <strings.h>
#include <dt_impl.h>
@@ -36,7 +41,6 @@ static const struct {
{ EDT_VERSREDUCED, "Requested version conflicts with earlier setting" },
{ EDT_CTF, "Unexpected libctf error" },
{ EDT_COMPILER, "Error in D program compilation" },
- { EDT_NOREG, "Insufficient registers to generate code" },
{ EDT_NOTUPREG, "Insufficient tuple registers to generate code" },
{ EDT_NOMEM, "Memory allocation failure" },
{ EDT_INT2BIG, "Integer constant table limit exceeded" },
diff --git a/usr/src/lib/libdtrace/common/dt_errtags.h b/usr/src/lib/libdtrace/common/dt_errtags.h
index 473e2addc7..0a9e7c029b 100644
--- a/usr/src/lib/libdtrace/common/dt_errtags.h
+++ b/usr/src/lib/libdtrace/common/dt_errtags.h
@@ -26,7 +26,7 @@
/*
* Copyright (c) 2011, Joyent, Inc. All rights reserved.
- * Copyright (c) 2011 by Delphix. All rights reserved.
+ * Copyright (c) 2012 by Delphix. All rights reserved.
*/
#ifndef _DT_ERRTAGS_H
@@ -259,7 +259,8 @@ typedef enum {
D_LLQUANT_FACTORNSTEPS, /* llquantize() # steps < factor */
D_LLQUANT_FACTOREVEN, /* llquantize() bad # steps/factor */
D_LLQUANT_FACTORSMALL, /* llquantize() magnitude too small */
- D_LLQUANT_MAGTOOBIG /* llquantize() high mag too large */
+ D_LLQUANT_MAGTOOBIG, /* llquantize() high mag too large */
+ D_NOREG /* no available internal registers */
} dt_errtag_t;
extern const char *dt_errtag(dt_errtag_t);
diff --git a/usr/src/lib/libdtrace/common/dt_impl.h b/usr/src/lib/libdtrace/common/dt_impl.h
index 7b9eb5e78b..60413d7e3b 100644
--- a/usr/src/lib/libdtrace/common/dt_impl.h
+++ b/usr/src/lib/libdtrace/common/dt_impl.h
@@ -26,7 +26,7 @@
/*
* Copyright (c) 2011, Joyent, Inc. All rights reserved.
- * Copyright (c) 2011 by Delphix. All rights reserved.
+ * Copyright (c) 2012 by Delphix. All rights reserved.
*/
#ifndef _DT_IMPL_H
@@ -55,6 +55,7 @@ extern "C" {
#include <dt_proc.h>
#include <dt_dof.h>
#include <dt_pcb.h>
+#include <dt_pq.h>
struct dt_module; /* see below */
struct dt_pfdict; /* see <dt_printf.h> */
@@ -226,6 +227,7 @@ struct dtrace_hdl {
uint_t dt_provbuckets; /* number of provider hash buckets */
uint_t dt_nprovs; /* number of providers in hash and list */
dt_proc_hash_t *dt_procs; /* hash table of grabbed process handles */
+ char **dt_proc_env; /* additional environment variables */
dt_intdesc_t dt_ints[6]; /* cached integer type descriptions */
ctf_id_t dt_type_func; /* cached CTF identifier for function type */
ctf_id_t dt_type_fptr; /* cached CTF identifier for function pointer */
@@ -244,7 +246,7 @@ struct dtrace_hdl {
int dt_maxstrdata; /* max strdata ID */
char **dt_strdata; /* pointer to strdata array */
dt_aggregate_t dt_aggregate; /* aggregate */
- dtrace_bufdesc_t dt_buf; /* staging buffer */
+ dt_pq_t *dt_bufq; /* CPU-specific data queue */
struct dt_pfdict *dt_pfdict; /* dictionary of printf conversions */
dt_version_t dt_vmax; /* optional ceiling on program API binding */
dtrace_attribute_t dt_amin; /* optional floor on program attributes */
@@ -306,6 +308,11 @@ struct dtrace_hdl {
struct utsname dt_uts; /* uname(2) information for system */
dt_list_t dt_lib_dep; /* scratch linked-list of lib dependencies */
dt_list_t dt_lib_dep_sorted; /* dependency sorted library list */
+ dtrace_flowkind_t dt_flow; /* flow kind */
+ const char *dt_prefix; /* recommended flow prefix */
+ int dt_indent; /* recommended flow indent */
+ dtrace_epid_t dt_last_epid; /* most recently consumed EPID */
+ uint64_t dt_last_timestamp; /* most recently consumed timestamp */
};
/*
@@ -439,7 +446,6 @@ enum {
EDT_VERSREDUCED, /* requested API version has been reduced */
EDT_CTF, /* libctf called failed (dt_ctferr has more) */
EDT_COMPILER, /* error in D program compilation */
- EDT_NOREG, /* register allocation failure */
EDT_NOTUPREG, /* tuple register allocation failure */
EDT_NOMEM, /* memory allocation failure */
EDT_INT2BIG, /* integer limit exceeded */
diff --git a/usr/src/lib/libdtrace/common/dt_open.c b/usr/src/lib/libdtrace/common/dt_open.c
index 59086f3ef8..a7f8676f74 100644
--- a/usr/src/lib/libdtrace/common/dt_open.c
+++ b/usr/src/lib/libdtrace/common/dt_open.c
@@ -22,7 +22,7 @@
/*
* Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, Joyent, Inc. All rights reserved.
- * Copyright (c) 2011 by Delphix. All rights reserved.
+ * Copyright (c) 2012 by Delphix. All rights reserved.
*/
#include <sys/types.h>
@@ -81,7 +81,7 @@
/*
* The version number should be increased for every customer visible release
- * of Solaris. The major number should be incremented when a fundamental
+ * of DTrace. The major number should be incremented when a fundamental
* change has been made that would affect all consumers, and would reflect
* sweeping changes to DTrace or the D language. The minor number should be
* incremented when a change is introduced that could break scripts that had
@@ -941,7 +941,7 @@ alloc:
dtp->dt_mods = calloc(dtp->dt_modbuckets, sizeof (dt_module_t *));
dtp->dt_provbuckets = _dtrace_strbuckets;
dtp->dt_provs = calloc(dtp->dt_provbuckets, sizeof (dt_provider_t *));
- dt_proc_hash_create(dtp);
+ dt_proc_init(dtp);
dtp->dt_vmax = DT_VERS_LATEST;
dtp->dt_cpp_path = strdup(_dtrace_defcpp);
dtp->dt_cpp_argv = malloc(sizeof (char *));
@@ -955,8 +955,9 @@ alloc:
(void) uname(&dtp->dt_uts);
if (dtp->dt_mods == NULL || dtp->dt_provs == NULL ||
- dtp->dt_procs == NULL || dtp->dt_ld_path == NULL ||
- dtp->dt_cpp_path == NULL || dtp->dt_cpp_argv == NULL)
+ dtp->dt_procs == NULL || dtp->dt_proc_env == NULL ||
+ dtp->dt_ld_path == NULL || dtp->dt_cpp_path == NULL ||
+ dtp->dt_cpp_argv == NULL)
return (set_open_errno(dtp, errp, EDT_NOMEM));
for (i = 0; i < DTRACEOPT_MAX; i++)
@@ -1322,7 +1323,7 @@ dtrace_close(dtrace_hdl_t *dtp)
int i;
if (dtp->dt_procs != NULL)
- dt_proc_hash_destroy(dtp);
+ dt_proc_fini(dtp);
while ((pgp = dt_list_next(&dtp->dt_programs)) != NULL)
dt_program_destroy(dtp, pgp);
@@ -1369,7 +1370,6 @@ dtrace_close(dtrace_hdl_t *dtp)
dt_strdata_destroy(dtp);
dt_buffered_destroy(dtp);
dt_aggregate_destroy(dtp);
- free(dtp->dt_buf.dtbd_data);
dt_pfdict_destroy(dtp);
dt_provmod_destroy(&dtp->dt_provmod);
dt_dof_fini(dtp);
diff --git a/usr/src/lib/libdtrace/common/dt_options.c b/usr/src/lib/libdtrace/common/dt_options.c
index 63db3ae349..71bd508ecd 100644
--- a/usr/src/lib/libdtrace/common/dt_options.c
+++ b/usr/src/lib/libdtrace/common/dt_options.c
@@ -26,6 +26,7 @@
/*
* Copyright (c) 2011, Joyent, Inc. All rights reserved.
+ * Copyright (c) 2012 by Delphix. All rights reserved.
*/
#include <sys/resource.h>
@@ -370,6 +371,61 @@ dt_opt_pgmax(dtrace_hdl_t *dtp, const char *arg, uintptr_t option)
return (0);
}
+static int
+dt_opt_setenv(dtrace_hdl_t *dtp, const char *arg, uintptr_t option)
+{
+ char **p;
+ char *var;
+ int i;
+
+ /*
+ * We can't effectively set environment variables from #pragma lines
+ * since the processes have already been spawned.
+ */
+ if (dtp->dt_pcb != NULL)
+ return (dt_set_errno(dtp, EDT_BADOPTCTX));
+
+ if (arg == NULL)
+ return (dt_set_errno(dtp, EDT_BADOPTVAL));
+
+ if (!option && strchr(arg, '=') != NULL)
+ return (dt_set_errno(dtp, EDT_BADOPTVAL));
+
+ for (i = 1, p = dtp->dt_proc_env; *p != NULL; i++, p++)
+ continue;
+
+ for (p = dtp->dt_proc_env; *p != NULL; p++) {
+ var = strchr(*p, '=');
+ if (var == NULL)
+ var = *p + strlen(*p);
+ if (strncmp(*p, arg, var - *p) == 0) {
+ dt_free(dtp, *p);
+ *p = dtp->dt_proc_env[i - 1];
+ dtp->dt_proc_env[i - 1] = NULL;
+ i--;
+ }
+ }
+
+ if (option) {
+ if ((var = strdup(arg)) == NULL)
+ return (dt_set_errno(dtp, EDT_NOMEM));
+
+ if ((p = dt_alloc(dtp, sizeof (char *) * (i + 1))) == NULL) {
+ dt_free(dtp, var);
+ return (dt_set_errno(dtp, EDT_NOMEM));
+ }
+
+ bcopy(dtp->dt_proc_env, p, sizeof (char *) * i);
+ dt_free(dtp, dtp->dt_proc_env);
+ dtp->dt_proc_env = p;
+
+ dtp->dt_proc_env[i - 1] = var;
+ dtp->dt_proc_env[i] = NULL;
+ }
+
+ return (0);
+}
+
/*ARGSUSED*/
static int
dt_opt_stdc(dtrace_hdl_t *dtp, const char *arg, uintptr_t option)
@@ -413,7 +469,6 @@ dt_opt_syslibdir(dtrace_hdl_t *dtp, const char *arg, uintptr_t option)
return (0);
}
-
/*ARGSUSED*/
static int
dt_opt_tree(dtrace_hdl_t *dtp, const char *arg, uintptr_t option)
@@ -918,6 +973,7 @@ static const dt_option_t _dtrace_ctoptions[] = {
{ "nolibs", dt_opt_cflags, DTRACE_C_NOLIBS },
{ "pgmax", dt_opt_pgmax },
{ "pspec", dt_opt_cflags, DTRACE_C_PSPEC },
+ { "setenv", dt_opt_setenv, 1 },
{ "stdc", dt_opt_stdc },
{ "strip", dt_opt_dflags, DTRACE_D_STRIP },
{ "syslibdir", dt_opt_syslibdir },
@@ -926,6 +982,7 @@ static const dt_option_t _dtrace_ctoptions[] = {
{ "udefs", dt_opt_invcflags, DTRACE_C_UNODEF },
{ "undef", dt_opt_cpp_opts, (uintptr_t)"-U" },
{ "unodefs", dt_opt_cflags, DTRACE_C_UNODEF },
+ { "unsetenv", dt_opt_setenv, 0 },
{ "verbose", dt_opt_cflags, DTRACE_C_DIFV },
{ "version", dt_opt_version },
{ "zdefs", dt_opt_cflags, DTRACE_C_ZDEFS },
@@ -954,6 +1011,7 @@ static const dt_option_t _dtrace_rtoptions[] = {
{ "strsize", dt_opt_strsize, DTRACEOPT_STRSIZE },
{ "ustackframes", dt_opt_runtime, DTRACEOPT_USTACKFRAMES },
{ "zone", dt_opt_zone, DTRACEOPT_ZONE },
+ { "temporal", dt_opt_runtime, DTRACEOPT_TEMPORAL },
{ NULL }
};
diff --git a/usr/src/lib/libdtrace/common/dt_parser.c b/usr/src/lib/libdtrace/common/dt_parser.c
index 05715894a7..6f837c4bed 100644
--- a/usr/src/lib/libdtrace/common/dt_parser.c
+++ b/usr/src/lib/libdtrace/common/dt_parser.c
@@ -22,6 +22,7 @@
/*
* Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, Joyent Inc. All rights reserved.
+ * Copyright (c) 2012 by Delphix. All rights reserved.
*/
/*
@@ -93,6 +94,7 @@
*/
#include <sys/param.h>
+#include <sys/sysmacros.h>
#include <limits.h>
#include <setjmp.h>
#include <strings.h>
@@ -1856,6 +1858,38 @@ dt_node_op1(int op, dt_node_t *cp)
return (dnp);
}
+/*
+ * If an integer constant is being cast to another integer type, we can
+ * perform the cast as part of integer constant folding in this pass. We must
+ * take action when the integer is being cast to a smaller type or if it is
+ * changing signed-ness. If so, we first shift rp's bits bits high (losing
+ * excess bits if narrowing) and then shift them down with either a logical
+ * shift (unsigned) or arithmetic shift (signed).
+ */
+static void
+dt_cast(dt_node_t *lp, dt_node_t *rp)
+{
+ size_t srcsize = dt_node_type_size(rp);
+ size_t dstsize = dt_node_type_size(lp);
+
+ if (dstsize < srcsize) {
+ int n = (sizeof (uint64_t) - dstsize) * NBBY;
+ rp->dn_value <<= n;
+ rp->dn_value >>= n;
+ } else if (dstsize > srcsize) {
+ int n = (sizeof (uint64_t) - srcsize) * NBBY;
+ int s = (dstsize - srcsize) * NBBY;
+
+ rp->dn_value <<= n;
+ if (rp->dn_flags & DT_NF_SIGNED) {
+ rp->dn_value = (intmax_t)rp->dn_value >> s;
+ rp->dn_value >>= n - s;
+ } else {
+ rp->dn_value >>= n;
+ }
+ }
+}
+
dt_node_t *
dt_node_op2(int op, dt_node_t *lp, dt_node_t *rp)
{
@@ -2005,32 +2039,9 @@ dt_node_op2(int op, dt_node_t *lp, dt_node_t *rp)
}
}
- /*
- * If an integer constant is being cast to another integer type, we can
- * perform the cast as part of integer constant folding in this pass.
- * We must take action when the integer is being cast to a smaller type
- * or if it is changing signed-ness. If so, we first shift rp's bits
- * bits high (losing excess bits if narrowing) and then shift them down
- * with either a logical shift (unsigned) or arithmetic shift (signed).
- */
if (op == DT_TOK_LPAR && rp->dn_kind == DT_NODE_INT &&
dt_node_is_integer(lp)) {
- size_t srcsize = dt_node_type_size(rp);
- size_t dstsize = dt_node_type_size(lp);
-
- if ((dstsize < srcsize) || ((lp->dn_flags & DT_NF_SIGNED) ^
- (rp->dn_flags & DT_NF_SIGNED))) {
- int n = dstsize < srcsize ?
- (sizeof (uint64_t) * NBBY - dstsize * NBBY) :
- (sizeof (uint64_t) * NBBY - srcsize * NBBY);
-
- rp->dn_value <<= n;
- if (lp->dn_flags & DT_NF_SIGNED)
- rp->dn_value = (intmax_t)rp->dn_value >> n;
- else
- rp->dn_value = rp->dn_value >> n;
- }
-
+ dt_cast(lp, rp);
dt_node_type_propagate(lp, rp);
dt_node_attr_assign(rp, dt_attr_min(lp->dn_attr, rp->dn_attr));
dt_node_free(lp);
@@ -2889,14 +2900,14 @@ dt_cook_op1(dt_node_t *dnp, uint_t idflags)
case DT_TOK_DEREF:
/*
* If the deref operator is applied to a translated pointer,
- * we can just set our output type to the base translation.
+ * we set our output type to the output of the translation.
*/
if ((idp = dt_node_resolve(cp, DT_IDENT_XLPTR)) != NULL) {
dt_xlator_t *dxp = idp->di_data;
dnp->dn_ident = &dxp->dx_souid;
dt_node_type_assign(dnp,
- DT_DYN_CTFP(dtp), DT_DYN_TYPE(dtp));
+ dnp->dn_ident->di_ctfp, dnp->dn_ident->di_type);
break;
}
@@ -3072,6 +3083,31 @@ dt_cook_op1(dt_node_t *dnp, uint_t idflags)
return (dnp);
}
+static void
+dt_assign_common(dt_node_t *dnp)
+{
+ dt_node_t *lp = dnp->dn_left;
+ dt_node_t *rp = dnp->dn_right;
+ int op = dnp->dn_op;
+
+ if (rp->dn_kind == DT_NODE_INT)
+ dt_cast(lp, rp);
+
+ if (!(lp->dn_flags & DT_NF_LVALUE)) {
+ xyerror(D_OP_LVAL, "operator %s requires modifiable "
+ "lvalue as an operand\n", opstr(op));
+ /* see K&R[A7.17] */
+ }
+
+ if (!(lp->dn_flags & DT_NF_WRITABLE)) {
+ xyerror(D_OP_WRITE, "operator %s can only be applied "
+ "to a writable variable\n", opstr(op));
+ }
+
+ dt_node_type_propagate(lp, dnp); /* see K&R[A7.17] */
+ dt_node_attr_assign(dnp, dt_attr_min(lp->dn_attr, rp->dn_attr));
+}
+
static dt_node_t *
dt_cook_op2(dt_node_t *dnp, uint_t idflags)
{
@@ -3550,19 +3586,7 @@ dt_cook_op2(dt_node_t *dnp, uint_t idflags)
}
}
asgn_common:
- if (!(lp->dn_flags & DT_NF_LVALUE)) {
- xyerror(D_OP_LVAL, "operator %s requires modifiable "
- "lvalue as an operand\n", opstr(op));
- /* see K&R[A7.17] */
- }
-
- if (!(lp->dn_flags & DT_NF_WRITABLE)) {
- xyerror(D_OP_WRITE, "operator %s can only be applied "
- "to a writable variable\n", opstr(op));
- }
-
- dt_node_type_propagate(lp, dnp); /* see K&R[A7.17] */
- dt_node_attr_assign(dnp, dt_attr_min(lp->dn_attr, rp->dn_attr));
+ dt_assign_common(dnp);
break;
case DT_TOK_PTR:
@@ -3867,6 +3891,14 @@ asgn_common:
dt_node_type_propagate(lp, dnp); /* see K&R[A7.5] */
dt_node_attr_assign(dnp, dt_attr_min(lp->dn_attr, rp->dn_attr));
+
+ /*
+ * If it's a pointer then should be able to (attempt to)
+ * assign to it.
+ */
+ if (lkind == CTF_K_POINTER)
+ dnp->dn_flags |= DT_NF_WRITABLE;
+
break;
}
diff --git a/usr/src/lib/libdtrace/common/dt_pq.c b/usr/src/lib/libdtrace/common/dt_pq.c
new file mode 100644
index 0000000000..0cd556abd8
--- /dev/null
+++ b/usr/src/lib/libdtrace/common/dt_pq.c
@@ -0,0 +1,157 @@
+/*
+ * CDDL HEADER START
+ *
+ * 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.
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 2012 by Delphix. All rights reserved.
+ */
+
+#include <dtrace.h>
+#include <dt_impl.h>
+#include <dt_pq.h>
+#include <assert.h>
+
+/*
+ * Create a new priority queue.
+ *
+ * size is the maximum number of items that will be stored in the priority
+ * queue at one time.
+ */
+dt_pq_t *
+dt_pq_init(dtrace_hdl_t *dtp, uint_t size, dt_pq_value_f value_cb, void *cb_arg)
+{
+ dt_pq_t *p;
+ assert(size > 1);
+
+ if ((p = dt_zalloc(dtp, sizeof (dt_pq_t))) == NULL)
+ return (NULL);
+
+ p->dtpq_items = dt_zalloc(dtp, size * sizeof (p->dtpq_items[0]));
+ if (p->dtpq_items == NULL) {
+ dt_free(dtp, p);
+ return (NULL);
+ }
+
+ p->dtpq_hdl = dtp;
+ p->dtpq_size = size;
+ p->dtpq_last = 1;
+ p->dtpq_value = value_cb;
+ p->dtpq_arg = cb_arg;
+
+ return (p);
+}
+
+void
+dt_pq_fini(dt_pq_t *p)
+{
+ dtrace_hdl_t *dtp = p->dtpq_hdl;
+
+ dt_free(dtp, p->dtpq_items);
+ dt_free(dtp, p);
+}
+
+static uint64_t
+dt_pq_getvalue(dt_pq_t *p, uint_t index)
+{
+ void *item = p->dtpq_items[index];
+ return (p->dtpq_value(item, p->dtpq_arg));
+}
+
+void
+dt_pq_insert(dt_pq_t *p, void *item)
+{
+ uint_t i;
+
+ assert(p->dtpq_last < p->dtpq_size);
+
+ i = p->dtpq_last++;
+ p->dtpq_items[i] = item;
+
+ while (i > 1 && dt_pq_getvalue(p, i) < dt_pq_getvalue(p, i / 2)) {
+ void *tmp = p->dtpq_items[i];
+ p->dtpq_items[i] = p->dtpq_items[i / 2];
+ p->dtpq_items[i / 2] = tmp;
+ i /= 2;
+ }
+}
+
+/*
+ * Return elements from the priority queue. *cookie should be zero when first
+ * called. Returns NULL when there are no more elements.
+ */
+void *
+dt_pq_walk(dt_pq_t *p, uint_t *cookie)
+{
+ (*cookie)++;
+ if (*cookie >= p->dtpq_last)
+ return (NULL);
+
+ return (p->dtpq_items[*cookie]);
+}
+
+void *
+dt_pq_pop(dt_pq_t *p)
+{
+ uint_t i = 1;
+ void *ret;
+
+ assert(p->dtpq_last > 0);
+
+ if (p->dtpq_last == 1)
+ return (NULL);
+
+ ret = p->dtpq_items[1];
+
+ p->dtpq_last--;
+ p->dtpq_items[1] = p->dtpq_items[p->dtpq_last];
+ p->dtpq_items[p->dtpq_last] = NULL;
+
+ for (;;) {
+ uint_t lc = i * 2;
+ uint_t rc = i * 2 + 1;
+ uint_t c;
+ uint64_t v;
+ void *tmp;
+
+ if (lc >= p->dtpq_last)
+ break;
+
+ if (rc >= p->dtpq_last) {
+ c = lc;
+ v = dt_pq_getvalue(p, lc);
+ } else {
+ uint64_t lv = dt_pq_getvalue(p, lc);
+ uint64_t rv = dt_pq_getvalue(p, rc);
+
+ if (lv < rv) {
+ c = lc;
+ v = lv;
+ } else {
+ c = rc;
+ v = rv;
+ }
+ }
+
+ if (v >= dt_pq_getvalue(p, i))
+ break;
+
+ tmp = p->dtpq_items[i];
+ p->dtpq_items[i] = p->dtpq_items[c];
+ p->dtpq_items[c] = tmp;
+
+ i = c;
+ }
+
+ return (ret);
+}
diff --git a/usr/src/lib/libdtrace/common/dt_pq.h b/usr/src/lib/libdtrace/common/dt_pq.h
new file mode 100644
index 0000000000..8184a90c66
--- /dev/null
+++ b/usr/src/lib/libdtrace/common/dt_pq.h
@@ -0,0 +1,51 @@
+/*
+ * CDDL HEADER START
+ *
+ * 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.
+ *
+ * CDDL HEADER END
+ */
+
+/*
+ * Copyright (c) 2012 by Delphix. All rights reserved.
+ */
+
+#ifndef _DT_PQ_H
+#define _DT_PQ_H
+
+#include <dtrace.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef uint64_t (*dt_pq_value_f)(void *, void *);
+
+typedef struct dt_pq {
+ dtrace_hdl_t *dtpq_hdl; /* dtrace handle */
+ void **dtpq_items; /* array of elements */
+ uint_t dtpq_size; /* count of allocated elements */
+ uint_t dtpq_last; /* next free slot */
+ dt_pq_value_f dtpq_value; /* callback to get the value */
+ void *dtpq_arg; /* callback argument */
+} dt_pq_t;
+
+extern dt_pq_t *dt_pq_init(dtrace_hdl_t *, uint_t size, dt_pq_value_f, void *);
+extern void dt_pq_fini(dt_pq_t *);
+
+extern void dt_pq_insert(dt_pq_t *, void *);
+extern void *dt_pq_pop(dt_pq_t *);
+extern void *dt_pq_walk(dt_pq_t *, uint_t *);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _DT_PQ_H */
diff --git a/usr/src/lib/libdtrace/common/dt_printf.c b/usr/src/lib/libdtrace/common/dt_printf.c
index eabc42338b..8d96bd4c71 100644
--- a/usr/src/lib/libdtrace/common/dt_printf.c
+++ b/usr/src/lib/libdtrace/common/dt_printf.c
@@ -22,6 +22,7 @@
/*
* Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2011, Joyent, Inc. All rights reserved.
+ * Copyright (c) 2012 by Delphix. All rights reserved.
*/
#include <sys/sysmacros.h>
@@ -154,7 +155,7 @@ static int
pfcheck_dint(dt_pfargv_t *pfv, dt_pfargd_t *pfd, dt_node_t *dnp)
{
if (dnp->dn_flags & DT_NF_SIGNED)
- pfd->pfd_flags |= DT_PFCONV_SIGNED;
+ pfd->pfd_fmt[strlen(pfd->pfd_fmt) - 1] = 'i';
else
pfd->pfd_fmt[strlen(pfd->pfd_fmt) - 1] = 'u';
@@ -642,7 +643,7 @@ static const dt_pfconv_t _dtrace_conversions[] = {
{ "hu", "u", "unsigned short", pfcheck_type, pfprint_uint },
{ "hx", "x", "short", pfcheck_xshort, pfprint_uint },
{ "hX", "X", "short", pfcheck_xshort, pfprint_uint },
-{ "i", "i", pfproto_xint, pfcheck_dint, pfprint_dint },
+{ "i", "i", pfproto_xint, pfcheck_xint, pfprint_sint },
{ "I", "s", pfproto_cstr, pfcheck_str, pfprint_inetaddr },
{ "k", "s", "stack", pfcheck_stack, pfprint_stack },
{ "lc", "lc", "int", pfcheck_type, pfprint_sint }, /* a.k.a. wint_t */
diff --git a/usr/src/lib/libdtrace/common/dt_proc.c b/usr/src/lib/libdtrace/common/dt_proc.c
index 96e85f1bdb..03fe05f21f 100644
--- a/usr/src/lib/libdtrace/common/dt_proc.c
+++ b/usr/src/lib/libdtrace/common/dt_proc.c
@@ -25,6 +25,10 @@
*/
/*
+ * Copyright (c) 2012 by Delphix. All rights reserved.
+ */
+
+/*
* DTrace Process Control
*
* This file provides a set of routines that permit libdtrace and its clients
@@ -460,7 +464,7 @@ dt_proc_control(void *arg)
dt_proc_control_data_t *datap = arg;
dtrace_hdl_t *dtp = datap->dpcd_hdl;
dt_proc_t *dpr = datap->dpcd_proc;
- dt_proc_hash_t *dph = dpr->dpr_hdl->dt_procs;
+ dt_proc_hash_t *dph = dtp->dt_procs;
struct ps_prochandle *P = dpr->dpr_proc;
int pfd = Pctlfd(P);
@@ -870,7 +874,8 @@ dt_proc_create(dtrace_hdl_t *dtp, const char *file, char *const *argv)
(void) pthread_mutex_init(&dpr->dpr_lock, NULL);
(void) pthread_cond_init(&dpr->dpr_cv, NULL);
- if ((dpr->dpr_proc = Pcreate(file, argv, &err, NULL, 0)) == NULL) {
+ dpr->dpr_proc = Pxcreate(file, argv, dtp->dt_proc_env, &err, NULL, 0);
+ if (dpr->dpr_proc == NULL) {
return (dt_proc_error(dtp, dpr,
"failed to execute %s: %s\n", file, Pcreate_error(err)));
}
@@ -1034,30 +1039,75 @@ dt_proc_unlock(dtrace_hdl_t *dtp, struct ps_prochandle *P)
}
void
-dt_proc_hash_create(dtrace_hdl_t *dtp)
+dt_proc_init(dtrace_hdl_t *dtp)
{
+ extern char **environ;
+ static char *envdef[] = {
+ "LD_NOLAZYLOAD=1", /* linker lazy loading hides funcs */
+ NULL
+ };
+ char **p;
+ int i;
+
if ((dtp->dt_procs = dt_zalloc(dtp, sizeof (dt_proc_hash_t) +
- sizeof (dt_proc_t *) * _dtrace_pidbuckets - 1)) != NULL) {
+ sizeof (dt_proc_t *) * _dtrace_pidbuckets - 1)) == NULL)
+ return;
+
+ (void) pthread_mutex_init(&dtp->dt_procs->dph_lock, NULL);
+ (void) pthread_cond_init(&dtp->dt_procs->dph_cv, NULL);
+
+ dtp->dt_procs->dph_hashlen = _dtrace_pidbuckets;
+ dtp->dt_procs->dph_lrulim = _dtrace_pidlrulim;
- (void) pthread_mutex_init(&dtp->dt_procs->dph_lock, NULL);
- (void) pthread_cond_init(&dtp->dt_procs->dph_cv, NULL);
- dtp->dt_procs->dph_hashlen = _dtrace_pidbuckets;
- dtp->dt_procs->dph_lrulim = _dtrace_pidlrulim;
+ /*
+ * Count how big our environment needs to be.
+ */
+ for (i = 1, p = environ; *p != NULL; i++, p++)
+ continue;
+ for (p = envdef; *p != NULL; i++, p++)
+ continue;
+
+ if ((dtp->dt_proc_env = dt_zalloc(dtp, sizeof (char *) * i)) == NULL)
+ return;
+
+ for (i = 0, p = environ; *p != NULL; i++, p++) {
+ if ((dtp->dt_proc_env[i] = strdup(*p)) == NULL)
+ goto err;
}
+ for (p = envdef; *p != NULL; i++, p++) {
+ if ((dtp->dt_proc_env[i] = strdup(*p)) == NULL)
+ goto err;
+ }
+
+ return;
+
+err:
+ while (--i != 0) {
+ dt_free(dtp, dtp->dt_proc_env[i]);
+ }
+ dt_free(dtp, dtp->dt_proc_env);
+ dtp->dt_proc_env = NULL;
}
void
-dt_proc_hash_destroy(dtrace_hdl_t *dtp)
+dt_proc_fini(dtrace_hdl_t *dtp)
{
dt_proc_hash_t *dph = dtp->dt_procs;
dt_proc_t *dpr;
+ char **p;
while ((dpr = dt_list_next(&dph->dph_lrulist)) != NULL)
dt_proc_destroy(dtp, dpr->dpr_proc);
dtp->dt_procs = NULL;
dt_free(dtp, dph);
+
+ for (p = dtp->dt_proc_env; *p != NULL; p++)
+ dt_free(dtp, *p);
+
+ dt_free(dtp, dtp->dt_proc_env);
+ dtp->dt_proc_env = NULL;
}
struct ps_prochandle *
diff --git a/usr/src/lib/libdtrace/common/dt_proc.h b/usr/src/lib/libdtrace/common/dt_proc.h
index a3236694b2..599a0f9118 100644
--- a/usr/src/lib/libdtrace/common/dt_proc.h
+++ b/usr/src/lib/libdtrace/common/dt_proc.h
@@ -24,11 +24,13 @@
* Use is subject to license terms.
*/
+/*
+ * Copyright (c) 2012 by Delphix. All rights reserved.
+ */
+
#ifndef _DT_PROC_H
#define _DT_PROC_H
-#pragma ident "%Z%%M% %I% %E% SMI"
-
#include <libproc.h>
#include <dtrace.h>
#include <pthread.h>
@@ -106,8 +108,8 @@ extern void dt_proc_lock(dtrace_hdl_t *, struct ps_prochandle *);
extern void dt_proc_unlock(dtrace_hdl_t *, struct ps_prochandle *);
extern dt_proc_t *dt_proc_lookup(dtrace_hdl_t *, struct ps_prochandle *, int);
-extern void dt_proc_hash_create(dtrace_hdl_t *);
-extern void dt_proc_hash_destroy(dtrace_hdl_t *);
+extern void dt_proc_init(dtrace_hdl_t *);
+extern void dt_proc_fini(dtrace_hdl_t *);
#ifdef __cplusplus
}
diff --git a/usr/src/lib/libdtrace/common/dt_regset.c b/usr/src/lib/libdtrace/common/dt_regset.c
index 05cc15c912..0c747ed133 100644
--- a/usr/src/lib/libdtrace/common/dt_regset.c
+++ b/usr/src/lib/libdtrace/common/dt_regset.c
@@ -19,12 +19,15 @@
*
* CDDL HEADER END
*/
+
/*
* Copyright 2003 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
-#pragma ident "%Z%%M% %I% %E% SMI"
+/*
+ * Copyright (c) 2012 by Delphix. All rights reserved.
+ */
#include <sys/types.h>
#include <sys/bitmap.h>
@@ -33,18 +36,19 @@
#include <stdlib.h>
#include <dt_regset.h>
+#include <dt_impl.h>
dt_regset_t *
-dt_regset_create(ulong_t size)
+dt_regset_create(ulong_t nregs)
{
- ulong_t n = BT_BITOUL(size + 1); /* + 1 for %r0 */
+ ulong_t n = BT_BITOUL(nregs);
dt_regset_t *drp = malloc(sizeof (dt_regset_t));
if (drp == NULL)
return (NULL);
drp->dr_bitmap = malloc(sizeof (ulong_t) * n);
- drp->dr_size = size + 1;
+ drp->dr_size = nregs;
if (drp->dr_bitmap == NULL) {
dt_regset_destroy(drp);
@@ -68,6 +72,25 @@ dt_regset_reset(dt_regset_t *drp)
bzero(drp->dr_bitmap, sizeof (ulong_t) * BT_BITOUL(drp->dr_size));
}
+void
+dt_regset_assert_free(dt_regset_t *drp)
+{
+ int reg;
+ boolean_t fail = B_FALSE;
+ for (reg = 0; reg < drp->dr_size; reg++) {
+ if (BT_TEST(drp->dr_bitmap, reg) != 0) {
+ dt_dprintf("%%r%d was left allocated\n", reg);
+ fail = B_TRUE;
+ }
+ }
+
+ /*
+ * We set this during dtest runs to check for register leaks.
+ */
+ if (fail && getenv("DTRACE_DEBUG_REGSET") != NULL)
+ abort();
+}
+
int
dt_regset_alloc(dt_regset_t *drp)
{
@@ -95,13 +118,15 @@ dt_regset_alloc(dt_regset_t *drp)
}
}
- return (-1); /* no available registers */
+ xyerror(D_NOREG, "Insufficient registers to generate code");
+ /*NOTREACHED*/
+ return (-1);
}
void
dt_regset_free(dt_regset_t *drp, int reg)
{
- assert(reg > 0 && reg < drp->dr_size);
+ assert(reg >= 0 && reg < drp->dr_size);
assert(BT_TEST(drp->dr_bitmap, reg) != 0);
BT_CLEAR(drp->dr_bitmap, reg);
}
diff --git a/usr/src/lib/libdtrace/common/dt_regset.h b/usr/src/lib/libdtrace/common/dt_regset.h
index 25e64d048e..35082846d9 100644
--- a/usr/src/lib/libdtrace/common/dt_regset.h
+++ b/usr/src/lib/libdtrace/common/dt_regset.h
@@ -19,16 +19,19 @@
*
* CDDL HEADER END
*/
+
/*
* Copyright 2003 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
+/*
+ * Copyright (c) 2012 by Delphix. All rights reserved.
+ */
+
#ifndef _DT_REGSET_H
#define _DT_REGSET_H
-#pragma ident "%Z%%M% %I% %E% SMI"
-
#include <sys/types.h>
#ifdef __cplusplus
@@ -45,6 +48,7 @@ extern void dt_regset_destroy(dt_regset_t *);
extern void dt_regset_reset(dt_regset_t *);
extern int dt_regset_alloc(dt_regset_t *);
extern void dt_regset_free(dt_regset_t *, int);
+extern void dt_regset_assert_free(dt_regset_t *);
#ifdef __cplusplus
}
diff --git a/usr/src/lib/libdtrace/common/dt_subr.c b/usr/src/lib/libdtrace/common/dt_subr.c
index f586504cfb..25e206eb4c 100644
--- a/usr/src/lib/libdtrace/common/dt_subr.c
+++ b/usr/src/lib/libdtrace/common/dt_subr.c
@@ -21,6 +21,7 @@
/*
* Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012 by Delphix. All rights reserved.
*/
#include <sys/sysmacros.h>
@@ -577,8 +578,8 @@ dt_printf(dtrace_hdl_t *dtp, FILE *fp, const char *format, ...)
size_t avail;
/*
- * It's not legal to use buffered ouput if there is not a
- * handler for buffered output.
+ * Using buffered output is not allowed if a handler has
+ * not been installed.
*/
if (dtp->dt_bufhdlr == NULL) {
va_end(ap);
diff --git a/usr/src/lib/libdtrace/i386/dt_isadep.c b/usr/src/lib/libdtrace/i386/dt_isadep.c
index c1484a4074..d16b393f3d 100644
--- a/usr/src/lib/libdtrace/i386/dt_isadep.c
+++ b/usr/src/lib/libdtrace/i386/dt_isadep.c
@@ -24,6 +24,10 @@
* Use is subject to license terms.
*/
+/*
+ * Copyright (c) 2012 by Delphix. All rights reserved.
+ */
+
#include <stdlib.h>
#include <assert.h>
#include <errno.h>
@@ -481,7 +485,8 @@ dt_instr_size(uchar_t *instr, dtrace_hdl_t *dtp, pid_t pid, uintptr_t addr,
* another debugger attached to this process. The original instruction
* can't be recovered so this must fail.
*/
- if (x86dis.d86_len == 1 && instr[0] == FASTTRAP_INSTR)
+ if (x86dis.d86_len == 1 &&
+ (uchar_t)x86dis.d86_bytes[0] == FASTTRAP_INSTR)
return (-1);
return (x86dis.d86_len);
diff --git a/usr/src/lib/libidmap/common/idmap_api.c b/usr/src/lib/libidmap/common/idmap_api.c
index e3ae017357..7d7b754c40 100644
--- a/usr/src/lib/libidmap/common/idmap_api.c
+++ b/usr/src/lib/libidmap/common/idmap_api.c
@@ -20,6 +20,7 @@
*/
/*
* Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright Milan Jurik 2012. All rights reserved.
*/
@@ -65,17 +66,6 @@ static idmap_stat idmap_strdupnull(char **, const char *);
itera->limit = 1024;\
itera->arg = argu;
-
-#define __ITER_ERR_RETURN(itera, argu, xdr_argu, iretcod)\
- if (argu) {\
- xdr_free(xdr_argu, (caddr_t)argu);\
- free(argu);\
- }\
- if (itera)\
- free(itera);\
- return (iretcod);
-
-
#define __ITER_CHECK(itera, ityp)\
if (itera == NULL) {\
errno = EINVAL;\
@@ -606,8 +596,14 @@ idmap_iter_namerules(const char *windomain,
return (IDMAP_SUCCESS);
errout:
- __ITER_ERR_RETURN(tmpiter, arg,
- xdr_idmap_list_namerules_1_argument, retcode);
+ if (arg) {
+ xdr_free(xdr_idmap_list_namerules_1_argument, (char *)arg);
+ free(arg);
+ }
+ if (tmpiter)
+ free(tmpiter);
+
+ return (retcode);
}
diff --git a/usr/src/lib/libldap4/Makefile.com b/usr/src/lib/libldap4/Makefile.com
deleted file mode 100644
index a92ce1d5c3..0000000000
--- a/usr/src/lib/libldap4/Makefile.com
+++ /dev/null
@@ -1,113 +0,0 @@
-#
-# CDDL HEADER START
-#
-# The contents of this file are subject to the terms of the
-# Common Development and Distribution License (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 2006 Sun Microsystems, Inc. All rights reserved.
-# Use is subject to license terms.
-#
-# ident "%Z%%M% %I% %E% SMI"
-#
-
-LIBRARY= libldap.a
-VERS= .4
-
-LDAPOBJS= abandon.o getentry.o referral.o \
- add.o getfilter.o regex.o \
- addentry.o getmsg.o rename.o \
- bind.o getref.o request.o \
- cache.o getvalues.o result.o \
- charset.o kbind.o saslbind.o \
- cldap.o sbind.o compare.o \
- search.o controls.o sort.o \
- delete.o srchpref.o disptmpl.o \
- tmplout.o dsparse.o \
- error.o ufn.o \
- extensions.o unbind.o extop.o \
- url.o \
- free.o modify.o utils.o \
- friendly.o modrdn.o notif.o Version.o \
- getattr.o open.o \
- getdn.o option.o \
- getdxbyname.o os-ip.o sortctrl.o \
- vlistctrl.o
-
-BEROBJS= bprint.o decode.o \
- encode.o \
- io.o i18n.o
-
-UTILOBJS= line64.o log.o
-
-
-SECOBJS= cram_md5.o secutil.o
-
-OBJECTS= $(LDAPOBJS) $(BEROBJS) $(UTILOBJS) $(SECOBJS)
-
-include ../../Makefile.lib
-
-LDAPINC= $(SRC)/lib/libldap4/include
-LDAP_FLAGS= -DLDAP_REFERRALS -DCLDAP -DLDAP_DNS -DSUN
-
-SRCDIR = ../common
-SRCS= $(LDAPOBJS:%.o=../common/%.c) $(BEROBJS:%.o=../ber/%.c) \
- $(UTILOBJS:%.o=../util/%.c) $(SECOBJS:%.o=../sec/%.c)
-
-LIBS = $(DYNLIB)
-
-$(LINTLIB):= SRCS=../common/llib-lldap
-
-LINTSRC= $(LINTLIB:%.ln=%)
-ROOTLINTDIR= $(ROOTLIBDIR)
-ROOTLINT= $(LINTSRC:%=$(ROOTLINTDIR)/%)
-
-
-CLEANFILES += $(LINTOUT) $(LINTLIB)
-
-# Local Libldap definitions
-
-LOCFLAGS += -D_SYS_STREAM_H -D_REENTRANT -DSVR4 -DSUNW_OPTIONS \
- -DTHREAD_SUNOS5_LWP -DSOUNDEX -DSTR_TRANSLATION \
- $(LDAP_FLAGS) -I$(LDAPINC)
-
-CPPFLAGS = $(LOCFLAGS) $(CPPFLAGS.master)
-CFLAGS += $(CCVERBOSE)
-LDLIBS += -lsocket -lnsl -lresolv -lc -lmd
-
-.KEEP_STATE:
-
-lint: lintcheck
-
-# include library targets
-include ../../Makefile.targ
-
-objs/%.o pics/%.o: ../common/%.c
- $(COMPILE.c) -o $@ $<
- $(POST_PROCESS_O)
-
-objs/%.o pics/%.o: ../ber/%.c
- $(COMPILE.c) -o $@ $<
- $(POST_PROCESS_O)
-
-objs/%.o pics/%.o: ../util/%.c
- $(COMPILE.c) -o $@ $<
- $(POST_PROCESS_O)
-
-objs/%.o pics/%.o: ../sec/%.c
- $(COMPILE.c) -o $@ $<
- $(POST_PROCESS_O)
diff --git a/usr/src/lib/libldap4/THIRDPARTYLICENSE b/usr/src/lib/libldap4/THIRDPARTYLICENSE
deleted file mode 100644
index 4d9788ecde..0000000000
--- a/usr/src/lib/libldap4/THIRDPARTYLICENSE
+++ /dev/null
@@ -1,19 +0,0 @@
- * Copyright (c) 1991 Regents of the University of Michigan.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms are permitted
- * provided that this notice is preserved and that due credit is given
- * to the University of Michigan at Ann Arbor. The name of the University
- * may not be used to endorse or promote products derived from this
- * software without specific prior written permission. This software
- * is provided ``as is'' without express or implied warranty.
-
- * Copyright (c) 1994 Enrique Silvestre Mora, Universitat Jaume I, Spain.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms are permitted
- * provided that this notice is preserved and that due credit is given
- * to the Universitat Jaume I. The name of the University
- * may not be used to endorse or promote products derived from this
- * software without specific prior written permission. This software
- * is provided ``as is'' without express or implied warranty.
diff --git a/usr/src/lib/libldap4/THIRDPARTYLICENSE.descrip b/usr/src/lib/libldap4/THIRDPARTYLICENSE.descrip
deleted file mode 100644
index 676a38e4e7..0000000000
--- a/usr/src/lib/libldap4/THIRDPARTYLICENSE.descrip
+++ /dev/null
@@ -1 +0,0 @@
-LDAP4 LIBRARY
diff --git a/usr/src/lib/libldap4/ber/Version.c b/usr/src/lib/libldap4/ber/Version.c
deleted file mode 100644
index 7a984d75eb..0000000000
--- a/usr/src/lib/libldap4/ber/Version.c
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Portions Copyright 1998 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*
- * Copyright (c) 1991 Regents of the University of Michigan.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms are permitted
- * provided that this notice is preserved and that due credit is given
- * to the University of Michigan at Ann Arbor. The name of the University
- * may not be used to endorse or promote products derived from this
- * software without specific prior written permission. This software
- * is provided ``as is'' without express or implied warranty.
- */
-
-static char Version[] = " liblber.a v%VERSION% (%WHEN%)\n\t%WHOANDWHERE%\n";
diff --git a/usr/src/lib/libldap4/ber/bprint.c b/usr/src/lib/libldap4/ber/bprint.c
deleted file mode 100644
index 05923b7ded..0000000000
--- a/usr/src/lib/libldap4/ber/bprint.c
+++ /dev/null
@@ -1,67 +0,0 @@
-/*
- * Portions Copyright 1998 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#include <stdio.h>
-#include <string.h>
-#include <ctype.h>
-#include "lber.h"
-
-/*
- * Print arbitrary stuff, for debugging.
- */
-
-#ifdef LDAP_DEBUG
-
-#ifndef NO_USERINTERFACE
-#define BPLEN 48
-
-void
-lber_bprint( char *data, int len )
-{
- static char hexdig[] = "0123456789abcdef";
- char out[ BPLEN ];
- int i = 0;
-
- (void) memset( out, 0, BPLEN );
- for ( ;; ) {
- if ( len < 1 ) {
- (void) fprintf( stderr, "\t%s\n", ( i == 0 ) ? catgets(slapdcat, 1, 72, "(end)") : out );
- break;
- }
-
-#ifndef HEX
- if ( isgraph( (unsigned char)*data )) {
- out[ i ] = ' ';
- out[ i+1 ] = *data;
- } else {
-#endif
- out[ i ] = hexdig[ ( *data & 0xf0 ) >> 4 ];
- out[ i+1 ] = hexdig[ *data & 0x0f ];
-#ifndef HEX
- }
-#endif
- i += 2;
- len--;
- data++;
-
- if ( i > BPLEN - 2 ) {
- (void) fprintf( stderr, "\t%s\n", out );
- (void) memset( out, 0, BPLEN );
- i = 0;
- continue;
- }
- out[ i++ ] = ' ';
- }
-}
-#else /* NO_USERINTERFACE */
-void
-lber_bprint( char *data, int len )
-{
-}
-#endif /* NO_USERINTERFACE */
-
-#endif
diff --git a/usr/src/lib/libldap4/ber/decode.c b/usr/src/lib/libldap4/ber/decode.c
deleted file mode 100644
index 5117b3249a..0000000000
--- a/usr/src/lib/libldap4/ber/decode.c
+++ /dev/null
@@ -1,630 +0,0 @@
-/*
- * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/* decode.c - ber input decoding routines */
-/*
- * Copyright (c) 1990 Regents of the University of Michigan.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms are permitted
- * provided that this notice is preserved and that due credit is given
- * to the University of Michigan at Ann Arbor. The name of the University
- * may not be used to endorse or promote products derived from this
- * software without specific prior written permission. This software
- * is provided ``as is'' without express or implied warranty.
- */
-
-#include <stdio.h>
-#ifdef MACOS
-#include <stdlib.h>
-#include <stdarg.h>
-#include "macos.h"
-#else /* MACOS */
-#if defined(NeXT) || defined(VMS)
-#include <stdlib.h>
-#else /* next || vms */
-#include <malloc.h>
-#endif /* next || vms */
-#if defined(BC31) || defined(_WIN32) || defined(__sun)
-#include <stdarg.h>
-#else /* BC31 || _WIN32 */
-#include <varargs.h>
-#endif /* BC31 || _WIN32 */
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#ifdef PCNFS
-#include <tklib.h>
-#endif /* PCNFS */
-#endif /* MACOS */
-
-#if defined( DOS ) || defined( _WIN32 )
-#include "msdos.h"
-#endif /* DOS */
-
-#include <string.h>
-#include "lber.h"
-#include "ldap.h"
-#include "ldap-private.h"
-#include "ldap-int.h"
-
-#ifdef LDAP_DEBUG
-int lber_debug;
-#endif
-
-#ifdef NEEDPROTOS
-static int ber_getnint( BerElement *ber, int *num, int len );
-#endif /* NEEDPROTOS */
-
-
-/* return the tag - LBER_DEFAULT returned means trouble */
-unsigned int
-ber_get_tag( BerElement *ber )
-{
- unsigned char xbyte;
- unsigned int tag;
- char *tagp;
- int i;
-
- if ( ber_read( ber, (char *) &xbyte, 1 ) != 1 )
- return( LBER_DEFAULT );
-
- if ( (xbyte & LBER_BIG_TAG_MASK) != LBER_BIG_TAG_MASK )
- return( (unsigned int) xbyte );
-
- tagp = (char *) &tag;
- tagp[0] = xbyte;
- for ( i = 1; i < sizeof(int); i++ ) {
- if ( ber_read( ber, (char *) &xbyte, 1 ) != 1 )
- return( LBER_DEFAULT );
-
- tagp[i] = xbyte;
-
- if ( ! (xbyte & LBER_MORE_TAG_MASK) )
- break;
- }
-
- /* tag too big! */
- if ( i == sizeof(int) )
- return( LBER_DEFAULT );
-
- /* want leading, not trailing 0's */
- return( tag >> (sizeof(int) - i - 1) );
-}
-
-unsigned int
-ber_skip_tag( BerElement *ber, unsigned int *len )
-{
- unsigned int tag;
- unsigned char lc;
- int noctets, diff;
- unsigned int netlen;
-
- /*
- * Any ber element looks like this: tag length contents.
- * Assuming everything's ok, we return the tag byte (we
- * can assume a single byte), and return the length in len.
- *
- * Assumptions:
- * 1) definite lengths
- * 2) primitive encodings used whenever possible
- */
-
- /*
- * First, we read the tag.
- */
-
- if ( (tag = ber_get_tag( ber )) == LBER_DEFAULT )
- return( LBER_DEFAULT );
-
- /*
- * Next, read the length. The first byte contains the length of
- * the length. If bit 8 is set, the length is the int form,
- * otherwise it's the short form. We don't allow a length that's
- * greater than what we can hold in an unsigned int.
- */
-
- *len = netlen = 0;
- if ( ber_read( ber, (char *) &lc, 1 ) != 1 )
- return( LBER_DEFAULT );
- if ( lc & 0x80 ) {
- noctets = (lc & 0x7f);
- if ( noctets > sizeof(unsigned int) )
- return( LBER_DEFAULT );
- diff = (int)sizeof(unsigned int) - noctets;
- if ( ber_read( ber, (char *) &netlen + diff, noctets )
- != noctets )
- return( LBER_DEFAULT );
- *len = LBER_NTOHL( netlen );
- } else {
- *len = lc;
- }
-
- return( tag );
-}
-
-unsigned int
-ber_peek_tag( BerElement *ber, unsigned int *len )
-{
- char *save;
- unsigned int tag;
-
- save = ber->ber_ptr;
- tag = ber_skip_tag( ber, len );
- ber->ber_ptr = save;
-
- return( tag );
-}
-
-static int
-ber_getnint( BerElement *ber, int *num, int len )
-{ /* New patch much cleaner, from David Wilson, Isode. Old code not kept*/
- int i;
- unsigned char buffer[sizeof(int)];
- int value;
-
- /*
- * The tag and length have already been stripped off. We should
- * be sitting right before len bytes of 2's complement integer,
- * ready to be read straight into an int.
- */
-
- if ( len > sizeof(int) )
- return( -1 );
-
- if ( ber_read( ber, (char *) buffer, len ) != len )
- return( -1 );
-
- /* This sets the required sign extension */
- value = 0x80 & buffer[0] ? (-1) : 0;
-
- for ( i = 0; i < len; i++ )
- value = (value << 8) | buffer[i];
-
- *num = value;
-
- return( len );
-}
-
-unsigned int
-ber_get_int( BerElement *ber, int *num )
-{
- unsigned int tag, len;
-
- if ( (tag = ber_skip_tag( ber, &len )) == LBER_DEFAULT )
- return( LBER_DEFAULT );
-
- if ( ber_getnint( ber, num, (int)len ) != len )
- return( LBER_DEFAULT );
- else
- return( tag );
-}
-
-unsigned int
-ber_get_stringb( BerElement *ber, char *buf, unsigned int *len )
-{
- unsigned int datalen, tag;
-#ifdef STR_TRANSLATION
- char *transbuf;
-#endif /* STR_TRANSLATION */
-
- if ( (tag = ber_skip_tag( ber, &datalen )) == LBER_DEFAULT )
- return( LBER_DEFAULT );
- if ( datalen > (*len - 1) )
- return( LBER_DEFAULT );
-
- if ( ber_read( ber, buf, datalen ) != datalen )
- return( LBER_DEFAULT );
-
- buf[datalen] = '\0';
-
-#ifdef STR_TRANSLATION
- if ( datalen > 0 && ( ber->ber_options & LBER_TRANSLATE_STRINGS ) != 0
- && ber->ber_decode_translate_proc != NULL ) {
- transbuf = buf;
- ++datalen;
- if ( (*(ber->ber_decode_translate_proc))( &transbuf, &datalen,
- 0 ) != 0 ) {
- return( LBER_DEFAULT );
- }
- if ( datalen > *len ) {
- free( transbuf );
- return( LBER_DEFAULT );
- }
- (void) SAFEMEMCPY( buf, transbuf, datalen );
- free( transbuf );
- --datalen;
- }
-#endif /* STR_TRANSLATION */
-
- *len = datalen;
- return( tag );
-}
-
-unsigned int
-ber_get_stringa( BerElement *ber, char **buf )
-{
- unsigned int datalen, tag;
-
- if ( (tag = ber_skip_tag( ber, &datalen )) == LBER_DEFAULT )
- return( LBER_DEFAULT );
-
- if ( (*buf = (char *) malloc( (size_t)datalen + 1 )) == NULL )
- return( LBER_DEFAULT );
-
- if ( ber_read( ber, *buf, datalen ) != datalen )
- return( LBER_DEFAULT );
- (*buf)[datalen] = '\0';
-
-#ifdef STR_TRANSLATION
- if ( datalen > 0 && ( ber->ber_options & LBER_TRANSLATE_STRINGS ) != 0
- && ber->ber_decode_translate_proc != NULL ) {
- ++datalen;
- if ( (*(ber->ber_decode_translate_proc))( buf, &datalen, 1 )
- != 0 ) {
- free( *buf );
- return( LBER_DEFAULT );
- }
- }
-#endif /* STR_TRANSLATION */
-
- return( tag );
-}
-
-unsigned int
-ber_get_stringal( BerElement *ber, struct berval **bv )
-{
- unsigned int len, tag;
-
- if ( (*bv = (struct berval *) malloc( sizeof(struct berval) )) == NULL )
- return( LBER_DEFAULT );
-
- if ( (tag = ber_skip_tag( ber, &len )) == LBER_DEFAULT )
- return( LBER_DEFAULT );
-
- if ( ((*bv)->bv_val = (char *) malloc( (size_t)len + 1 )) == NULL )
- return( LBER_DEFAULT );
-
- if ( ber_read( ber, (*bv)->bv_val, len ) != len )
- return( LBER_DEFAULT );
- ((*bv)->bv_val)[len] = '\0';
- (*bv)->bv_len = len;
-
-#ifdef STR_TRANSLATION
- if ( len > 0 && ( ber->ber_options & LBER_TRANSLATE_STRINGS ) != 0
- && ber->ber_decode_translate_proc != NULL ) {
- ++len;
- if ( (*(ber->ber_decode_translate_proc))( &((*bv)->bv_val),
- &len, 1 ) != 0 ) {
- free( (*bv)->bv_val );
- return( LBER_DEFAULT );
- }
- (*bv)->bv_len = len - 1;
- }
-#endif /* STR_TRANSLATION */
-
- return( tag );
-}
-
-unsigned int
-ber_get_bitstringa( BerElement *ber, char **buf, unsigned int *blen )
-{
- unsigned int datalen, tag;
- unsigned char unusedbits;
-
- if ( (tag = ber_skip_tag( ber, &datalen )) == LBER_DEFAULT )
- return( LBER_DEFAULT );
- --datalen;
-
- if ( (*buf = (char *) malloc( (size_t)datalen )) == NULL )
- return( LBER_DEFAULT );
-
- if ( ber_read( ber, (char *)&unusedbits, 1 ) != 1 )
- return( LBER_DEFAULT );
-
- if ( ber_read( ber, *buf, datalen ) != datalen )
- return( LBER_DEFAULT );
-
- *blen = datalen * 8 - unusedbits;
- return( tag );
-}
-
-unsigned int
-ber_get_null( BerElement *ber )
-{
- unsigned int len, tag;
-
- if ( (tag = ber_skip_tag( ber, &len )) == LBER_DEFAULT )
- return( LBER_DEFAULT );
-
- if ( len != 0 )
- return( LBER_DEFAULT );
-
- return( tag );
-}
-
-unsigned int
-ber_get_boolean( BerElement *ber, int *boolval )
-{
- int longbool;
- int rc;
-
- rc = ber_get_int( ber, &longbool );
- *boolval = longbool;
-
- return( rc );
-}
-
-unsigned int
-ber_first_element( BerElement *ber, unsigned int *len, char **last )
-{
- /* skip the sequence header, use the len to mark where to stop */
- if ( ber_skip_tag( ber, len ) == LBER_DEFAULT ) {
- return( LBER_DEFAULT );
- }
-
- *last = ber->ber_ptr + *len;
-
- if ( *last == ber->ber_ptr ) {
- return( LBER_DEFAULT );
- }
-
- return( ber_peek_tag( ber, len ) );
-}
-
-unsigned int
-ber_next_element( BerElement *ber, unsigned int *len, char *last )
-{
- if ( ber->ber_ptr == last ) {
- return( LBER_DEFAULT );
- }
-
- return( ber_peek_tag( ber, len ) );
-}
-
-/* VARARGS */
-unsigned int
-ber_scanf(
-#if defined(MACOS) || defined(BC31) || defined(_WIN32) || defined(__sun)
- BerElement *ber, char *fmt, ... )
-#else
- va_alist )
-va_dcl
-#endif
-{
- va_list ap;
-#if !defined(MACOS) && !defined(BC31) && !defined(_WIN32) && !defined(__sun)
- BerElement *ber;
- char *fmt;
-#endif
- char *last;
- char *s, **ss, ***sss;
- struct berval ***bv, **bvp, *bval;
- int *i, j;
- int *l, rc, tag;
- unsigned int len;
-
-#if defined(MACOS) || defined(BC31) || defined(_WIN32) || defined(__sun)
- va_start( ap, fmt );
-#else
- va_start( ap );
- ber = va_arg( ap, BerElement * );
- fmt = va_arg( ap, char * );
-#endif
-
-#ifdef LDAP_DEBUG
- if ( lber_debug & 64 ) {
- (void) fprintf( stderr, catgets(slapdcat, 1, 73, "ber_scanf fmt (%s) ber:\n"), fmt );
- ber_dump( ber, 1 );
- }
-#endif
-
- for ( rc = 0; *fmt && rc != LBER_DEFAULT; fmt++ ) {
- switch ( *fmt ) {
- case 'a': /* octet string - allocate storage as needed */
- ss = va_arg( ap, char ** );
- rc = ber_get_stringa( ber, ss );
- break;
-
- case 'b': /* boolean */
- i = va_arg( ap, int * );
- rc = ber_get_boolean( ber, i );
- break;
-
- case 'e': /* enumerated */
- case 'i': /* int */
- l = va_arg( ap, int * );
- rc = ber_get_int( ber, l );
- break;
-
- case 'l': /* length of next item */
- l = va_arg( ap, int * );
- rc = ber_peek_tag( ber, (unsigned int *)l );
- break;
-
- case 'n': /* null */
- rc = ber_get_null( ber );
- break;
-
- case 's': /* octet string - in a buffer */
- s = va_arg( ap, char * );
- l = va_arg( ap, int * );
- rc = ber_get_stringb( ber, s, (unsigned int *)l );
- break;
-
- case 'o': /* octet string in a supplied berval */
- bval = va_arg( ap, struct berval * );
- ber_peek_tag( ber, &bval->bv_len );
- rc = ber_get_stringa( ber, &bval->bv_val );
- break;
-
- case 'O': /* octet string - allocate & include length */
- bvp = va_arg( ap, struct berval ** );
- rc = ber_get_stringal( ber, bvp );
- break;
-
- case 'B': /* bit string - allocate storage as needed */
- ss = va_arg( ap, char ** );
- l = va_arg( ap, int * ); /* for length, in bits */
- rc = ber_get_bitstringa( ber, ss, (unsigned int *)l );
- break;
-
- case 't': /* tag of next item */
- i = va_arg( ap, int * );
- *i = rc = ber_peek_tag( ber, &len );
- break;
-
- case 'T': /* skip tag of next item */
- i = va_arg( ap, int * );
- *i = rc = ber_skip_tag( ber, &len );
- break;
-
- case 'v': /* sequence of strings */
- sss = va_arg( ap, char *** );
- *sss = NULL;
- j = 0;
- for ( tag = ber_first_element( ber, &len, &last );
- tag != LBER_DEFAULT && rc != LBER_DEFAULT;
- tag = ber_next_element( ber, &len, last ) ) {
- if ( *sss == NULL ) {
- *sss = (char **) malloc(
- 2 * sizeof(char *) );
- } else {
- *sss = (char **) realloc( *sss,
- (j + 2) * sizeof(char *) );
- }
- rc = ber_get_stringa( ber, &((*sss)[j]) );
- j++;
- }
- if ( j > 0 )
- (*sss)[j] = NULL;
- break;
-
- case 'V': /* sequence of strings + lengths */
- bv = va_arg( ap, struct berval *** );
- *bv = NULL;
- j = 0;
- for ( tag = ber_first_element( ber, &len, &last );
- tag != LBER_DEFAULT && rc != LBER_DEFAULT;
- tag = ber_next_element( ber, &len, last ) ) {
- if ( *bv == NULL ) {
- *bv = (struct berval **) malloc(
- 2 * sizeof(struct berval *) );
- } else {
- *bv = (struct berval **) realloc( *bv,
- (j + 2) * sizeof(struct berval *) );
- }
- rc = ber_get_stringal( ber, &((*bv)[j]) );
- j++;
- }
- if ( j > 0 )
- (*bv)[j] = NULL;
- break;
-
- case 'x': /* skip the next element - whatever it is */
- if ( (rc = ber_skip_tag( ber, &len )) == LBER_DEFAULT )
- break;
- ber->ber_ptr += len;
- break;
-
- case '{': /* begin sequence */
- case '[': /* begin set */
- if ( *(fmt + 1) != 'v' && *(fmt + 1) != 'V' )
- rc = ber_skip_tag( ber, &len );
- break;
-
- case '}': /* end sequence */
- case ']': /* end set */
- break;
-
- default:
-#ifndef NO_USERINTERFACE
- (void) fprintf( stderr, catgets(slapdcat, 1, 74, "unknown fmt %c\n"), *fmt );
-#endif /* NO_USERINTERFACE */
- rc = (int) LBER_DEFAULT;
- break;
- }
- }
-
- va_end( ap );
-
- return( rc );
-}
-
-void
-ber_bvfree( struct berval *bv )
-{
- if ( bv->bv_val != NULL )
- free( bv->bv_val );
- free( (char *) bv );
-}
-
-void
-ber_bvecfree( struct berval **bv )
-{
- int i;
-
- for ( i = 0; bv[i] != NULL; i++ )
- ber_bvfree( bv[i] );
- free( (char *) bv );
-}
-
-struct berval *
-ber_bvdup( struct berval *bv )
-{
- struct berval *new;
-
- if ( (new = (struct berval *) malloc( sizeof(struct berval) ))
- == NULL ) {
- return( NULL );
- }
- if ( (new->bv_val = (char *) malloc( bv->bv_len + 1 )) == NULL ) {
- free(new);
- return( NULL );
- }
- SAFEMEMCPY( new->bv_val, bv->bv_val, (size_t) bv->bv_len );
- new->bv_val[bv->bv_len] = '\0';
- new->bv_len = bv->bv_len;
-
- return( new );
-}
-
-
-#ifdef STR_TRANSLATION
-void
-ber_set_string_translators( BerElement *ber, BERTranslateProc encode_proc,
- BERTranslateProc decode_proc )
-{
- ber->ber_encode_translate_proc = encode_proc;
- ber->ber_decode_translate_proc = decode_proc;
-}
-#endif /* STR_TRANSLATION */
-
-int ber_flatten(BerElement *ber, struct berval **bvPtr)
-{
- struct berval * bv;
- int len;
-
- if ((ber == NULL) || (ber->ber_buf == NULL))
- return (-1);
-
- len = ber->ber_ptr - ber->ber_buf;
-
- if ((bv = (struct berval *)malloc(sizeof(struct berval))) == NULL)
- return (-1);
- if ((bv->bv_val = (char *) malloc(len + 1)) == NULL) {
- free(bv);
- return (-1);
- }
-
- SAFEMEMCPY(bv->bv_val, ber->ber_buf, (size_t)len);
- bv->bv_val[len] = '\0';
- bv->bv_len = len;
-
- *bvPtr = bv;
- return (0);
-}
diff --git a/usr/src/lib/libldap4/ber/encode.c b/usr/src/lib/libldap4/ber/encode.c
deleted file mode 100644
index f296d52053..0000000000
--- a/usr/src/lib/libldap4/ber/encode.c
+++ /dev/null
@@ -1,658 +0,0 @@
-/*
- * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/* encode.c - ber output encoding routines */
-/*
- * Copyright (c) 1990 Regents of the University of Michigan.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms are permitted
- * provided that this notice is preserved and that due credit is given
- * to the University of Michigan at Ann Arbor. The name of the University
- * may not be used to endorse or promote products derived from this
- * software without specific prior written permission. This software
- * is provided ``as is'' without express or implied warranty.
- */
-
-#include <stdio.h>
-#ifdef MACOS
-#include <stdlib.h>
-#include <stdarg.h>
-#include "macos.h"
-#else /* MACOS */
-#if defined(NeXT) || defined(VMS)
-#include <stdlib.h>
-#else /* next || vms */
-#include <malloc.h>
-#endif /* next || vms */
-#if defined( BC31 ) || defined( _WIN32 ) || defined(__sun)
-#include <stdarg.h>
-#else /* BC31 || _WIN32 */
-#include <varargs.h>
-#endif /* BC31 || _WIN32 */
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#ifdef PCNFS
-#include <tklib.h>
-#endif /* PCNFS */
-#endif /* MACOS */
-#ifndef VMS
-#include <memory.h>
-#endif
-#include <string.h>
-#include "lber.h"
-#include "ldap.h"
-#include "ldap-private.h"
-#include "ldap-int.h"
-
-#if defined( DOS ) || defined( _WIN32 )
-#include "msdos.h"
-#endif /* DOS */
-
-#ifdef NEEDPROTOS
-static int ber_put_len( BerElement *ber, unsigned int len, int nosos );
-static int ber_start_seqorset( BerElement *ber, unsigned int tag );
-static int ber_put_seqorset( BerElement *ber );
-static int ber_put_int_or_enum( BerElement *ber, int num, unsigned int tag );
-#endif /* NEEDPROTOS */
-
-extern int ber_realloc(BerElement *ber, unsigned int len);
-
-static int
-ber_calc_taglen( unsigned int tag )
-{
- int i;
- int mask;
-
- /* find the first non-all-zero byte in the tag */
- for ( i = sizeof(int) - 1; i > 0; i-- ) {
- mask = (0xffL << (i * 8));
- /* not all zero */
- if ( tag & mask )
- break;
- }
-
- return( i + 1 );
-}
-
-static int
-ber_put_tag( BerElement *ber, unsigned int tag, int nosos )
-{
- int taglen;
- unsigned int ntag;
-
- taglen = ber_calc_taglen( tag );
-
- ntag = LBER_HTONL( tag );
-
- return( ber_write( ber, ((char *) &ntag) + sizeof(int) - taglen,
- taglen, nosos ) );
-}
-
-static int
-ber_calc_lenlen( unsigned int len )
-{
- /*
- * short len if it's less than 128 - one byte giving the len,
- * with bit 8 0.
- */
-
- if ( len <= 0x7F )
- return( 1 );
-
- /*
- * int len otherwise - one byte with bit 8 set, giving the
- * length of the length, followed by the length itself.
- */
-
- if ( len <= 0xFF )
- return( 2 );
- if ( len <= 0xFFFF )
- return( 3 );
- if ( len <= 0xFFFFFF )
- return( 4 );
-
- return( 5 );
-}
-
-static int
-ber_put_len( BerElement *ber, unsigned int len, int nosos )
-{
- int i;
- char lenlen;
- int mask;
- unsigned int netlen;
-
- /*
- * short len if it's less than 128 - one byte giving the len,
- * with bit 8 0.
- */
-
- if ( len <= 127 ) {
- netlen = LBER_HTONL( len );
- return( ber_write( ber, (char *) &netlen + sizeof(int) - 1,
- 1, nosos ) );
- }
-
- /*
- * int len otherwise - one byte with bit 8 set, giving the
- * length of the length, followed by the length itself.
- */
-
- /* find the first non-all-zero byte */
- for ( i = sizeof(int) - 1; i > 0; i-- ) {
- mask = (0xff << (i * 8));
- /* not all zero */
- if ( len & mask )
- break;
- }
- lenlen = ++i;
- if ( lenlen > 4 )
- return( -1 );
- lenlen |= 0x80;
-
- /* write the length of the length */
- if ( ber_write( ber, &lenlen, 1, nosos ) != 1 )
- return( -1 );
-
- /* write the length itself */
- netlen = LBER_HTONL( len );
- if ( ber_write( ber, (char *) &netlen + (sizeof(int) - i), i, nosos )
- != i )
- return( -1 );
-
- return( i + 1 );
-}
-
-static int
-ber_put_int_or_enum( BerElement *ber, int num, unsigned int tag )
-{
- int i, sign, taglen;
- int len, lenlen;
- int netnum, mask;
-
- sign = (num < 0);
-
- /*
- * high bit is set - look for first non-all-one byte
- * high bit is clear - look for first non-all-zero byte
- */
- for ( i = sizeof(int) - 1; i > 0; i-- ) {
- mask = (0xff << (i * 8));
-
- if ( sign ) {
- /* not all ones */
- if ( (num & mask) != mask )
- break;
- } else {
- /* not all zero */
- if ( num & mask )
- break;
- }
- }
-
- /*
- * we now have the "leading byte". if the high bit on this
- * byte matches the sign bit, we need to "back up" a byte.
- */
- mask = (num & (0x80 << (i * 8)));
- if ( (mask && !sign) || (sign && !mask) )
- i++;
-
- len = i + 1;
-
- if ( (taglen = ber_put_tag( ber, tag, 0 )) == -1 )
- return( -1 );
-
- if ( (lenlen = ber_put_len( ber, len, 0 )) == -1 )
- return( -1 );
- i++;
- netnum = LBER_HTONL( num );
- if ( ber_write( ber, (char *) &netnum + (sizeof(int) - i), i, 0 )
- != i )
- return( -1 );
-
- /* length of tag + length + contents */
- return( taglen + lenlen + i );
-}
-
-int
-ber_put_enum( BerElement *ber, int num, unsigned int tag )
-{
- if ( tag == LBER_DEFAULT )
- tag = LBER_ENUMERATED;
-
- return( ber_put_int_or_enum( ber, num, tag ) );
-}
-
-int
-ber_put_int( BerElement *ber, int num, unsigned int tag )
-{
- if ( tag == LBER_DEFAULT )
- tag = LBER_INTEGER;
-
- return( ber_put_int_or_enum( ber, num, tag ) );
-}
-
-int
-ber_put_ostring( BerElement *ber, char *str, unsigned int len,
- unsigned int tag )
-{
- int taglen, lenlen, rc;
-#ifdef STR_TRANSLATION
- int free_str;
-#endif /* STR_TRANSLATION */
-
- if ( tag == LBER_DEFAULT )
- tag = LBER_OCTETSTRING;
-
- if ( (taglen = ber_put_tag( ber, tag, 0 )) == -1 )
- return( -1 );
-
-#ifdef STR_TRANSLATION
- if ( len > 0 && ( ber->ber_options & LBER_TRANSLATE_STRINGS ) != 0 &&
- ber->ber_encode_translate_proc != NULL ) {
- if ( (*(ber->ber_encode_translate_proc))( &str, &len, 0 )
- != 0 ) {
- return( -1 );
- }
- free_str = 1;
- } else {
- free_str = 0;
- }
-#endif /* STR_TRANSLATION */
-
- if ( (lenlen = ber_put_len( ber, len, 0 )) == -1 ||
- ber_write( ber, str, len, 0 ) != len ) {
- rc = -1;
- } else {
- /* return length of tag + length + contents */
- rc = taglen + lenlen + len;
- }
-
-#ifdef STR_TRANSLATION
- if ( free_str ) {
- free( str );
- }
-#endif /* STR_TRANSLATION */
-
- return( rc );
-}
-
-int
-ber_put_string( BerElement *ber, char *str, unsigned int tag )
-{
- return( ber_put_ostring( ber, str, (unsigned int)strlen( str ), tag ));
-}
-
-int
-ber_put_bitstring( BerElement *ber, char *str,
- unsigned int blen /* in bits */, unsigned int tag )
-{
- int taglen, lenlen, len;
- unsigned char unusedbits;
-
- if ( tag == LBER_DEFAULT )
- tag = LBER_BITSTRING;
-
- if ( (taglen = ber_put_tag( ber, tag, 0 )) == -1 )
- return( -1 );
-
- len = ( blen + 7 ) / 8;
- unusedbits = len * 8 - blen;
- if ( (lenlen = ber_put_len( ber, len + 1, 0 )) == -1 )
- return( -1 );
-
- if ( ber_write( ber, (char *)&unusedbits, 1, 0 ) != 1 )
- return( -1 );
-
- if ( ber_write( ber, str, len, 0 ) != len )
- return( -1 );
-
- /* return length of tag + length + unused bit count + contents */
- return( taglen + 1 + lenlen + len );
-}
-
-int
-ber_put_null( BerElement *ber, unsigned int tag )
-{
- int taglen;
-
- if ( tag == LBER_DEFAULT )
- tag = LBER_NULL;
-
- if ( (taglen = ber_put_tag( ber, tag, 0 )) == -1 )
- return( -1 );
-
- if ( ber_put_len( ber, 0, 0 ) != 1 )
- return( -1 );
-
- return( taglen + 1 );
-}
-
-int
-ber_put_boolean( BerElement *ber, int boolval, unsigned int tag )
-{
- int taglen;
- unsigned char trueval = 0xff;
- unsigned char falseval = 0x00;
-
- if ( tag == LBER_DEFAULT )
- tag = LBER_BOOLEAN;
-
- if ( (taglen = ber_put_tag( ber, tag, 0 )) == -1 )
- return( -1 );
-
- if ( ber_put_len( ber, 1, 0 ) != 1 )
- return( -1 );
-
- if ( ber_write( ber, (char *)(boolval ? &trueval : &falseval), 1, 0 )
- != 1 )
- return( -1 );
-
- return( taglen + 2 );
-}
-
-#define FOUR_BYTE_LEN 5
-
-static int
-ber_start_seqorset( BerElement *ber, unsigned int tag )
-{
- Seqorset *new;
-
- if ( (new = (Seqorset *) calloc( sizeof(Seqorset), 1 ))
- == NULLSEQORSET )
- return( -1 );
- new->sos_ber = ber;
- if ( ber->ber_sos == NULLSEQORSET )
- new->sos_first = ber->ber_ptr;
- else
- new->sos_first = ber->ber_sos->sos_ptr;
-
- /* Set aside room for a 4 byte length field */
- new->sos_ptr = new->sos_first + ber_calc_taglen( tag ) + FOUR_BYTE_LEN;
- new->sos_tag = tag;
-
- new->sos_next = ber->ber_sos;
- ber->ber_sos = new;
- if (ber->ber_sos->sos_ptr > ber->ber_end)
- ber_realloc(ber, ber->ber_sos->sos_ptr - ber->ber_end);
-
- return( 0 );
-}
-
-int
-ber_start_seq( BerElement *ber, unsigned int tag )
-{
- if ( tag == LBER_DEFAULT )
- tag = LBER_SEQUENCE;
-
- return( ber_start_seqorset( ber, tag ) );
-}
-
-int
-ber_start_set( BerElement *ber, unsigned int tag )
-{
- if ( tag == LBER_DEFAULT )
- tag = LBER_SET;
-
- return( ber_start_seqorset( ber, tag ) );
-}
-
-static int
-ber_put_seqorset( BerElement *ber )
-{
- unsigned int len, netlen;
- int taglen, lenlen;
- unsigned char ltag = 0x80 + FOUR_BYTE_LEN - 1;
- Seqorset *next;
- Seqorset **sos = &ber->ber_sos;
-
- /*
- * If this is the toplevel sequence or set, we need to actually
- * write the stuff out. Otherwise, it's already been put in
- * the appropriate buffer and will be written when the toplevel
- * one is written. In this case all we need to do is update the
- * length and tag.
- */
-
- len = (*sos)->sos_clen;
- netlen = LBER_HTONL( len );
- /* CONSTCOND */
- if ( sizeof(int) > 4 && len > 0xFFFFFFFF )
- return( -1 );
-
- if ( ber->ber_options & LBER_USE_DER ) {
- lenlen = ber_calc_lenlen( len );
- } else {
- lenlen = FOUR_BYTE_LEN;
- }
-
- if ( (next = (*sos)->sos_next) == NULLSEQORSET ) {
- /* write the tag */
- if ( (taglen = ber_put_tag( ber, (*sos)->sos_tag, 1 )) == -1 )
- return( -1 );
-
- if ( ber->ber_options & LBER_USE_DER ) {
- /* Write the length in the minimum # of octets */
- if ( ber_put_len( ber, len, 1 ) == -1 )
- return( -1 );
-
- if (lenlen != FOUR_BYTE_LEN) {
- /*
- * We set aside FOUR_BYTE_LEN bytes for
- * the length field. Move the data if
- * we don't actually need that much
- */
- (void) SAFEMEMCPY( (*sos)->sos_first + taglen +
- lenlen, (*sos)->sos_first + taglen +
- FOUR_BYTE_LEN, len );
- }
- } else {
- /* Fill FOUR_BYTE_LEN bytes for length field */
- /* one byte of length length */
- if ( ber_write( ber, (char *)&ltag, 1, 1 ) != 1 )
- return( -1 );
-
- /* the length itself */
- if ( ber_write( ber, (char *) &netlen + sizeof(int)
- - (FOUR_BYTE_LEN - 1), FOUR_BYTE_LEN - 1, 1 )
- != FOUR_BYTE_LEN - 1 )
- return( -1 );
- }
- /* The ber_ptr is at the set/seq start - move it to the end */
- (*sos)->sos_ber->ber_ptr += len;
- } else {
- unsigned int ntag;
-
- /* the tag */
- taglen = ber_calc_taglen( (*sos)->sos_tag );
- ntag = LBER_HTONL( (*sos)->sos_tag );
- (void) SAFEMEMCPY( (*sos)->sos_first, (char *) &ntag +
- sizeof(int) - taglen, taglen );
-
- if ( ber->ber_options & LBER_USE_DER ) {
- ltag = (lenlen == 1) ? len : 0x80 + (lenlen - 1);
- }
-
- /* one byte of length length */
- (void) SAFEMEMCPY( (*sos)->sos_first + 1, &ltag, 1 );
-
- if ( ber->ber_options & LBER_USE_DER ) {
- if (lenlen > 1) {
- /* Write the length itself */
- (void) SAFEMEMCPY( (*sos)->sos_first + 2,
- (char *)&netlen + sizeof(unsigned int) -
- (lenlen - 1),
- lenlen - 1 );
- }
- if (lenlen != FOUR_BYTE_LEN) {
- /*
- * We set aside FOUR_BYTE_LEN bytes for
- * the length field. Move the data if
- * we don't actually need that much
- */
- (void) SAFEMEMCPY( (*sos)->sos_first + taglen +
- lenlen, (*sos)->sos_first + taglen +
- FOUR_BYTE_LEN, len );
- }
- } else {
- /* the length itself */
- (void) SAFEMEMCPY( (*sos)->sos_first + taglen + 1,
- (char *) &netlen + sizeof(int) -
- (FOUR_BYTE_LEN - 1), FOUR_BYTE_LEN - 1 );
- }
-
- next->sos_clen += (taglen + lenlen + len);
- next->sos_ptr += (taglen + lenlen + len);
- }
-
- /* we're done with this seqorset, so free it up */
- free( (char *) (*sos) );
- *sos = next;
-
- return( taglen + lenlen + len );
-}
-
-int
-ber_put_seq( BerElement *ber )
-{
- return( ber_put_seqorset( ber ) );
-}
-
-int
-ber_put_set( BerElement *ber )
-{
- return( ber_put_seqorset( ber ) );
-}
-
-/* VARARGS */
-int
-ber_printf(
-#if defined(MACOS) || defined(_WIN32) || defined(BC31) || defined(__sun)
- BerElement *ber, char *fmt, ... )
-#else /* MACOS || _WIN32 || BC31 */
- va_alist )
-va_dcl
-#endif /* MACOS || _WIN32 || BC31 */
-{
- va_list ap;
-#if !defined(MACOS) && !defined(_WIN32) && !defined(BC31) && !defined(__sun)
- BerElement *ber;
- char *fmt;
-#endif /* !MACOS && !_WIN32 && !BC31 */
- char *s, **ss;
- struct berval **bv;
- int rc, i;
- unsigned int len;
-
-#if defined(MACOS) || defined(_WIN32) || defined(BC31) || defined(__sun)
- va_start( ap, fmt );
-#else /* MACOS || _WIN32 || BC31 */
- va_start( ap );
- ber = va_arg( ap, BerElement * );
- fmt = va_arg( ap, char * );
-#endif /* MACOS || _WIN32 || BC31 */
-
- for ( rc = 0; *fmt && rc != -1; fmt++ ) {
- switch ( *fmt ) {
- case 'b': /* boolean */
- i = va_arg( ap, int );
- rc = ber_put_boolean( ber, i, ber->ber_tag );
- break;
-
- case 'i': /* int */
- i = va_arg( ap, int );
- rc = ber_put_int( ber, i, ber->ber_tag );
- break;
-
- case 'e': /* enumeration */
- i = va_arg( ap, int );
- rc = ber_put_enum( ber, i, ber->ber_tag );
- break;
-
- case 'n': /* null */
- rc = ber_put_null( ber, ber->ber_tag );
- break;
-
- case 'o': /* octet string (non-null terminated) */
- s = va_arg( ap, char * );
- len = va_arg( ap, int );
- rc = ber_put_ostring( ber, s, len, ber->ber_tag );
- break;
-
- case 's': /* string */
- s = va_arg( ap, char * );
- rc = ber_put_string( ber, s, ber->ber_tag );
- break;
-
- case 'B': /* bit string */
- s = va_arg( ap, char * );
- len = va_arg( ap, int ); /* in bits */
- rc = ber_put_bitstring( ber, s, len, ber->ber_tag );
- break;
-
- case 't': /* tag for the next element */
- ber->ber_tag = va_arg( ap, unsigned int );
- ber->ber_usertag = 1;
- break;
-
- case 'v': /* vector of strings */
- if ( (ss = va_arg( ap, char ** )) == NULL )
- break;
- for ( i = 0; ss[i] != NULL; i++ ) {
- if ( (rc = ber_put_string( ber, ss[i],
- ber->ber_tag )) == -1 )
- break;
- }
- break;
-
- case 'V': /* sequences of strings + lengths */
- if ( (bv = va_arg( ap, struct berval ** )) == NULL )
- break;
- for ( i = 0; bv[i] != NULL; i++ ) {
- if ( (rc = ber_put_ostring( ber, bv[i]->bv_val,
- bv[i]->bv_len, ber->ber_tag )) == -1 )
- break;
- }
- break;
-
- case '{': /* begin sequence */
- rc = ber_start_seq( ber, ber->ber_tag );
- break;
-
- case '}': /* end sequence */
- rc = ber_put_seqorset( ber );
- break;
-
- case '[': /* begin set */
- rc = ber_start_set( ber, ber->ber_tag );
- break;
-
- case ']': /* end set */
- rc = ber_put_seqorset( ber );
- break;
-
- default:
-#ifndef NO_USERINTERFACE
- (void) fprintf( stderr, catgets(slapdcat, 1, 74, "unknown fmt %c\n"), *fmt );
-#endif /* NO_USERINTERFACE */
- rc = -1;
- break;
- }
-
- if ( ber->ber_usertag == 0 )
- ber->ber_tag = LBER_DEFAULT;
- else
- ber->ber_usertag = 0;
- }
-
- va_end( ap );
-
- return( rc );
-}
diff --git a/usr/src/lib/libldap4/ber/i18n.c b/usr/src/lib/libldap4/ber/i18n.c
deleted file mode 100644
index 04170c17ab..0000000000
--- a/usr/src/lib/libldap4/ber/i18n.c
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- *
- * Portions Copyright 1998 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- *
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#include <nl_types.h>
-/* #include <lthread.h> */
-#include <pthread.h>
-#include <thread.h>
-
-nl_catd slapdcat = 0;
-int notdone = 1;
-static pthread_mutex_t log_mutex;
-pthread_mutex_t systime_mutex;
-
-void i18n_catopen(char * name)
-{
- if ( notdone ) {
- notdone = 0;
- slapdcat = catopen(name, NL_CAT_LOCALE);
- } /* end if */
-}
-
diff --git a/usr/src/lib/libldap4/ber/io.c b/usr/src/lib/libldap4/ber/io.c
deleted file mode 100644
index 5b7338e08e..0000000000
--- a/usr/src/lib/libldap4/ber/io.c
+++ /dev/null
@@ -1,683 +0,0 @@
-/*
- * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/* io.c - ber general i/o routines */
-/*
- * Copyright (c) 1990 Regents of the University of Michigan.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms are permitted
- * provided that this notice is preserved and that due credit is given
- * to the University of Michigan at Ann Arbor. The name of the University
- * may not be used to endorse or promote products derived from this
- * software without specific prior written permission. This software
- * is provided ``as is'' without express or implied warranty.
- */
-
-#include <stdio.h>
-#include <ctype.h>
-#include <unistd.h>
-#include <poll.h>
-
-#if defined( DOS ) || defined( _WIN32 )
-#include "msdos.h"
-#endif /* DOS || _WIN32 */
-
-#ifdef MACOS
-#include <stdlib.h>
-#include "macos.h"
-#else /* MACOS */
-#if defined(NeXT) || defined(VMS)
-#include <stdlib.h>
-#else /* next || vms */
-#include <malloc.h>
-#endif /* next || vms */
-#include <errno.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#ifdef PCNFS
-#include <tklib.h>
-#endif /* PCNFS */
-#endif /* MACOS */
-
-#ifdef SUN
-#include <unistd.h>
-#endif
-
-#ifndef VMS
-#include <memory.h>
-#endif
-#include <string.h>
-#include "lber.h"
-#include "ldap.h"
-#include "ldap-private.h"
-#include "ldap-int.h"
-
-#ifdef _WIN32
-#include <winsock.h>
-#include <io.h>
-#endif /* _WIN32 */
-
-#ifdef NEEDPROTOS
-int ber_realloc(BerElement *ber, unsigned int len);
-static int ber_filbuf(Sockbuf *sb, int len);
-static int BerRead(Sockbuf *sb, char *buf, int len);
-#ifdef PCNFS
-static int BerWrite( Sockbuf *sb, char *buf, int len );
-#endif /* PCNFS */
-#else
-int ber_filbuf();
-int BerRead();
-int ber_realloc();
-#endif /* NEEDPROTOS */
-
-#define bergetc( sb, len ) ( sb->sb_ber.ber_end > sb->sb_ber.ber_ptr ? \
- (unsigned char)*sb->sb_ber.ber_ptr++ : \
- ber_filbuf( sb, len ))
-
-#ifdef MACOS
-/*
- * MacTCP/OpenTransport
- */
-#define read( s, b, l ) tcpread( s, 0, (unsigned char *)b, l, NULL )
-#define MAX_WRITE 65535
-#define BerWrite( sb, b, l ) tcpwrite( sb->sb_sd, (unsigned char *)(b), (l<MAX_WRITE)? l : MAX_WRITE )
-#else /* MACOS */
-#ifdef DOS
-#ifdef PCNFS
-/*
- * PCNFS (under DOS)
- */
-#define read( s, b, l ) recv( s, b, l, 0 )
-#define BerWrite( s, b, l ) send( s->sb_sd, b, (int) l, 0 )
-#endif /* PCNFS */
-#ifdef NCSA
-/*
- * NCSA Telnet TCP/IP stack (under DOS)
- */
-#define read( s, b, l ) nread( s, b, l )
-#define BerWrite( s, b, l ) netwrite( s->sb_sd, b, l )
-#endif /* NCSA */
-#ifdef WINSOCK
-/*
- * Windows Socket API (under DOS/Windows 3.x)
- */
-#define read( s, b, l ) recv( s, b, l, 0 )
-#define BerWrite( s, b, l ) send( s->sb_sd, b, l, 0 )
-#endif /* WINSOCK */
-#else /* DOS */
-#ifdef _WIN32
-/*
- * 32-bit Windows Socket API (under Windows NT or Windows 95)
- */
-#define read( s, b, l ) recv( s, b, l, 0 )
-#define BerWrite( s, b, l ) send( s->sb_sd, b, l, 0 )
-#else /* _WIN32 */
-#ifdef VMS
-/*
- * VMS -- each write must be 64K or smaller
- */
-#define MAX_WRITE 65535
-#define BerWrite( sb, b, l ) write( sb->sb_sd, b, (l<MAX_WRITE)? l : MAX_WRITE)
-#else /* VMS */
-/*
- * everything else (Unix/BSD 4.3 socket API)
- */
-#define BerWrite( sb, b, l ) write( sb->sb_sd, b, l )
-#endif /* VMS */
-#define udp_read( sb, b, l, al ) recvfrom(sb->sb_sd, (char *)b, l, 0, \
- (struct sockaddr *)sb->sb_fromaddr, \
- (al = sizeof(struct sockaddr), &al))
-#define udp_write( sb, b, l ) sendto(sb->sb_sd, (char *)(b), l, 0, \
- (struct sockaddr *)sb->sb_useaddr, sizeof(struct sockaddr))
-#endif /* _WIN32 */
-#endif /* DOS */
-#endif /* MACOS */
-
-#ifndef udp_read
-#define udp_read( sb, b, l, al ) CLDAP NOT SUPPORTED
-#define udp_write( sb, b, l ) CLDAP NOT SUPPORTED
-#endif /* udp_read */
-
-#define EXBUFSIZ 1024
-
-int
-ber_filbuf( Sockbuf *sb, int len )
-{
- ssize_t rc;
-#ifdef CLDAP
- int addrlen;
-#endif /* CLDAP */
-
- if ( sb->sb_ber.ber_buf == NULL ) {
- if ( (sb->sb_ber.ber_buf = (char *) malloc( READBUFSIZ )) ==
- NULL )
- return( -1 );
- sb->sb_ber.ber_ptr = sb->sb_ber.ber_buf;
- sb->sb_ber.ber_end = sb->sb_ber.ber_buf;
- }
-
- if ( sb->sb_naddr > 0 ) {
-#ifdef CLDAP
- rc = udp_read(sb, sb->sb_ber.ber_buf, READBUFSIZ, addrlen );
-#ifdef LDAP_DEBUG
- if ( lber_debug ) {
- (void) fprintf( stderr, catgets(slapdcat, 1, 75, "ber_filbuf udp_read %d bytes\n"),
- (int)rc );
- if ( lber_debug > 1 && rc > 0 )
- lber_bprint( sb->sb_ber.ber_buf, (int)rc );
- }
-#endif /* LDAP_DEBUG */
-#else /* CLDAP */
- rc = -1;
-#endif /* CLDAP */
-#ifdef LDAP_SSL
- } else if ( sb->sb_ssl != NULL ) {
- rc = SSL_read(sb->sb_ssl,(u_char *)sb->sb_ber.ber_buf,
- ((sb->sb_options & LBER_NO_READ_AHEAD) &&
- (len < READBUFSIZ)) ?
- len : READBUFSIZ );
-#endif /* LDAP_SSL */
- } else {
- int loop=2;
- while (loop>0) {
- --loop;
- rc = read( sb->sb_sd, sb->sb_ber.ber_buf,
- ((sb->sb_options & LBER_NO_READ_AHEAD) &&
- (len < READBUFSIZ)) ?
- len : READBUFSIZ );
- /*
- * if packet not here yet, wait 10 seconds to let it arrive
- */
- if ( rc <= 0 && (errno==EWOULDBLOCK || errno==EAGAIN) ) {
- struct pollfd poll_tab[1];
- poll_tab[0].fd = sb->sb_sd;
- poll_tab[0].events = POLLIN;
- poll_tab[0].revents = 0;
- if ( poll(poll_tab, 1, 10000) <= 0) {
- /* nothing received or error, just abandon the read */
- break;
- } /* end if */
- } else {
- break;
- } /* end if */
- } /* end while */
- }
-
- if ( rc > 0 ) {
- sb->sb_ber.ber_ptr = sb->sb_ber.ber_buf + 1;
- sb->sb_ber.ber_end = sb->sb_ber.ber_buf + rc;
- return( (unsigned char)*sb->sb_ber.ber_buf );
- }
-
- return( -1 );
-}
-
-
-int
-BerRead( Sockbuf *sb, char *buf, int len )
-{
- int c;
- int nread = 0;
-
- while ( len > 0 ) {
- if ( (c = bergetc( sb, len )) < 0 ) {
- if ( nread > 0 )
- break;
- return( c );
- }
- *buf++ = (char)c;
- nread++;
- len--;
- }
-
- return( nread );
-}
-
-
-int
-ber_read( BerElement *ber, char *buf, unsigned int len )
-{
- unsigned int actuallen, nleft;
-
- nleft = (int)(ber->ber_end - ber->ber_ptr);
- actuallen = nleft < len ? nleft : len;
-
- SAFEMEMCPY( buf, ber->ber_ptr, (size_t)actuallen );
-
- ber->ber_ptr += actuallen;
-
- return( (int)actuallen );
-}
-
-int
-ber_write( BerElement *ber, char *buf, unsigned int len, int nosos )
-{
- if ( nosos || ber->ber_sos == NULL ) {
- if ( ber->ber_ptr + len > ber->ber_end ) {
- if ( ber_realloc( ber, len ) != 0 )
- return( -1 );
- }
- (void) SAFEMEMCPY( ber->ber_ptr, buf, (size_t)len );
- ber->ber_ptr += len;
- return( len );
- } else {
- if ( ber->ber_sos->sos_ptr + len > ber->ber_end ) {
- if ( ber_realloc( ber, len ) != 0 )
- return( -1 );
- }
- (void) SAFEMEMCPY( ber->ber_sos->sos_ptr, buf, (size_t)len );
- ber->ber_sos->sos_ptr += len;
- ber->ber_sos->sos_clen += len;
- return( len );
- }
-}
-
-int
-ber_realloc(BerElement *ber, unsigned int len)
-{
- size_t need, have, total;
- Seqorset *s;
- ssize_t off;
- char *oldbuf;
-
- have = (ber->ber_end - ber->ber_buf) / EXBUFSIZ;
- need = (len < EXBUFSIZ ? 1 : (len + (EXBUFSIZ - 1)) / EXBUFSIZ);
- total = have * EXBUFSIZ + need * EXBUFSIZ;
-
- oldbuf = ber->ber_buf;
-
- if ( ber->ber_buf == NULL ) {
- if ( (ber->ber_buf = (char *) malloc( (size_t)total )) == NULL )
- return( -1 );
- } else if ( (ber->ber_buf = (char *) realloc( ber->ber_buf,
- (size_t)total )) == NULL )
- return( -1 );
-
- ber->ber_end = ber->ber_buf + total;
-
- /*
- * If the stinking thing was moved, we need to go through and
- * reset all the sos and ber pointers. Offsets would've been
- * a better idea... oh well.
- */
-
- if ( ber->ber_buf != oldbuf ) {
- ber->ber_ptr = ber->ber_buf + (ber->ber_ptr - oldbuf);
-
- for ( s = ber->ber_sos; s != NULLSEQORSET; s = s->sos_next ) {
- off = s->sos_first - oldbuf;
- s->sos_first = ber->ber_buf + off;
-
- off = s->sos_ptr - oldbuf;
- s->sos_ptr = ber->ber_buf + off;
- }
- }
-
- return( 0 );
-}
-
-void
-ber_free(BerElement *ber, int freebuf)
-{
- if (NULL != ber) {
- if (freebuf && ber->ber_buf != NULL)
- free(ber->ber_buf);
- free((char *)ber);
- }
-}
-
-int
-ber_flush( Sockbuf *sb, BerElement *ber, int freeit )
-{
- ssize_t nwritten, towrite, rc;
-
- if ( ber->ber_rwptr == NULL ) {
- ber->ber_rwptr = ber->ber_buf;
- }
- towrite = ber->ber_ptr - ber->ber_rwptr;
-
-#ifdef LDAP_DEBUG
- if ( lber_debug ) {
- (void) fprintf( stderr, catgets(slapdcat, 1, 76, "ber_flush: %1$ld bytes to sd %2$ld%s\n"), towrite,
- sb->sb_sd, ber->ber_rwptr != ber->ber_buf ? " (re-flush)"
- : "" );
- if ( lber_debug > 1 )
- lber_bprint( ber->ber_rwptr, towrite );
- }
-#endif
-#if !defined(MACOS) && !defined(DOS)
- if ( sb->sb_options & (LBER_TO_FILE | LBER_TO_FILE_ONLY) ) {
-#ifdef LDAP_SSL
- if (sb->sb_ssl) {
- rc = SSL_write( sb->sb_ssl, (u_char *)ber->ber_buf, towrite );
- if ( rc < 0 ) {
- fprintf( stderr, SSL_strerr(SSL_errno(sb->sb_ssl)));
- }
- } else {
-#endif /* LDAP_SSL */
- rc = write( sb->sb_fd, ber->ber_buf, towrite );
- if ( sb->sb_options & LBER_TO_FILE_ONLY ) {
- return( (int)rc );
- }
-#ifdef LDAP_SSL
- }
-#endif /* LDAP_SSL */
- }
-#endif
-
- nwritten = 0;
- do {
- if (sb->sb_naddr > 0) {
-#ifdef CLDAP
- rc = udp_write( sb, ber->ber_buf + nwritten,
- (size_t)towrite );
-#else /* CLDAP */
- rc = -1;
-#endif /* CLDAP */
- if ( rc <= 0 )
- return( -1 );
- /* fake error if write was not atomic */
- if (rc < towrite) {
-#if !defined( MACOS ) && !defined( DOS )
- errno = EMSGSIZE;
-#endif
- return( -1 );
- }
- } else {
-#ifdef LDAP_SSL
- if (sb->sb_ssl) {
- if ( (rc = SSL_write( sb->sb_ssl, (u_char *)ber->ber_rwptr,
- (size_t) towrite )) <= 0 ) {
- return( -1 );
- }
- } else
-#endif /* LDAP_SSL */
- if ( (rc = BerWrite( sb, ber->ber_rwptr,
- (size_t) towrite )) <= 0 ) {
- return( -1 );
- }
- }
- towrite -= rc;
- nwritten += rc;
- ber->ber_rwptr += rc;
- } while ( towrite > 0 );
-
- if ( freeit )
- ber_free( ber, 1 );
-
- return( 0 );
-}
-
-BerElement *
-ber_alloc_t( int options )
-{
- BerElement *ber;
-
- if ( (ber = (BerElement *) calloc( (size_t) 1, sizeof(BerElement) )) == NULLBER )
- return( NULLBER );
- ber->ber_tag = LBER_DEFAULT;
- ber->ber_options = (char) options;
-
- return( ber );
-}
-
-BerElement *
-ber_alloc()
-{
- return( ber_alloc_t( 0 ) );
-}
-
-BerElement *
-der_alloc()
-{
- return( ber_alloc_t( LBER_USE_DER ) );
-}
-
-BerElement *
-ber_dup( BerElement *ber )
-{
- BerElement *new;
-
- if ( (new = ber_alloc()) == NULLBER )
- return( NULLBER );
-
- *new = *ber;
-
- return( new );
-}
-
-BerElement *ber_init(struct berval *bv)
-{
- BerElement *new;
-
- if (bv == NULL)
- return (NULLBER);
-
- if ((new = ber_alloc()) == NULLBER)
- return (NULLBER);
- if ((new->ber_buf = (char *)malloc(bv->bv_len + 1)) == NULL){
- free(new);
- return (NULLBER);
- }
- SAFEMEMCPY(new->ber_buf, bv->bv_val, bv->bv_len);
- new->ber_end = new->ber_buf + bv->bv_len;
- new->ber_ptr = new->ber_buf;
- new->ber_len = bv->bv_len;
- return (new);
-}
-
-void
-ber_zero_init( BerElement *ber, int options )
-{
- (void) memset( (char *)ber, '\0', sizeof( BerElement ));
- ber->ber_tag = LBER_DEFAULT;
- ber->ber_options = options;
-}
-
-
-void
-ber_reset( BerElement *ber, int was_writing )
-{
- if ( was_writing ) {
- ber->ber_end = ber->ber_ptr;
- ber->ber_ptr = ber->ber_buf;
- } else {
- ber->ber_ptr = ber->ber_end;
- }
-
- ber->ber_rwptr = NULL;
-}
-
-
-#ifdef LDAP_DEBUG
-
-void
-ber_dump( BerElement *ber, int inout )
-{
- (void) fprintf( stderr, catgets(slapdcat, 1, 77, "ber_dump: buf 0x%1$lx, ptr 0x%2$lx, end 0x%3$lx\n"),
- ber->ber_buf, ber->ber_ptr, ber->ber_end );
- if ( inout == 1 ) {
- (void) fprintf( stderr, catgets(slapdcat, 1, 78, " current len %ld, contents:\n"),
- ber->ber_end - ber->ber_ptr );
- lber_bprint( ber->ber_ptr, ber->ber_end - ber->ber_ptr );
- } else {
- (void) fprintf( stderr, catgets(slapdcat, 1, 78, " current len %ld, contents:\n"),
- ber->ber_ptr - ber->ber_buf );
- lber_bprint( ber->ber_buf, ber->ber_ptr - ber->ber_buf );
- }
-}
-
-void
-ber_sos_dump( Seqorset *sos )
-{
- (void) fprintf( stderr, catgets(slapdcat, 1, 79, "*** sos dump ***\n") );
- while ( sos != NULLSEQORSET ) {
- (void) fprintf( stderr, catgets(slapdcat, 1, 80, "ber_sos_dump: clen %1$ld first 0x%2$lx ptr 0x%3$lx\n"),
- sos->sos_clen, sos->sos_first, sos->sos_ptr );
- (void) fprintf( stderr, catgets(slapdcat, 1, 81, " current len %ld contents:\n"),
- sos->sos_ptr - sos->sos_first );
- lber_bprint( sos->sos_first, sos->sos_ptr - sos->sos_first );
-
- sos = sos->sos_next;
- }
- (void) fprintf( stderr, catgets(slapdcat, 1, 82, "*** end dump ***\n") );
-}
-
-#endif
-
-/* return the tag - LBER_DEFAULT returned means trouble */
-static unsigned int
-get_tag( Sockbuf *sb )
-{
- unsigned char xbyte;
- unsigned int tag;
- char *tagp;
- int i;
-
- if ( BerRead( sb, (char *) &xbyte, 1 ) != 1 )
- return( LBER_DEFAULT );
-
- if ( (xbyte & LBER_BIG_TAG_MASK) != LBER_BIG_TAG_MASK )
- return( (unsigned int) xbyte );
-
- tagp = (char *) &tag;
- tagp[0] = xbyte;
- for ( i = 1; i < sizeof(int); i++ ) {
- if ( BerRead( sb, (char *) &xbyte, 1 ) != 1 )
- return( LBER_DEFAULT );
-
- tagp[i] = xbyte;
-
- if ( ! (xbyte & LBER_MORE_TAG_MASK) )
- break;
- }
-
- /* tag too big! */
- if ( i == sizeof(int) )
- return( LBER_DEFAULT );
-
- /* want leading, not trailing 0's */
- return( tag >> (sizeof(int) - i - 1) );
-}
-
-unsigned int
-ber_get_next( Sockbuf *sb, unsigned int *len, BerElement *ber )
-{
- unsigned int tag, netlen, toread;
- unsigned char lc;
- int rc;
- int noctets, diff;
-
-#ifdef LDAP_DEBUG
- if ( lber_debug )
- (void) fprintf( stderr, catgets(slapdcat, 1, 83, "ber_get_next\n") );
-#endif
-
- /*
- * Any ber element looks like this: tag length contents.
- * Assuming everything's ok, we return the tag byte (we
- * can assume a single byte), return the length in len,
- * and the rest of the undecoded element in buf.
- *
- * Assumptions:
- * 1) small tags (less than 128)
- * 2) definite lengths
- * 3) primitive encodings used whenever possible
- */
-
- /*
- * first time through - malloc the buffer, set up ptrs, and
- * read the tag and the length and as much of the rest as we can
- */
-
- if ( ber->ber_rwptr == NULL ) {
- /*
- * First, we read the tag.
- */
-
- if ( (tag = get_tag( sb )) == LBER_DEFAULT ) {
- return( LBER_DEFAULT );
- }
- ber->ber_tag = tag;
-
- /*
- * Next, read the length. The first byte contains the length
- * of the length. If bit 8 is set, the length is the int
- * form, otherwise it's the short form. We don't allow a
- * length that's greater than what we can hold in an unsigned
- * int.
- */
-
- *len = netlen = 0;
- if ( BerRead( sb, (char *) &lc, 1 ) != 1 ) {
- return( LBER_DEFAULT );
- }
- if ( lc & 0x80 ) {
- noctets = (lc & 0x7f);
- if ( noctets > sizeof(unsigned int) )
- return( LBER_DEFAULT );
- diff = sizeof(unsigned int) - noctets;
- if ( BerRead( sb, (char *) &netlen + diff, noctets ) !=
- noctets ) {
- return( LBER_DEFAULT );
- }
- *len = LBER_NTOHL( netlen );
- } else {
- *len = lc;
- }
- ber->ber_len = *len;
-
- /*
- * Finally, malloc a buffer for the contents and read it in.
- * It's this buffer that's passed to all the other ber decoding
- * routines.
- */
-
-#if defined( DOS ) && !defined( _WIN32 )
- if ( *len > 65535 ) { /* DOS can't allocate > 64K */
- return( LBER_DEFAULT );
- }
-#endif /* DOS && !_WIN32 */
-
- if ( ( sb->sb_options & LBER_MAX_INCOMING_SIZE ) &&
- *len > sb->sb_max_incoming ) {
- return( LBER_DEFAULT );
- }
-
- if ( (ber->ber_buf = (char *) malloc( (size_t)*len )) == NULL ) {
- return( LBER_DEFAULT );
- }
- ber->ber_ptr = ber->ber_buf;
- ber->ber_end = ber->ber_buf + *len;
- ber->ber_rwptr = ber->ber_buf;
- }
-
- toread = (uintptr_t)ber->ber_end - (uintptr_t)ber->ber_rwptr;
- do {
- if ( (rc = BerRead( sb, ber->ber_rwptr, (int)toread )) <= 0 ) {
- return( LBER_DEFAULT );
- }
-
- toread -= rc;
- ber->ber_rwptr += rc;
- } while ( toread != 0 ); /* DF SUN for LINT */
-
-#ifdef LDAP_DEBUG
- if ( lber_debug ) {
- (void) fprintf( stderr, catgets(slapdcat, 1, 84, "ber_get_next: tag 0x%1$lx len %2$ld contents:\n"),
- tag, ber->ber_len );
- if ( lber_debug > 1 )
- ber_dump( ber, 1 );
- }
-#endif
-
- *len = ber->ber_len;
- ber->ber_rwptr = NULL;
- return( ber->ber_tag );
-}
diff --git a/usr/src/lib/libldap4/common/Version.c b/usr/src/lib/libldap4/common/Version.c
deleted file mode 100644
index c3fa7df517..0000000000
--- a/usr/src/lib/libldap4/common/Version.c
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Portions Copyright 1998 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*
- * Copyright (c) 1991 Regents of the University of Michigan.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms are permitted
- * provided that this notice is preserved and that due credit is given
- * to the University of Michigan at Ann Arbor. The name of the University
- * may not be used to endorse or promote products derived from this
- * software without specific prior written permission. This software
- * is provided ``as is'' without express or implied warranty.
- */
-
-static char Version[] = " libldap.a v%VERSION% (%WHEN%)\n\t%WHOANDWHERE%\n";
diff --git a/usr/src/lib/libldap4/common/abandon.c b/usr/src/lib/libldap4/common/abandon.c
deleted file mode 100644
index 71345186c7..0000000000
--- a/usr/src/lib/libldap4/common/abandon.c
+++ /dev/null
@@ -1,267 +0,0 @@
-
-/*
- * Portions Copyright 1998 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*
- * Copyright (c) 1990 Regents of the University of Michigan.
- * All rights reserved.
- *
- * abandon.c
- */
-
-#ifndef lint
-static char copyright[] = "@(#) Copyright (c) 1990 Regents of the University of Michigan.\nAll rights reserved.\n";
-#endif
-
-#include <stdio.h>
-#include <string.h>
-
-#if !defined( MACOS ) && !defined( DOS )
-#include <sys/types.h>
-#include <sys/socket.h>
-#endif
-
-#if defined( DOS ) || defined( _WIN32 )
-#include <malloc.h>
-#include "msdos.h"
-#endif /* DOS */
-
-#ifdef MACOS
-#include <stdlib.h>
-#include "macos.h"
-#endif /* MACOS */
-
-#include "lber.h"
-#include "ldap.h"
-#include "ldap-private.h"
-#include "ldap-int.h"
-
-#ifdef NEEDPROTOS
-static int do_abandon( LDAP *ld, int origid, int msgid, LDAPControl **serverctrls );
-#else /* NEEDPROTOS */
-static int do_abandon();
-#endif /* NEEDPROTOS */
-
-BerElement * ldap_build_abandon_req( LDAP *ld, int msgid, LDAPControl ** serverctrls)
-{
- BerElement *ber;
- int rc;
-
- /* create a message to send */
- if ( (ber = alloc_ber_with_options( ld )) == NULLBER ) {
- rc = -1;
- ld->ld_errno = LDAP_NO_MEMORY;
- return (NULLBER);
- }
-#ifdef CLDAP
- if ( ld->ld_sb.sb_naddr > 0 ) {
- rc = ber_printf( ber, "{isti",
- ++ld->ld_msgid, ld->ld_cldapdn,
- LDAP_REQ_ABANDON, msgid );
- } else {
-#endif /* CLDAP */
- rc = ber_printf( ber, "{iti", ++ld->ld_msgid,
- LDAP_REQ_ABANDON, msgid );
-#ifdef CLDAP
- }
-#endif /* CLDAP */
-
- if ( rc == -1 ) {
- ld->ld_errno = LDAP_ENCODING_ERROR;
- ber_free( ber, 1 );
- return (NULLBER);
- }
- /* LDAPv3 */
- /* Code controls if any */
- if (serverctrls && serverctrls[0]) {
- if (ldap_controls_code(ber, serverctrls) != LDAP_SUCCESS){
- ld->ld_errno = LDAP_ENCODING_ERROR;
- return( NULLBER );
- }
- } else if (ld->ld_srvctrls && ld->ld_srvctrls[0]) {
- /* Otherwise, is there any global server ctrls ? */
- if (ldap_controls_code(ber, ld->ld_srvctrls) != LDAP_SUCCESS){
- ld->ld_errno = LDAP_ENCODING_ERROR;
- return( NULLBER );
- }
- }
-
- if ( ber_printf( ber, "}" ) == -1 ) {
- ld->ld_errno = LDAP_ENCODING_ERROR;
- ber_free( ber, 1 );
- return( NULLBER );
- }
- return (ber);
-}
-
-
-/*
- * ldap_abandon - perform an ldap (and X.500) abandon operation. Parameters:
- *
- * ld LDAP descriptor
- * msgid The message id of the operation to abandon
- *
- * ldap_abandon returns 0 if everything went ok, -1 otherwise.
- *
- * Example:
- * ldap_abandon( ld, msgid );
- */
-int
-ldap_abandon( LDAP *ld, int msgid )
-{
- int rv;
-
-#ifdef _REENTRANT
- LOCK_LDAP( ld );
-#endif
-
- Debug( LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 85, "ldap_abandon %d\n"), msgid, 0, 0 );
-
- rv = do_abandon( ld, msgid, msgid , NULL);
-#ifdef _REENTRANT
- UNLOCK_LDAP( ld );
-#endif
- return (rv);
-}
-
-/* ldapv3 API extensions */
-
-int ldap_abandon_ext(LDAP *ld, int msgid, LDAPControl **serverctrls, LDAPControl **clientctrls)
-{
- int rv;
-
-#ifdef _REENTRANT
- LOCK_LDAP( ld );
-#endif
-
- Debug( LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 85, "ldap_abandon %d\n"), msgid, 0, 0 );
-
- rv = do_abandon( ld, msgid, msgid , NULL);
- if (rv == -1) {
- rv = ld->ld_errno;
- if (rv == LDAP_SUCCESS)
- rv = LDAP_OTHER;
-#ifdef _REENTRANT
- UNLOCK_LDAP( ld );
-#endif
- return (rv);
- }
-#ifdef _REENTRANT
- UNLOCK_LDAP( ld );
-#endif
- return (LDAP_SUCCESS);
-}
-
-
-static int
-do_abandon( LDAP *ld, int origid, int msgid , LDAPControl **serverctrls)
-{
- BerElement *ber;
- int i, err, sendabandon;
- Sockbuf *sb;
-#ifdef LDAP_REFERRALS
- LDAPRequest *lr;
-#endif /* LDAP_REFERRALS */
-
- /*
- * An abandon request looks like this:
- * AbandonRequest ::= MessageID
- */
-
- Debug( LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 86, "do_abandon origid %1$d, msgid %2$d\n"),
- origid, msgid, 0 );
-
- sendabandon = 1;
-
-#ifdef LDAP_REFERRALS
- /* find the request that we are abandoning */
- for ( lr = ld->ld_requests; lr != NULL; lr = lr->lr_next ) {
- if ( lr->lr_msgid == msgid ) { /* this message */
- break;
- }
- if ( lr->lr_origid == msgid ) { /* child: abandon it */
- do_abandon( ld, msgid, lr->lr_msgid , serverctrls);
- }
- }
-
- if ( lr != NULL ) {
- if ( origid == msgid && lr->lr_parent != NULL ) {
- /* don't let caller abandon child requests! */
- ld->ld_errno = LDAP_PARAM_ERROR;
- return( -1 );
- }
- if ( lr->lr_status != LDAP_REQST_INPROGRESS ) {
- /* no need to send abandon message */
- sendabandon = 0;
- }
- }
-#endif /* LDAP_REFERRALS */
-
- if ( ldap_msgdelete( ld, msgid ) == 0 ) {
- ld->ld_errno = LDAP_SUCCESS;
- return( 0 );
- }
-
- err = 0;
- if ( sendabandon ) {
- if ((ber = ldap_build_abandon_req(ld, msgid, serverctrls)) == NULLBER){
- return (-1);
- }
-
-#ifdef LDAP_REFERRALS
- if ( lr != NULL ) {
- sb = lr->lr_conn->lconn_sb;
- } else {
- sb = &ld->ld_sb;
- }
-#else /* LDAP_REFERRALS */
- sb = &ld->ld_sb;
-#endif /* LDAP_REFERRALS */
- if ( ber_flush( sb, ber, 1 ) != 0 ) {
- ld->ld_errno = LDAP_SERVER_DOWN;
- err = -1;
- } else {
- err = 0;
- }
- }
-#ifdef LDAP_REFERRALS
- if ( lr != NULL ) {
- if ( sendabandon ) {
- free_connection( ld, lr->lr_conn, 0, 1 );
- }
- if ( origid == msgid ) {
- free_request( ld, lr );
- }
- }
-#endif /* LDAP_REFERRALS */
-
-
- if ( ld->ld_abandoned == NULL ) {
- if ( (ld->ld_abandoned = (int *) malloc( 2 * sizeof(int) ))
- == NULL ) {
- ld->ld_errno = LDAP_NO_MEMORY;
- return( -1 );
- }
- i = 0;
- } else {
- for ( i = 0; ld->ld_abandoned[i] != -1; i++ )
- ; /* NULL */
- if ( (ld->ld_abandoned = (int *) realloc( (char *)
- ld->ld_abandoned, (i + 2) * sizeof(int) )) == NULL ) {
- ld->ld_errno = LDAP_NO_MEMORY;
- return( -1 );
- }
- }
- ld->ld_abandoned[i] = msgid;
- ld->ld_abandoned[i + 1] = -1;
-
- if ( err != -1 ) {
- ld->ld_errno = LDAP_SUCCESS;
- }
- return( err );
-}
-
diff --git a/usr/src/lib/libldap4/common/add.c b/usr/src/lib/libldap4/common/add.c
deleted file mode 100644
index ce3e357b6f..0000000000
--- a/usr/src/lib/libldap4/common/add.c
+++ /dev/null
@@ -1,270 +0,0 @@
-/*
- * Portions Copyright 1998 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-#pragma ident "%Z%%M% %I% %E% SMI"
-/*
- * Copyright (c) 1990 Regents of the University of Michigan.
- * All rights reserved.
- *
- * add.c
- */
-
-#ifndef lint
-static char copyright[] = "@(#) Copyright (c) 1990 Regents of the University of Michigan.\nAll rights reserved.\n";
-#endif
-
-#include <stdio.h>
-#include <string.h>
-
-#ifdef MACOS
-#include "macos.h"
-#endif /* MACOS */
-
-#if defined( DOS ) || defined( _WIN32 )
-#include <malloc.h>
-#include "msdos.h"
-#endif /* DOS */
-
-#if !defined( MACOS ) && !defined( DOS )
-#include <sys/types.h>
-#include <sys/socket.h>
-#endif /* !MACOS && !DOS */
-
-#include "lber.h"
-#include "ldap.h"
-#include "ldap-private.h"
-#include "ldap-int.h"
-
-
-BerElement * ldap_build_add_req(LDAP *ld, char *dn, LDAPMod **attrs,
- LDAPControl ** serverctrls)
-{
- BerElement * ber;
- int rc, i;
-
- /*
- * An add request looks like this:
- * AddRequest ::= [APPLICATION 8] SEQUENCE {
- * entry DistinguishedName,
- * attrs SEQUENCE OF SEQUENCE {
- * type AttributeType,
- * values SET OF AttributeValue
- * }
- * }
- */
-
- /* create a message to send */
- if ( (ber = alloc_ber_with_options( ld )) == NULLBER ) {
- ld->ld_errno = LDAP_NO_MEMORY;
- return( NULLBER );
- }
-
- if ( ber_printf( ber, "{it{s{", ++ld->ld_msgid, LDAP_REQ_ADD, dn )
- == -1 ) {
- ld->ld_errno = LDAP_ENCODING_ERROR;
- ber_free( ber, 1 );
- return( NULLBER );
- }
-
- /* for each attribute in the entry... */
- for ( i = 0; attrs[i] != NULL; i++ ) {
- if ( ( attrs[i]->mod_op & LDAP_MOD_BVALUES) != 0 ) {
- rc = ber_printf( ber, "{s[V]}", attrs[i]->mod_type,
- attrs[i]->mod_values );
- } else {
- rc = ber_printf( ber, "{s[v]}", attrs[i]->mod_type,
- attrs[i]->mod_values );
- }
- if ( rc == -1 ) {
- ld->ld_errno = LDAP_ENCODING_ERROR;
- ber_free( ber, 1 );
- return(NULLBER);
- }
- }
-
- if ( ber_printf( ber, "}}" ) == -1 ) {
- ld->ld_errno = LDAP_ENCODING_ERROR;
- ber_free( ber, 1 );
- return( NULLBER );
- }
-
-/* LDAPv3 */
- /* Code controls if any */
- if (serverctrls && serverctrls[0]) {
- if (ldap_controls_code(ber, serverctrls) != LDAP_SUCCESS){
- ld->ld_errno = LDAP_ENCODING_ERROR;
- ber_free( ber, 1 );
- return( NULLBER );
- }
- } else if (ld->ld_srvctrls && ld->ld_srvctrls[0]) {
- /* Otherwise, is there any global server ctrls ? */
- if (ldap_controls_code(ber, ld->ld_srvctrls) != LDAP_SUCCESS){
- ld->ld_errno = LDAP_ENCODING_ERROR;
- ber_free( ber, 1 );
- return( NULLBER );
- }
- }
-
- if ( ber_printf( ber, "}" ) == -1 ) {
- ld->ld_errno = LDAP_ENCODING_ERROR;
- ber_free( ber, 1 );
- return( NULLBER );
- }
-
- return (ber);
-}
-
-
-/*
- * ldap_add - initiate an ldap (and X.500) add operation. Parameters:
- *
- * ld LDAP descriptor
- * dn DN of the entry to add
- * mods List of attributes for the entry. This is a null-
- * terminated array of pointers to LDAPMod structures.
- * only the type and values in the structures need be
- * filled in.
- *
- * Example:
- * LDAPMod *attrs[] = {
- * { 0, "cn", { "babs jensen", "babs", 0 } },
- * { 0, "sn", { "jensen", 0 } },
- * { 0, "objectClass", { "person", 0 } },
- * 0
- * }
- * msgid = ldap_add( ld, dn, attrs );
- */
-int ldap_add( LDAP *ld, char *dn, LDAPMod **attrs )
-{
- BerElement *ber;
- int rv;
-
-#ifdef _REENTRANT
- LOCK_LDAP(ld);
-#endif
- Debug( LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 87, "ldap_add\n"), 0, 0, 0 );
-
- if ((ber = ldap_build_add_req(ld, dn, attrs, NULL)) == NULLBER){
-#ifdef _REENTRANT
- UNLOCK_LDAP(ld);
-#endif
- return (-1);
- }
-
- /* send the message */
- rv = send_initial_request( ld, LDAP_REQ_ADD, dn, ber );
-#ifdef _REENTRANT
- UNLOCK_LDAP(ld);
-#endif
- return (rv);
-}
-
-int
-ldap_add_s( LDAP *ld, char *dn, LDAPMod **attrs )
-{
- int msgid;
- LDAPMessage *res;
-
- if ( (msgid = ldap_add( ld, dn, attrs )) == -1 )
- return( ld->ld_errno );
-
- if ( ldap_result( ld, msgid, 1, (struct timeval *) NULL, &res ) == -1 )
- return( ld->ld_errno );
-
- return( ldap_result2error( ld, res, 1 ) );
-}
-
-
-/* ldapv3 API extensions */
-/*
- * ldap_add_ext - initiate an ldap (and X.500) add operation. Parameters:
- *
- * ld LDAP descriptor
- * dn DN of the entry to add
- * attrs List of attributes for the entry. This is a null-
- * terminated array of pointers to LDAPMod structures.
- * only the type and values in the structures need be
- * filled in.
- * serverctrls List of server controls. This is a null-terminated
- * array of pointers to LDAPControl structures.
- * clientctrls List of client controls.
- *
- * Example:
- * LDAPMod *attrs[] = {
- * { 0, "cn", { "babs jensen", "babs", 0 } },
- * { 0, "sn", { "jensen", 0 } },
- * { 0, "objectClass", { "person", 0 } },
- * 0
- * }
- *
- * retcode = ldap_add_ext( ld, dn, attrs, srvctrls, cltctrls, &msgid );
- */
-
-int ldap_add_ext(LDAP *ld, char *dn, LDAPMod **attrs,
- LDAPControl ** serverctrls, LDAPControl **clientctrls, int *msgidp)
-{
- BerElement *ber;
- int i, rc;
- int rv;
-
-#ifdef _REENTRANT
- LOCK_LDAP(ld);
-#endif
- Debug( LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 87, "ldap_add\n"), 0, 0, 0 );
-
- if ((ber = ldap_build_add_req(ld, dn, attrs, serverctrls)) == NULLBER){
- rv = ld->ld_errno;
- if (rv == LDAP_SUCCESS)
- rv = LDAP_OTHER;
-#ifdef _REENTRANT
- UNLOCK_LDAP(ld);
-#endif
- return (rv);
- }
-
- /* send the message */
- rv = send_initial_request( ld, LDAP_REQ_ADD, dn, ber );
- if (rv == -1) {
- rv = ld->ld_errno;
- if (rv == LDAP_SUCCESS){
- rv = LDAP_OTHER;
- }
-
-#ifdef _REENTRANT
- UNLOCK_LDAP(ld);
-#endif
- return (rv);
- }
-
- *msgidp = rv;
-#ifdef _REENTRANT
- UNLOCK_LDAP(ld);
-#endif
- return (LDAP_SUCCESS);
-}
-
-int ldap_add_ext_s(LDAP *ld, char *dn, LDAPMod **attrs,
- LDAPControl ** serverctrls, LDAPControl **clientctrls)
-{
- int msgid;
- int retcode = LDAP_SUCCESS;
- LDAPMessage *res;
-
- if ((retcode = ldap_add_ext(ld, dn, attrs, serverctrls, clientctrls, &msgid)) != LDAP_SUCCESS)
- return (retcode);
- if (ldap_result(ld, msgid, 1, (struct timeval *)NULL, &res ) == -1)
- return (ld->ld_errno );
-
-#ifdef _REENTRANT
- LOCK_LDAP(ld);
-#endif
- retcode = ldap_parse_result(ld, res, &ld->ld_errno, &ld->ld_matched, &ld->ld_error,
- &ld->ld_referrals, &ld->ld_ret_ctrls, 1);
- if (retcode == LDAP_SUCCESS)
- retcode = ld->ld_errno;
-#ifdef _REENTRANT
- UNLOCK_LDAP(ld);
-#endif
- return (retcode);
-}
diff --git a/usr/src/lib/libldap4/common/addentry.c b/usr/src/lib/libldap4/common/addentry.c
deleted file mode 100644
index f1f0582560..0000000000
--- a/usr/src/lib/libldap4/common/addentry.c
+++ /dev/null
@@ -1,63 +0,0 @@
-
-/*
- * Portions Copyright 1998 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-#pragma ident "%Z%%M% %I% %E% SMI"
-/*
- * Copyright (c) 1990 Regents of the University of Michigan.
- * All rights reserved.
- *
- * addentry.c
- */
-
-#ifndef lint
-static char copyright[] = "@(#) Copyright (c) 1990 Regents of the University of Michigan.\nAll rights reserved.\n";
-#endif
-
-#include <stdio.h>
-#include <ctype.h>
-#include <string.h>
-#ifdef MACOS
-#include <stdlib.h>
-#include "macos.h"
-#else /* MACOS */
-#if defined( DOS ) || defined( _WIN32 )
-#include <malloc.h>
-#include "msdos.h"
-#else /* DOS */
-#include <sys/types.h>
-#include <sys/socket.h>
-#endif /* DOS */
-#endif /* MACOS */
-
-#include "lber.h"
-#include "ldap.h"
-#include "ldap-private.h"
-
-LDAPMessage *
-ldap_delete_result_entry( LDAPMessage **list, LDAPMessage *e )
-{
- LDAPMessage *tmp, *prev = NULL;
-
- for ( tmp = *list; tmp != NULL && tmp != e; tmp = tmp->lm_chain )
- prev = tmp;
-
- if ( tmp == NULL )
- return( NULL );
-
- if ( prev == NULL )
- *list = tmp->lm_chain;
- else
- prev->lm_chain = tmp->lm_chain;
- tmp->lm_chain = NULL;
-
- return( tmp );
-}
-
-void
-ldap_add_result_entry( LDAPMessage **list, LDAPMessage *e )
-{
- e->lm_chain = *list;
- *list = e;
-}
diff --git a/usr/src/lib/libldap4/common/bind.c b/usr/src/lib/libldap4/common/bind.c
deleted file mode 100644
index 7c5d783f2c..0000000000
--- a/usr/src/lib/libldap4/common/bind.c
+++ /dev/null
@@ -1,145 +0,0 @@
-/*
- * Portions Copyright 1998 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-/*
- * Copyright (c) 1990 Regents of the University of Michigan.
- * All rights reserved.
- *
- * bind.c
- */
-
-#ifndef lint
-static char copyright[] = "@(#) Copyright (c) 1990 Regents of the University of Michigan.\nAll rights reserved.\n";
-#endif
-
-#include <stdio.h>
-#include <string.h>
-#ifdef MACOS
-#include <stdlib.h>
-#include "macos.h"
-#else /* MACOS */
-#ifdef DOS
-#include "msdos.h"
-#ifdef NCSA
-#include "externs.h"
-#endif /* NCSA */
-#else /* DOS */
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/time.h>
-#endif /* DOS */
-#endif /* MACOS */
-
-#include "lber.h"
-#include "ldap.h"
-#include "ldap-private.h"
-#include "ldap-int.h"
-
-
-/*
- * ldap_bind - bind to the ldap server (and X.500). The dn and password
- * of the entry to which to bind are supplied, along with the authentication
- * method to use. The msgid of the bind request is returned on success,
- * -1 if there's trouble. Note, the kerberos support assumes the user already
- * has a valid tgt for now. ldap_result() should be called to find out the
- * outcome of the bind request.
- *
- * Example:
- * ldap_bind( ld, "cn=manager, o=university of michigan, c=us", "secret",
- * LDAP_AUTH_SIMPLE )
- */
-
-int
-ldap_bind( LDAP *ld, char *dn, char *passwd, int authmethod )
-{
- /*
- * The bind request looks like this:
- * BindRequest ::= SEQUENCE {
- * version INTEGER,
- * name DistinguishedName, -- who
- * authentication CHOICE {
- * simple [0] OCTET STRING -- passwd
-#ifdef KERBEROS
- * krbv42ldap [1] OCTET STRING
- * krbv42dsa [2] OCTET STRING
-#endif
- * }
- * }
- * all wrapped up in an LDAPMessage sequence.
- */
-
- Debug( LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 88, "ldap_bind\n"), 0, 0, 0 );
-
- switch ( authmethod ) {
- case LDAP_AUTH_SIMPLE:
- return( ldap_simple_bind( ld, dn, passwd ) );
-
-#ifdef KERBEROS
- case LDAP_AUTH_KRBV41:
- return( ldap_kerberos_bind1( ld, dn ) );
-
- case LDAP_AUTH_KRBV42:
- return( ldap_kerberos_bind2( ld, dn ) );
-#endif
-
- default:
- ld->ld_errno = LDAP_AUTH_UNKNOWN;
- return( -1 );
- }
-}
-
-/*
- * ldap_bind_s - bind to the ldap server (and X.500). The dn and password
- * of the entry to which to bind are supplied, along with the authentication
- * method to use. This routine just calls whichever bind routine is
- * appropriate and returns the result of the bind (e.g. LDAP_SUCCESS or
- * some other error indication). Note, the kerberos support assumes the
- * user already has a valid tgt for now.
- *
- * Examples:
- * ldap_bind_s( ld, "cn=manager, o=university of michigan, c=us",
- * "secret", LDAP_AUTH_SIMPLE )
- * ldap_bind_s( ld, "cn=manager, o=university of michigan, c=us",
- * NULL, LDAP_AUTH_KRBV4 )
- */
-int
-ldap_bind_s( LDAP *ld, char *dn, char *passwd, int authmethod )
-{
- Debug( LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 89, "ldap_bind_s\n"), 0, 0, 0 );
-
- switch ( authmethod ) {
- case LDAP_AUTH_SIMPLE:
- return( ldap_simple_bind_s( ld, dn, passwd ) );
-
-#ifdef KERBEROS
- case LDAP_AUTH_KRBV4:
- return( ldap_kerberos_bind_s( ld, dn ) );
-
- case LDAP_AUTH_KRBV41:
- return( ldap_kerberos_bind1_s( ld, dn ) );
-
- case LDAP_AUTH_KRBV42:
- return( ldap_kerberos_bind2_s( ld, dn ) );
-#endif
-
- default:
- return( ld->ld_errno = LDAP_AUTH_UNKNOWN );
- }
-}
-
-
-void
-ldap_set_rebind_proc( LDAP *ld, LDAP_REBIND_FUNCTION *rebindproc, void *extra_arg )
-{
-#ifdef _REENTRANT
- LOCK_LDAP(ld);
-#endif
- ld->ld_rebindproc = rebindproc;
- ld->ld_rebind_extra_arg = extra_arg;
-#ifdef _REENTRANT
- UNLOCK_LDAP(ld);
-#endif
-}
diff --git a/usr/src/lib/libldap4/common/cache.c b/usr/src/lib/libldap4/common/cache.c
deleted file mode 100644
index 977e4c6d02..0000000000
--- a/usr/src/lib/libldap4/common/cache.c
+++ /dev/null
@@ -1,714 +0,0 @@
-/*
- * Portions Copyright 1998 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-#pragma ident "%Z%%M% %I% %E% SMI"
-/*
- * Copyright (c) 1993 The Regents of the University of Michigan.
- * All rights reserved.
- *
- * cache.c - local caching support for LDAP
- */
-
-#ifndef NO_CACHE
-
-#ifndef lint
-static char copyright[] = "@(#) Copyright (c) 1993 The Regents of the University of Michigan.\nAll rights reserved.\n";
-#endif
-
-#include <stdio.h>
-#include <string.h>
-#ifdef MACOS
-#include <stdlib.h>
-#include <time.h>
-#include "macos.h"
-#else /* MACOS */
-#if defined( DOS ) || defined( _WIN32 )
-#include <malloc.h>
-#include "msdos.h"
-#ifdef NCSA
-#include "externs.h"
-#endif /* NCSA */
-#ifdef WINSOCK
-#include <time.h>
-#endif /* WINSOCK */
-#else /* DOS */
-#include <sys/types.h>
-#include <sys/socket.h>
-#endif /* DOS */
-#endif /* MACOS */
-#include "lber.h"
-#include "ldap.h"
-#include "ldap-private.h"
-#include "ldap-int.h"
-
-#ifdef NEEDPROTOS
-static int cache_hash( BerElement *ber );
-static LDAPMessage *msg_dup( LDAPMessage *msg );
-static int request_cmp( BerElement *req1, BerElement *req2 );
-static int chain_contains_dn( LDAPMessage *msg, char *dn );
-static ssize_t msg_size( LDAPMessage *msg );
-static void check_cache_memused( LDAPCache *lc );
-static void uncache_entry_or_req( LDAP *ld, char *dn, int msgid );
-#else /* NEEDPROTOS */
-static int cache_hash();
-static LDAPMessage *msg_dup();
-static int request_cmp();
-static int chain_contains_dn();
-static ssize_t msg_size();
-static void check_cache_memused();
-static void uncache_entry_or_req();
-#endif /* NEEDPROTOS */
-
-
-int
-ldap_enable_cache( LDAP *ld, time_t timeout, ssize_t maxmem )
-{
-#if defined( SUN ) && defined( _REENTRANT )
- LOCK_LDAP(ld);
-#endif
- if ( ld->ld_cache == NULLLDCACHE ) {
- if (( ld->ld_cache = (LDAPCache *)malloc( sizeof( LDAPCache )))
- == NULLLDCACHE ) {
- ld->ld_errno = LDAP_NO_MEMORY;
-#if defined( SUN ) && defined( _REENTRANT )
- UNLOCK_LDAP(ld);
-#endif
- return( -1 );
- }
- (void) memset( ld->ld_cache, 0, sizeof( LDAPCache ));
- ld->ld_cache->lc_memused = sizeof( LDAPCache );
- }
-
- ld->ld_cache->lc_timeout = timeout;
- ld->ld_cache->lc_maxmem = maxmem;
- check_cache_memused( ld->ld_cache );
- ld->ld_cache->lc_enabled = 1;
-#if defined( SUN ) && defined( _REENTRANT )
- UNLOCK_LDAP(ld);
-#endif
- return( 0 );
-}
-
-
-void
-ldap_disable_cache( LDAP *ld )
-{
-#if defined( SUN ) && defined( _REENTRANT )
- LOCK_LDAP(ld);
-#endif
- if ( ld->ld_cache != NULLLDCACHE ) {
- ld->ld_cache->lc_enabled = 0;
- }
-#if defined( SUN ) && defined( _REENTRANT )
- UNLOCK_LDAP(ld);
-#endif
-}
-
-
-
-void
-ldap_set_cache_options( LDAP *ld, unsigned int opts )
-{
-#if defined( SUN ) && defined( _REENTRANT )
- LOCK_LDAP(ld);
-#endif
- if ( ld->ld_cache != NULLLDCACHE ) {
- ld->ld_cache->lc_options = opts;
- }
-#if defined( SUN ) && defined( _REENTRANT )
- UNLOCK_LDAP(ld);
-#endif
-}
-
-
-void
-ldap_destroy_cache( LDAP *ld )
-{
-#if defined( SUN ) && defined( _REENTRANT )
- LOCK_LDAP(ld);
-#endif
- if ( ld->ld_cache != NULLLDCACHE ) {
- ldap_flush_cache( ld );
- free( (char *)ld->ld_cache );
- ld->ld_cache = NULLLDCACHE;
- }
-#if defined( SUN ) && defined( _REENTRANT )
- UNLOCK_LDAP(ld);
-#endif
-}
-
-
-void
-ldap_flush_cache( LDAP *ld )
-{
- int i;
- LDAPMessage *m, *next;
-
-#if defined( SUN ) && defined( _REENTRANT )
- LOCK_LDAP(ld);
-#endif
- Debug( LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 90, "ldap_flush_cache\n"), 0, 0, 0 );
-
- if ( ld->ld_cache != NULLLDCACHE ) {
- /* delete all requests in the queue */
- for ( m = ld->ld_cache->lc_requests; m != NULLMSG; m = next ) {
- next = m->lm_next;
- ldap_msgfree( m );
- }
- ld->ld_cache->lc_requests = NULLMSG;
-
- /* delete all messages in the cache */
- for ( i = 0; i < LDAP_CACHE_BUCKETS; ++i ) {
- for ( m = ld->ld_cache->lc_buckets[ i ];
- m != NULLMSG; m = next ) {
- next = m->lm_next;
- ldap_msgfree( m );
- }
- ld->ld_cache->lc_buckets[ i ] = NULLMSG;
- }
- ld->ld_cache->lc_memused = sizeof( LDAPCache );
- }
-#if defined( SUN ) && defined( _REENTRANT )
- UNLOCK_LDAP(ld);
-#endif
-}
-
-
-void
-ldap_uncache_request( LDAP *ld, int msgid )
-{
-#if defined( SUN ) && defined( _REENTRANT )
- LOCK_LDAP(ld);
-#endif
- Debug( LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 91, "ldap_uncache_request %1$d ld_cache %2$x\n"),
- msgid, ld->ld_cache, 0 );
-
- uncache_entry_or_req( ld, NULL, msgid );
-#if defined( SUN ) && defined( _REENTRANT )
- UNLOCK_LDAP(ld);
-#endif
-}
-
-
-void
-ldap_uncache_entry( LDAP *ld, char *dn )
-{
-#if defined( SUN ) && defined( _REENTRANT )
- LOCK_LDAP(ld);
-#endif
- Debug( LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 92, "ldap_uncache_entry %1$s ld_cache %2$x\n"),
- dn, ld->ld_cache, 0 );
-
- uncache_entry_or_req( ld, dn, 0 );
-#if defined( SUN ) && defined( _REENTRANT )
- UNLOCK_LDAP(ld);
-#endif
-}
-
-
-static void
-uncache_entry_or_req( LDAP *ld,
- char *dn, /* if non-NULL, uncache entry */
- int msgid ) /* request to uncache (if dn == NULL) */
-{
- int i;
- LDAPMessage *m, *prev, *next;
-
- Debug( LDAP_DEBUG_TRACE,
- catgets(slapdcat, 1, 93, "ldap_uncache_entry_or_req dn %1$s msgid %2$d ld_cache %3$x\n"),
- dn, msgid, ld->ld_cache );
-
- if ( ld->ld_cache == NULLLDCACHE ) {
- return;
- }
-
- /* first check the request queue */
- prev = NULLMSG;
- for ( m = ld->ld_cache->lc_requests; m != NULLMSG; m = next ) {
- next = m->lm_next;
- if (( dn != NULL && chain_contains_dn( m, dn )) ||
- ( dn == NULL && m->lm_msgid == msgid )) {
- if ( prev == NULLMSG ) {
- ld->ld_cache->lc_requests = next;
- } else {
- prev->lm_next = next;
- }
- ld->ld_cache->lc_memused -= msg_size( m );
- ldap_msgfree( m );
- } else {
- prev = m;
- }
- }
-
- /* now check the rest of the cache */
- for ( i = 0; i < LDAP_CACHE_BUCKETS; ++i ) {
- prev = NULLMSG;
- for ( m = ld->ld_cache->lc_buckets[ i ]; m != NULLMSG;
- m = next ) {
- next = m->lm_next;
- if (( dn != NULL && chain_contains_dn( m, dn )) ||
- ( dn == NULL && m->lm_msgid == msgid )) {
- if ( prev == NULLMSG ) {
- ld->ld_cache->lc_buckets[ i ] = next;
- } else {
- prev->lm_next = next;
- }
- ld->ld_cache->lc_memused -= msg_size( m );
- ldap_msgfree( m );
- } else {
- prev = m;
- }
- }
- }
-}
-
-
-void
-add_request_to_cache( LDAP *ld, unsigned int msgtype, BerElement *request )
-{
- LDAPMessage *new;
- size_t len;
-
- Debug( LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 94, "add_request_to_cache\n"), 0, 0, 0 );
-
- ld->ld_errno = LDAP_SUCCESS;
- if ( ld->ld_cache == NULLLDCACHE ||
- ( ld->ld_cache->lc_enabled == 0 )) {
- return;
- }
-
- if (( new = (LDAPMessage *) calloc( 1, sizeof(LDAPMessage) ))
- != NULL ) {
- if (( new->lm_ber = alloc_ber_with_options( ld )) == NULLBER ) {
- free( (char *)new );
- return;
- }
- len = request->ber_ptr - request->ber_buf;
- if (( new->lm_ber->ber_buf = (char *) malloc( len ))
- == NULL ) {
- ber_free( new->lm_ber, 0 );
- free( (char *)new );
- ld->ld_errno = LDAP_NO_MEMORY;
- return;
- }
- SAFEMEMCPY( new->lm_ber->ber_buf, request->ber_buf, len );
- new->lm_ber->ber_ptr = new->lm_ber->ber_buf;
- new->lm_ber->ber_end = new->lm_ber->ber_buf + len;
- new->lm_msgid = ld->ld_msgid;
- new->lm_msgtype = (int) msgtype;;
- new->lm_next = ld->ld_cache->lc_requests;
- ld->ld_cache->lc_requests = new;
- } else {
- ld->ld_errno = LDAP_NO_MEMORY;
- }
-}
-
-
-void
-add_result_to_cache( LDAP *ld, LDAPMessage *result )
-{
- LDAPMessage *m, **mp, *req, *new, *prev;
- int err, keep;
-
- Debug( LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 95, "add_result_to_cache: id %1$d, type %2$d\n"),
- result->lm_msgid, result->lm_msgtype, 0 );
-
- if ( ld->ld_cache == NULLLDCACHE ||
- ( ld->ld_cache->lc_enabled == 0 )) {
- Debug( LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 96, "artc: cache disabled\n"), 0, 0, 0 );
- return;
- }
-
- if ( result->lm_msgtype != LDAP_RES_SEARCH_ENTRY &&
- result->lm_msgtype != LDAP_RES_SEARCH_RESULT &&
- result->lm_msgtype != LDAP_RES_SEARCH_REFERENCE &&
- result->lm_msgtype != LDAP_RES_COMPARE ) {
- /*
- * only cache search and compare operations
- */
- Debug( LDAP_DEBUG_TRACE,
- catgets(slapdcat, 1, 97, "artc: only caching search & compare operations\n"), 0, 0, 0 );
- return;
- }
-
- /*
- * if corresponding request is in the lc_requests list, add this
- * result to it. if this result completes the results for the
- * request, add the request/result chain to the cache proper.
- */
- prev = NULLMSG;
- for ( m = ld->ld_cache->lc_requests; m != NULL; m = m->lm_next ) {
- if ( m->lm_msgid == result->lm_msgid ) {
- break;
- }
- prev = m;
- }
-
- if ( m != NULLMSG ) { /* found request; add to end of chain */
- req = m;
- for ( ; m->lm_chain != NULLMSG; m = m->lm_chain )
- ;
- if (( new = msg_dup( result )) != NULLMSG ) {
- new->lm_chain = NULLMSG;
- m->lm_chain = new;
- Debug( LDAP_DEBUG_TRACE,
- catgets(slapdcat, 1, 98, "artc: result added to cache request chain\n"),
- 0, 0, 0 );
- }
- if ( result->lm_msgtype == LDAP_RES_SEARCH_RESULT ||
- result->lm_msgtype == LDAP_RES_COMPARE ) {
- /*
- * this result completes the chain of results
- * add to cache proper if appropriate
- */
- keep = 0; /* pessimistic */
- err = ldap_result2error( ld, result, 0 );
- if ( err == LDAP_SUCCESS ||
- ( result->lm_msgtype == LDAP_RES_COMPARE &&
- ( err == LDAP_COMPARE_FALSE ||
- err == LDAP_COMPARE_TRUE ||
- err == LDAP_NO_SUCH_ATTRIBUTE ))) {
- keep = 1;
- }
-
- if ( ld->ld_cache->lc_options == 0 ) {
- if ( err == LDAP_SIZELIMIT_EXCEEDED ) {
- keep = 1;
- }
- } else if (( ld->ld_cache->lc_options &
- LDAP_CACHE_OPT_CACHEALLERRS ) != 0 ) {
- keep = 1;
- }
-
- if ( prev == NULLMSG ) {
- ld->ld_cache->lc_requests = req->lm_next;
- } else {
- prev->lm_next = req->lm_next;
- }
-
- if ( !keep ) {
- Debug( LDAP_DEBUG_TRACE,
- catgets(slapdcat, 1, 99, "artc: not caching result with error %d\n"),
- err, 0, 0 );
- ldap_msgfree( req );
- } else {
- mp = &ld->ld_cache->lc_buckets[
- cache_hash( req->lm_ber ) ];
- req->lm_next = *mp;
- *mp = req;
- req->lm_time = time( NULL );
- ld->ld_cache->lc_memused += msg_size( req );
- check_cache_memused( ld->ld_cache );
- Debug( LDAP_DEBUG_TRACE,
- catgets(slapdcat, 1, 100, "artc: cached result with error %d\n"),
- err, 0, 0 );
- }
- }
- } else {
- Debug( LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 101, "artc: msgid not in request list\n"),
- 0, 0, 0 );
- }
-}
-
-
-/*
- * look in the cache for this request
- * return 0 if found, -1 if not
- * if found, the corresponding result messages are added to the incoming
- * queue with the correct (new) msgid so that subsequent ldap_result calls
- * will find them.
- */
-int
-check_cache( LDAP *ld, unsigned int msgtype, BerElement *request )
-{
- LDAPMessage *m, *new, *prev, *next;
- BerElement reqber;
- int first, hash;
- unsigned long validtime;
-
- Debug( LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 102, "check_cache\n"), 0, 0, 0 );
-
- if ( ld->ld_cache == NULLLDCACHE ||
- ( ld->ld_cache->lc_enabled == 0 )) {
- return( -1 );
- }
-
- reqber.ber_buf = reqber.ber_ptr = request->ber_buf;
- reqber.ber_end = request->ber_ptr;
-
- validtime = time( NULL ) - ld->ld_cache->lc_timeout;
-
- prev = NULLMSG;
- hash = cache_hash( &reqber );
- for ( m = ld->ld_cache->lc_buckets[ hash ]; m != NULLMSG; m = next ) {
- Debug( LDAP_DEBUG_TRACE,catgets(slapdcat, 1, 103, "cc: examining id %1$d,type %2$d\n"),
- m->lm_msgid, m->lm_msgtype, 0 );
- if ( m->lm_time < validtime ) {
- /* delete expired message */
- next = m->lm_next;
- if ( prev == NULL ) {
- ld->ld_cache->lc_buckets[ hash ] = next;
- } else {
- prev->lm_next = next;
- }
- Debug( LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 104, "cc: expired id %d\n"),
- m->lm_msgid, 0, 0 );
- ld->ld_cache->lc_memused -= msg_size( m );
- ldap_msgfree( m );
- } else {
- if ( m->lm_msgtype == msgtype &&
- request_cmp( m->lm_ber, &reqber ) == 0 ) {
- break;
- }
- next = m->lm_next;
- prev = m;
- }
- }
-
- if ( m == NULLMSG ) {
- return( -1 );
- }
-
- /*
- * add duplicates of responses to incoming queue
- */
- first = 1;
-#if defined( SUN ) && defined( _REENTRANT )
- LOCK_RESPONSE(ld);
-#endif
- for ( m = m->lm_chain; m != NULLMSG; m = m->lm_chain ) {
- if (( new = msg_dup( m )) == NULLMSG ) {
-#if defined( SUN ) && defined( _REENTRANT )
- UNLOCK_RESPONSE(ld);
-#endif
- return( -1 );
- }
-
- new->lm_msgid = ld->ld_msgid;
- new->lm_chain = NULLMSG;
- if ( first ) {
- new->lm_next = ld->ld_responses;
- ld->ld_responses = new;
- first = 0;
- } else {
- prev->lm_chain = new;
- }
- prev = new;
- Debug( LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 105, "cc: added type %d\n"),
- new->lm_msgtype, 0, 0 );
- }
-
- Debug( LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 106, "cc: result returned from cache\n"), 0, 0, 0 );
-#if defined( SUN ) && defined( _REENTRANT )
- UNLOCK_RESPONSE(ld);
-#endif
- return( 0 );
-}
-
-
-static int
-cache_hash( BerElement *ber )
-{
- BerElement bercpy;
- unsigned int len;
-
- /*
- * just take the length of the packet and mod with # of buckets
- */
- bercpy = *ber;
- if ( ber_skip_tag( &bercpy, &len ) == LBER_ERROR
- || ber_scanf( &bercpy, "x" ) == LBER_ERROR ) {
- len = 0; /* punt: just return zero */
- } else {
- len = (int) ( bercpy.ber_end - bercpy.ber_ptr );
- }
-
- Debug( LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 107, "cache_hash: len is %1$ld, returning %2$ld\n"),
- len, len % LDAP_CACHE_BUCKETS, 0 );
- return ( len % LDAP_CACHE_BUCKETS );
-}
-
-
-static LDAPMessage *
-msg_dup( LDAPMessage *msg )
-{
- LDAPMessage *new;
- size_t len;
-
- if (( new = (LDAPMessage *)malloc( sizeof(LDAPMessage))) != NULL ) {
- *new = *msg; /* struct copy */
- if (( new->lm_ber = ber_dup( msg->lm_ber )) == NULLBER ) {
- free( (char *)new );
- return( NULLMSG );
- }
- len = msg->lm_ber->ber_end - msg->lm_ber->ber_buf;
- if (( new->lm_ber->ber_buf = (char *) malloc( len )) == NULL ) {
- ber_free( new->lm_ber, 0 );
- free( (char *)new );
- return( NULLMSG );
- }
- SAFEMEMCPY( new->lm_ber->ber_buf, msg->lm_ber->ber_buf, len );
-
- new->lm_ber->ber_ptr = new->lm_ber->ber_buf +
- ( msg->lm_ber->ber_ptr - msg->lm_ber->ber_buf );
- new->lm_ber->ber_end = new->lm_ber->ber_buf + len;
- }
-
- return( new );
-}
-
-
-static int
-request_cmp( BerElement *req1, BerElement *req2 )
-{
- unsigned int len;
- size_t slen;
- BerElement r1, r2;
-
- r1 = *req1; /* struct copies */
- r2 = *req2;
-
- /*
- * skip the enclosing tags (sequence markers) and the msg ids
- */
- if ( ber_skip_tag( &r1, &len ) == LBER_ERROR || ber_scanf( &r1, "x" )
- == LBER_ERROR ) {
- return( -1 );
- }
- if ( ber_skip_tag( &r2, &len ) == LBER_ERROR || ber_scanf( &r2, "x" )
- == LBER_ERROR ) {
- return( -1 );
- }
-
- /*
- * check remaining length and bytes if necessary
- */
- if (( slen = r1.ber_end - r1.ber_ptr ) != r2.ber_end - r2.ber_ptr ) {
- return( -1 ); /* different lengths */
- }
- return( memcmp( r1.ber_ptr, r2.ber_ptr, slen ));
-}
-
-
-static int
-chain_contains_dn( LDAPMessage *msg, char *dn )
-{
- LDAPMessage *m;
- BerElement ber;
- int msgid;
- char *s;
- int rc;
-
-
- /*
- * first check the base or dn of the request
- */
- ber = *msg->lm_ber; /* struct copy */
- if ( ber_scanf( &ber, "{i{a", &msgid, &s ) != LBER_ERROR ) {
- rc = ( strcasecmp( dn, s ) == 0 ) ? 1 : 0;
- free( s );
- if ( rc != 0 ) {
- return( rc );
- }
- }
-
- if ( msg->lm_msgtype == LDAP_REQ_COMPARE ) {
- return( 0 );
- }
-
- /*
- * now check the dn of each search result
- */
- rc = 0;
- for ( m = msg->lm_chain; m != NULLMSG && rc == 0 ; m = m->lm_chain ) {
- if ( m->lm_msgtype != LDAP_RES_SEARCH_ENTRY ) {
- continue;
- }
- ber = *m->lm_ber; /* struct copy */
- if ( ber_scanf( &ber, "{a", &s ) != LBER_ERROR ) {
- rc = ( strcasecmp( dn, s ) == 0 ) ? 1 : 0;
- free( s );
- }
- }
-
- return( rc );
-}
-
-
-static ssize_t
-msg_size( LDAPMessage *msg )
-{
- LDAPMessage *m;
- ssize_t size;
-
- size = 0;
- for ( m = msg; m != NULLMSG; m = m->lm_chain ) {
- size += sizeof( LDAPMessage ) + m->lm_ber->ber_end -
- m->lm_ber->ber_buf;
- }
-
- return( size );
-}
-
-
-#define THRESHOLD_FACTOR 3 / 4
-#define SIZE_FACTOR 2 / 3
-
-static void
-check_cache_memused( LDAPCache *lc )
-{
-/*
- * this routine is called to check if the cache is too big (lc_maxmem >
- * minimum cache size and lc_memused > lc_maxmem). If too big, it reduces
- * the cache size to < SIZE_FACTOR * lc_maxmem. The algorithm is as follows:
- * remove_threshold = lc_timeout seconds;
- * do {
- * remove everything older than remove_threshold seconds;
- * remove_threshold = remove_threshold * THRESHOLD_FACTOR;
- * } while ( cache size is > SIZE_FACTOR * lc_maxmem )
- */
- int i;
- unsigned long remove_threshold, validtime;
- LDAPMessage *m, *prev, *next;
-
- Debug( LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 108, "check_cache_memused: %1$ld bytes in use (%2$ld max)\n"),
- lc->lc_memused, lc->lc_maxmem, 0 );
-
- if ( lc->lc_maxmem <= sizeof( LDAPCache )
- || lc->lc_memused <= lc->lc_maxmem * SIZE_FACTOR ) {
- return;
- }
-
- remove_threshold = lc->lc_timeout;
- while ( lc->lc_memused > lc->lc_maxmem * SIZE_FACTOR ) {
- validtime = time( NULL ) - remove_threshold;
- for ( i = 0; i < LDAP_CACHE_BUCKETS; ++i ) {
- prev = NULLMSG;
- for ( m = lc->lc_buckets[ i ]; m != NULLMSG;
- m = next ) {
- next = m->lm_next;
- if ( m->lm_time < validtime ) {
- if ( prev == NULLMSG ) {
- lc->lc_buckets[ i ] = next;
- } else {
- prev->lm_next = next;
- }
- lc->lc_memused -= msg_size( m );
- Debug( LDAP_DEBUG_TRACE,
- catgets(slapdcat, 1, 109, "ccm: removed %d\n"),
- m->lm_msgid, 0, 0 );
- ldap_msgfree( m );
- } else {
- prev = m;
- }
- }
- }
- remove_threshold *= THRESHOLD_FACTOR;
- }
-
- Debug( LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 110, "ccm: reduced usage to %ld bytes\n"),
- lc->lc_memused, 0, 0 );
-}
-
-#endif /* !NO_CACHE */
diff --git a/usr/src/lib/libldap4/common/charset.c b/usr/src/lib/libldap4/common/charset.c
deleted file mode 100644
index e1c9b9d9be..0000000000
--- a/usr/src/lib/libldap4/common/charset.c
+++ /dev/null
@@ -1,1869 +0,0 @@
-/*
- * Portions Copyright 1998 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*
- * Copyright (c) 1995 Regents of the University of Michigan.
- * All rights reserved.
- *
- * charset.c
- */
-
-#if defined( DOS ) || defined( _WIN32 )
-/*
- * This MUST precede "#ifdef STR_TRANSLATION"
- * because STR_TRANSLATION and friends are defined in msdos.h.
- */
-#include "msdos.h"
-#endif /* DOS */
-
-#ifdef STR_TRANSLATION
-
-#ifndef lint
-static char copyright[] = "@(#) Copyright (c) 1995 Regents of the University of Michigan.\nAll rights reserved.\n";
-#endif
-
-#include <stdio.h>
-#include <string.h>
-
-#ifdef MACOS
-#include <stdlib.h>
-#include "macos.h"
-#endif /* MACOS */
-
-#if !defined(MACOS) && !defined(DOS) && !defined( _WIN32 ) && !defined(VMS)
-#include <sys/time.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/param.h>
-#endif
-#include "lber.h"
-#include "ldap.h"
-#include "ldap-private.h"
-#include "ldap-int.h"
-
-
-void
-ldap_set_string_translators( LDAP *ld, BERTranslateProc encode_proc,
- BERTranslateProc decode_proc )
-{
-#if defined( SUN ) && defined( _REENTRANT )
- LOCK_LDAP(ld);
-#endif
- ld->ld_lber_encode_translate_proc = encode_proc;
- ld->ld_lber_decode_translate_proc = decode_proc;
-#if defined( SUN ) && defined( _REENTRANT )
- UNLOCK_LDAP(ld);
-#endif
-}
-
-
-void
-ldap_enable_translation( LDAP *ld, LDAPMessage *entry, int enable )
-{
- char *optionsp;
-
-#if defined( SUN ) && defined( _REENTRANT )
- LOCK_LDAP(ld);
-#endif
- optionsp = ( entry == NULLMSG ) ? &ld->ld_lberoptions :
- &entry->lm_ber->ber_options;
-
- if ( enable ) {
- *optionsp |= LBER_TRANSLATE_STRINGS;
- } else {
- *optionsp &= ~LBER_TRANSLATE_STRINGS;
- }
-#if defined( SUN ) && defined( _REENTRANT )
- UNLOCK_LDAP(ld);
-#endif
-}
-
-
-int
-ldap_translate_from_t61( LDAP *ld, char **bufp, unsigned int *lenp,
- int free_input )
-{
-#if defined( SUN ) && defined( _REENTRANT )
- BERTranslateProc decode_proc;
-
- LOCK_LDAP(ld);
-#endif
- if ( ld->ld_lber_decode_translate_proc == NULL ) {
-#if defined( SUN ) && defined( _REENTRANT )
- UNLOCK_LDAP(ld);
-#endif
- return( LDAP_SUCCESS );
- }
-#if defined( SUN ) && defined( _REENTRANT )
- decode_proc = ld->ld_lber_decode_translate_proc;
- UNLOCK_LDAP(ld);
-
- return( (*decode_proc)( bufp, lenp, free_input ));
-#else
- return( (*ld->ld_lber_decode_translate_proc)( bufp, lenp, free_input ));
-#endif
-}
-
-
-int
-ldap_translate_to_t61( LDAP *ld, char **bufp, unsigned int *lenp,
- int free_input )
-{
-#if defined( SUN ) && defined( _REENTRANT )
- BERTranslateProc encode_proc;
-
- LOCK_LDAP(ld);
-#endif
- if ( ld->ld_lber_encode_translate_proc == NULL ) {
-#if defined( SUN ) && defined( _REENTRANT )
- UNLOCK_LDAP(ld);
-#endif
- return( LDAP_SUCCESS );
- }
-
-#if defined( SUN ) && defined( _REENTRANT )
- encode_proc = ld->ld_lber_encode_translate_proc;
- UNLOCK_LDAP(ld);
- return( (*encode_proc)( bufp, lenp, free_input ));
-#else
- return( (*ld->ld_lber_encode_translate_proc)( bufp, lenp, free_input ));
-#endif
-}
-
-
-/*
- ** Character translation routine notes:
- *
- * On entry: bufp points to a "string" to be converted (not necessarily
- * zero-terminated) and buflenp points to the length of the buffer.
- *
- * On exit: bufp should point to a malloc'd result. If free_input is
- * non-zero then the original bufp will be freed. *buflenp should be
- * set to the new length. Zero bytes in the input buffer must be left
- * as zero bytes.
- *
- * Return values: any ldap error code (LDAP_SUCCESS if all goes well).
- */
-
-
-#ifdef LDAP_CHARSET_8859
-
-#if LDAP_CHARSET_8859 == 88591
-#define ISO_8859 1
-#elif LDAP_CHARSET_8859 == 88592
-#define ISO_8859 2
-#elif LDAP_CHARSET_8859 == 88593
-#define ISO_8859 3
-#elif LDAP_CHARSET_8859 == 88594
-#define ISO_8859 4
-#elif LDAP_CHARSET_8859 == 88595
-#define ISO_8859 5
-#elif LDAP_CHARSET_8859 == 88596
-#define ISO_8859 6
-#elif LDAP_CHARSET_8859 == 88597
-#define ISO_8859 7
-#elif LDAP_CHARSET_8859 == 88598
-#define ISO_8859 8
-#elif LDAP_CHARSET_8859 == 88599
-#define ISO_8859 9
-#elif LDAP_CHARSET_8859 == 885910
-#define ISO_8859 10
-#else
-#define ISO_8859 0
-#endif
-
-/*
- * the following ISO_8859 to/afrom T.61 character set translation code is
- * based on the code found in Enrique Silvestre Mora's iso-t61.c, found
- * as part of this package:
- * ftp://pereiii.uji.es/pub/uji-ftp/unix/ldap/iso-t61.translation.tar.Z
- * Enrique is now (10/95) at this address: enrique.silvestre@uv.es
- *
- * changes made by mcs@umich.edu 12 October 1995:
- * Change calling conventions of iso8859_t61() and t61_iso8859() to
- * match libldap conventions; rename to ldap_8859_to_t61() and
- * ldap_t61_to_8859().
- * Change conversion routines to deal with non-zero terminated strings.
- * ANSI-ize functions and include prototypes.
- */
-
-/* iso-t61.c - ISO-T61 translation routines (version: 0.2.1, July-1994) */
-/*
- * Copyright (c) 1994 Enrique Silvestre Mora, Universitat Jaume I, Spain.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms are permitted
- * provided that this notice is preserved and that due credit is given
- * to the Universitat Jaume I. The name of the University
- * may not be used to endorse or promote products derived from this
- * software without specific prior written permission. This software
- * is provided ``as is'' without express or implied warranty.
-*/
-
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-
-/* Character set used: ISO 8859-1, ISO 8859-2, ISO 8859-3, ... */
-/* #define ISO_8859 1 */
-
-#ifndef ISO_8859
-# define ISO_8859 0
-#endif
-
-typedef unsigned char Byte;
-typedef struct { Byte a, b; } Couple;
-
-#ifdef NEEDPROTOS
-static Byte *c_to_hh( Byte *o, Byte c );
-static Byte *c_to_cc( Byte *o, Couple *cc, Byte c );
-static int hh_to_c( Byte *h );
-static Byte *cc_to_t61( Byte *o, Byte *s );
-#else /* NEEDPROTOS */
-static Byte *c_to_hh();
-static Byte *c_to_cc();
-static int hh_to_c();
-static Byte *cc_to_t61();
-#endif /* NEEDPROTOS */
-
-/*
- Character choosed as base in diacritics alone: NO-BREAK SPACE.
- (The standard say it must be a blank space, 0x20.)
-*/
-#define ALONE 0xA0
-
-static Couple diacritic[16] = {
-#if (ISO_8859 == 1) || (ISO_8859 == 9)
- {0,0}, {'`',0}, {0xb4,0}, {'^',0},
- {'~',0}, {0xaf,0}, {'(',ALONE}, {'.',ALONE},
- {0xa8,0}, {0,0}, {'0',ALONE}, {0xb8,0},
- {0,0}, {'"',ALONE}, {';',ALONE}, {'<',ALONE},
-#elif (ISO_8859 == 2)
- {0,0}, {'`',0}, {0xb4,0}, {'^',0},
- {'~',0}, {'-',ALONE}, {0xa2,0}, {0xff,0},
- {0xa8,0}, {0,0}, {'0',ALONE}, {0xb8,0},
- {0,0}, {0xbd,0}, {0xb2,0}, {0xb7,0}
-#elif (ISO_8859 == 3)
- {0,0}, {'`',0}, {0xb4,0}, {'^',0},
- {'~',0}, {'-',ALONE}, {0xa2,0}, {0xff,0},
- {0xa8,0}, {0,0}, {'0',ALONE}, {0xb8,0},
- {0,0}, {'"',ALONE}, {';',ALONE}, {'<',ALONE}
-#elif (ISO_8859 == 4)
- {0,0}, {'`',0}, {0xb4,0}, {'^',0},
- {'~',0}, {0xaf,0}, {'(',ALONE}, {0xff,0},
- {0xa8,0}, {0,0}, {'0',ALONE}, {0xb8,0},
- {0,0}, {'"',ALONE}, {0xb2,0}, {0xb7,0}
-#else
- {0,0}, {'`',0}, {'\'',ALONE}, {'^',0},
- {'~',0}, {'-',ALONE}, {'(',ALONE}, {'.',ALONE},
- {':',ALONE}, {0,0}, {'0',ALONE}, {',',ALONE},
- {0,0}, {'"',ALONE}, {';',ALONE}, {'<',ALONE}
-#endif
-};
-
-/*
- --- T.61 (T.51) letters with diacritics: conversion to ISO 8859-n -----
- A, C, D, E, G, H, I, J, K,
- L, N, O, R, S, T, U, W, Y, Z.
- -----------------------------------------------------------------------
-*/
-static int letter_w_diacritic[16][38] = {
-#if (ISO_8859 == 1)
- 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0xc0,0, 0, 0xc8,0, 0, 0xcc,0, 0,
- 0, 0, 0xd2,0, 0, 0, 0xd9,0, 0, 0,
- 0xe0,0, 0, 0xe8,0, 0, 0xec,0, 0,
- 0, 0, 0xf2,0, 0, 0, 0xf9,0, 0, 0,
- 0xc1,-1, 0, 0xc9,0, 0, 0xcd,0, 0,
- -1, -1, 0xd3,-1, -1, 0, 0xda,0, 0xdd,-1,
- 0xe1,-1, 0, 0xe9,0, 0, 0xed,0, 0,
- -1, -1, 0xf3,-1, -1, 0, 0xfa,0, 0xfd,-1,
- 0xc2,-1, 0, 0xca,-1, -1, 0xce,-1, 0,
- 0, 0, 0xd4,0, -1, 0, 0xdb,-1, -1, 0,
- 0xe2,-1, 0, 0xea,-1, -1, 0xee,-1, 0,
- 0, 0, 0xf4,0, -1, 0, 0xfb,-1, -1, 0,
- 0xc3,0, 0, 0, 0, 0, -1, 0, 0,
- 0, 0xd1,0xd5,0, 0, 0, -1, 0, 0, 0,
- 0xe3,0, 0, 0, 0, 0, -1, 0, 0,
- 0, 0xf1,0xf5,0, 0, 0, -1, 0, 0, 0,
- -1, 0, 0, -1, 0, 0, -1, 0, 0,
- 0, 0, -1, 0, 0, 0, -1, 0, 0, 0,
- -1, 0, 0, -1, 0, 0, -1, 0, 0,
- 0, 0, -1, 0, 0, 0, -1, 0, 0, 0,
- -1, 0, 0, 0, -1, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, -1, 0, 0, 0,
- -1, 0, 0, 0, -1, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, -1, 0, 0, 0,
- 0, -1, 0, -1, -1, 0, -1, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, -1,
- 0, -1, 0, -1, -1, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, -1,
- 0xc4,0, 0, 0xcb,0, 0, 0xcf,0, 0,
- 0, 0, 0xd6,0, 0, 0, 0xdc,0, -1, 0,
- 0xe4,0, 0, 0xeb,0, 0, 0xef,0, 0,
- 0, 0, 0xf6,0, 0, 0, 0xfc,0, 0xff,0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0xc5,0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, -1, 0, 0, 0,
- 0xe5,0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, -1, 0, 0, 0,
- 0, 0xc7,0, 0, -1, 0, 0, 0, -1,
- -1, -1, 0, -1, -1, -1, 0, 0, 0, 0,
- 0, 0xe7,0, 0, -1, 0, 0, 0, -1,
- -1, -1, 0, -1, -1, -1, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, -1, 0, 0, 0, -1, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, -1, 0, 0, 0, -1, 0, 0, 0,
- -1, 0, 0, -1, 0, 0, -1, 0, 0,
- 0, 0, 0, 0, 0, 0, -1, 0, 0, 0,
- -1, 0, 0, -1, 0, 0, -1, 0, 0,
- 0, 0, 0, 0, 0, 0, -1, 0, 0, 0,
- 0, -1, -1, -1, 0, 0, 0, 0, 0,
- -1, -1, 0, -1, -1, -1, 0, 0, 0, -1,
- 0, -1, -1, -1, 0, 0, 0, 0, 0,
- -1, -1, 0, -1, -1, -1, 0, 0, 0, -1
-#elif (ISO_8859 == 2)
- 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- -1, 0, 0, -1, 0, 0, -1, 0, 0,
- 0, 0, -1, 0, 0, 0, -1, 0, 0, 0,
- -1, 0, 0, -1, 0, 0, -1, 0, 0,
- 0, 0, -1, 0, 0, 0, -1, 0, 0, 0,
- 0xc1,0xc6,0, 0xc9,0, 0, 0xcd,0, 0,
- 0xc5,0xd1,0xd3,0xc0,0xa6,0, 0xda,0, 0xdd,0xac,
- 0xe1,0xe6,0, 0xe9,0, 0, 0xed,0, 0,
- 0xe5,0xf1,0xf3,0xe0,0xb6,0, 0xfa,0, 0xfd,0xbc,
- 0xc2,-1, 0, -1, -1, -1, 0xce,-1, 0,
- 0, 0, 0xd4,0, -1, 0, -1, -1, -1, 0,
- 0xe2,-1, 0, -1, -1, -1, 0xee,-1, 0,
- 0, 0, 0xf4,0, -1, 0, -1, -1, -1, 0,
- -1, 0, 0, 0, 0, 0, -1, 0, 0,
- 0, -1, -1, 0, 0, 0, -1, 0, 0, 0,
- -1, 0, 0, 0, 0, 0, -1, 0, 0,
- 0, -1, -1, 0, 0, 0, -1, 0, 0, 0,
- -1, 0, 0, -1, 0, 0, -1, 0, 0,
- 0, 0, -1, 0, 0, 0, -1, 0, 0, 0,
- -1, 0, 0, -1, 0, 0, -1, 0, 0,
- 0, 0, -1, 0, 0, 0, -1, 0, 0, 0,
- 0xc3,0, 0, 0, -1, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, -1, 0, 0, 0,
- 0xe3,0, 0, 0, -1, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, -1, 0, 0, 0,
- 0, -1, 0, -1, -1, 0, -1, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xaf,
- 0, -1, 0, -1, -1, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xbf,
- 0xc4,0, 0, 0xcb,0, 0, -1, 0, 0,
- 0, 0, 0xd6,0, 0, 0, 0xdc,0, -1, 0,
- 0xe4,0, 0, 0xeb,0, 0, -1, 0, 0,
- 0, 0, 0xf6,0, 0, 0, 0xfc,0, -1, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- -1, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0xd9,0, 0, 0,
- -1, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0xf9,0, 0, 0,
- 0, 0xc7,0, 0, -1, 0, 0, 0, -1,
- -1, -1, 0, -1, 0xaa,0xde,0, 0, 0, 0,
- 0, 0xe7,0, 0, -1, 0, 0, 0, -1,
- -1, -1, 0, -1, 0xba,0xfe,0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0xd5,0, 0, 0, 0xdb,0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0xf5,0, 0, 0, 0xfb,0, 0, 0,
- 0xa1,0, 0, 0xca,0, 0, -1, 0, 0,
- 0, 0, 0, 0, 0, 0, -1, 0, 0, 0,
- 0xb1,0, 0, 0xea,0, 0, -1, 0, 0,
- 0, 0, 0, 0, 0, 0, -1, 0, 0, 0,
- 0, 0xc8,0xcf,0xcc,0, 0, 0, 0, 0,
- 0xa5,0xd2,0, 0xd8,0xa9,0xab,0, 0, 0, 0xae,
- 0, 0xe8,0xef,0xec,0, 0, 0, 0, 0,
- 0xb5,0xf2,0, 0xf8,0xb9,0xbb,0, 0, 0, 0xbe
-#elif (ISO_8859 == 3)
- 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0xc0,0, 0, 0xc8,0, 0, 0xcc,0, 0,
- 0, 0, 0xd2,0, 0, 0, 0xd9,0, 0, 0,
- 0xe0,0, 0, 0xe8,0, 0, 0xec,0, 0,
- 0, 0, 0xf2,0, 0, 0, 0xf9,0, 0, 0,
- 0xc1,-1, 0, 0xc9,0, 0, 0xcd,0, 0,
- -1, -1, 0xd3,-1, -1, 0, 0xda,0, -1, -1,
- 0xe1,-1, 0, 0xe9,0, 0, 0xed,0, 0,
- -1, -1, 0xf3,-1, -1, 0, 0xfa,0, -1, -1,
- 0xc2,0xc6,0, 0xca,0xd8,0xa6,0xce,0xac,0,
- 0, 0, 0xd4,0, 0xde,0, 0xdb,-1, -1, 0,
- 0xe2,0xe6,0, 0xea,0xf8,0xb6,0xee,0xbc,0,
- 0, 0, 0xf4,0, 0xfe,0, 0xfb,-1, -1, 0,
- -1, 0, 0, 0, 0, 0, -1, 0, 0,
- 0, 0xd1,-1, 0, 0, 0, -1, 0, 0, 0,
- -1, 0, 0, 0, 0, 0, -1, 0, 0,
- 0, 0xf1,-1, 0, 0, 0, -1, 0, 0, 0,
- -1, 0, 0, -1, 0, 0, -1, 0, 0,
- 0, 0, -1, 0, 0, 0, -1, 0, 0, 0,
- -1, 0, 0, -1, 0, 0, -1, 0, 0,
- 0, 0, -1, 0, 0, 0, -1, 0, 0, 0,
- -1, 0, 0, 0, 0xab,0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0xdd,0, 0, 0,
- -1, 0, 0, 0, 0xbb,0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0xfd,0, 0, 0,
- 0, 0xc5,0, -1, 0xd5,0, 0xa9,0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xaf,
- 0, 0xe5,0, -1, 0xf5,0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0xbf,
- 0xc4,0, 0, 0xcb,0, 0, 0xcf,0, 0,
- 0, 0, 0xd6,0, 0, 0, 0xdc,0, -1, 0,
- 0xe4,0, 0, 0xeb,0, 0, 0xef,0, 0,
- 0, 0, 0xf6,0, 0, 0, 0xfc,0, -1, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- -1, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, -1, 0, 0, 0,
- -1, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, -1, 0, 0, 0,
- 0, 0xc7,0, 0, -1, 0, 0, 0, -1,
- -1, -1, 0, -1, 0xaa,-1, 0, 0, 0, 0,
- 0, 0xe7,0, 0, -1, 0, 0, 0, -1,
- -1, -1, 0, -1, 0xba,-1, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, -1, 0, 0, 0, -1, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, -1, 0, 0, 0, -1, 0, 0, 0,
- -1, 0, 0, -1, 0, 0, -1, 0, 0,
- 0, 0, 0, 0, 0, 0, -1, 0, 0, 0,
- -1, 0, 0, -1, 0, 0, -1, 0, 0,
- 0, 0, 0, 0, 0, 0, -1, 0, 0, 0,
- 0, -1, -1, -1, 0, 0, 0, 0, 0,
- -1, -1, 0, -1, -1, -1, 0, 0, 0, -1,
- 0, -1, -1, -1, 0, 0, 0, 0, 0,
- -1, -1, 0, -1, -1, -1, 0, 0, 0, -1
-#elif (ISO_8859 == 4)
- 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- -1, 0, 0, -1, 0, 0, -1, 0, 0,
- 0, 0, -1, 0, 0, 0, -1, 0, 0, 0,
- -1, 0, 0, -1, 0, 0, -1, 0, 0,
- 0, 0, -1, 0, 0, 0, -1, 0, 0, 0,
- 0xc1,-1, 0, 0xc9,0, 0, 0xcd,0, 0,
- -1, -1, -1, -1, -1, 0, 0xda,0, -1, -1,
- 0xe1,-1, 0, 0xe9,0, 0, 0xed,0, 0,
- -1, -1, -1, -1, -1, 0, 0xfa,0, -1, -1,
- 0xc2,-1, 0, -1, -1, -1, 0xce,-1, 0,
- 0, 0, 0xd4,0, -1, 0, 0xdb,-1, -1, 0,
- 0xe2,-1, 0, -1, -1, -1, 0xee,-1, 0,
- 0, 0, 0xf4,0, -1, 0, 0xfb,-1, -1, 0,
- 0xc3,0, 0, 0, 0, 0, 0xa5,0, 0,
- 0, -1, 0xd5,0, 0, 0, 0xdd,0, 0, 0,
- 0xe3,0, 0, 0, 0, 0, 0xb5,0, 0,
- 0, -1, 0xf5,0, 0, 0, 0xfd,0, 0, 0,
- 0xc0,0, 0, 0xaa,0, 0, 0xcf,0, 0,
- 0, 0, 0xd2,0, 0, 0, 0xde,0, 0, 0,
- 0xe0,0, 0, 0xba,0, 0, 0xef,0, 0,
- 0, 0, 0xf2,0, 0, 0, 0xfe,0, 0, 0,
- -1, 0, 0, 0, -1, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, -1, 0, 0, 0,
- -1, 0, 0, 0, -1, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, -1, 0, 0, 0,
- 0, -1, 0, 0xcc,-1, 0, -1, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, -1,
- 0, -1, 0, 0xec,-1, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, -1,
- 0xc4,0, 0, 0xcb,0, 0, -1, 0, 0,
- 0, 0, 0xd6,0, 0, 0, 0xdc,0, -1, 0,
- 0xe4,0, 0, 0xeb,0, 0, -1, 0, 0,
- 0, 0, 0xf6,0, 0, 0, 0xfc,0, -1, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0xc5,0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, -1, 0, 0, 0,
- 0xe5,0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, -1, 0, 0, 0,
- 0, -1, 0, 0, 0xab,0, 0, 0, 0xd3,
- 0xa6,0xd1,0, 0xa3,-1, -1, 0, 0, 0, 0,
- 0, -1, 0, 0, 0xbb,0, 0, 0, 0xf3,
- 0xb6,0xf1,0, 0xb3,-1, -1, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, -1, 0, 0, 0, -1, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, -1, 0, 0, 0, -1, 0, 0, 0,
- 0xa1,0, 0, 0xca,0, 0, 0xc7,0, 0,
- 0, 0, 0, 0, 0, 0, 0xd9,0, 0, 0,
- 0xb1,0, 0, 0xea,0, 0, 0xe7,0, 0,
- 0, 0, 0, 0, 0, 0, 0xf9,0, 0, 0,
- 0, 0xc8,-1, -1, 0, 0, 0, 0, 0,
- -1, -1, 0, -1, 0xa9,-1, 0, 0, 0, 0xae,
- 0, 0xe8,-1, -1, 0, 0, 0, 0, 0,
- -1, -1, 0, -1, 0xb9,-1, 0, 0, 0, 0xbe
-#elif (ISO_8859 == 9)
- 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0xc0,0, 0, 0xc8,0, 0, 0xcc,0, 0,
- 0, 0, 0xd2,0, 0, 0, 0xd9,0, 0, 0,
- 0xe0,0, 0, 0xe8,0, 0, -1, 0, 0,
- 0, 0, 0xf2,0, 0, 0, 0xf9,0, 0, 0,
- 0xc1,-1, 0, 0xc9,0, 0, 0xcd,0, 0,
- -1, -1, 0xd3,-1, -1, 0, 0xda,0, -1, -1,
- 0xe1,-1, 0, 0xe9,0, 0, 0xed,0, 0,
- -1, -1, 0xf3,-1, -1, 0, 0xfa,0, -1, -1,
- 0xc2,-1, 0, 0xca,-1, -1, 0xce,-1, 0,
- 0, 0, 0xd4,0, -1, 0, 0xdb,-1, -1, 0,
- 0xe2,-1, 0, -1, -1, -1, 0xee,-1, 0,
- 0, 0, 0xf4,0, -1, 0, 0xfb,-1, -1, 0,
- 0xc3,0, 0, 0, 0, 0, -1, 0, 0,
- 0, 0xd1,0xd5,0, 0, 0, -1, 0, 0, 0,
- 0xe3,0, 0, 0, 0, 0, -1, 0, 0,
- 0, 0xf1,0xf5,0, 0, 0, -1, 0, 0, 0,
- -1, 0, 0, -1, 0, 0, -1, 0, 0,
- 0, 0, -1, 0, 0, 0, -1, 0, 0, 0,
- -1, 0, 0, -1, 0, 0, 0xef,0, 0,
- 0, 0, -1, 0, 0, 0, -1, 0, 0, 0,
- -1, 0, 0, 0, 0xd0,0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, -1, 0, 0, 0,
- -1, 0, 0, 0, 0xf0,0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, -1, 0, 0, 0,
- 0, -1, 0, -1, -1, 0, 0xdd,0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, -1,
- 0, -1, 0, 0xec,-1, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, -1,
- 0xc4,0, 0, 0xcb,0, 0, 0xcf,0, 0,
- 0, 0, 0xd6,0, 0, 0, 0xdc,0, -1, 0,
- 0xe4,0, 0, 0xeb,0, 0, -1, 0, 0,
- 0, 0, 0xf6,0, 0, 0, 0xfc,0, 0xff,0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0xc5,0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, -1, 0, 0, 0,
- 0xe5,0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, -1, 0, 0, 0,
- 0, 0xc7,0, 0, -1, 0, 0, 0, -1,
- -1, -1, 0, -1, 0xde,-1, 0, 0, 0, 0,
- 0, 0xe7,0, 0, -1, 0, 0, 0, -1,
- -1, -1, 0, -1, 0xfe,-1, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, -1, 0, 0, 0, -1, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, -1, 0, 0, 0, -1, 0, 0, 0,
- -1, 0, 0, -1, 0, 0, -1, 0, 0,
- 0, 0, 0, 0, 0, 0, -1, 0, 0, 0,
- -1, 0, 0, 0xea,0, 0, -1, 0, 0,
- 0, 0, 0, 0, 0, 0, -1, 0, 0, 0,
- 0, -1, -1, -1, 0, 0, 0, 0, 0,
- -1, -1, 0, -1, -1, -1, 0, 0, 0, -1,
- 0, -1, -1, -1, 0, 0, 0, 0, 0,
- -1, -1, 0, -1, -1, -1, 0, 0, 0, -1
-#elif (ISO_8859 == 10)
- 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- -1, 0, 0, -1, 0, 0, -1, 0, 0,
- 0, 0, -1, 0, 0, 0, -1, 0, 0, 0,
- -1, 0, 0, -1, 0, 0, -1, 0, 0,
- 0, 0, -1, 0, 0, 0, -1, 0, 0, 0,
- 0xc1,-1, 0, 0xc9,0, 0, 0xcd,0, 0,
- -1, -1, 0xd3,-1, -1, 0, 0xda,0, 0xdd,-1,
- 0xe1,-1, 0, 0xe9,0, 0, 0xed,0, 0,
- -1, -1, 0xf3,-1, -1, 0, 0xfa,0, 0xfd,-1,
- 0xc2,-1, 0, -1, -1, -1, 0xce,-1, 0,
- 0, 0, 0xd4,0, -1, 0, 0xdb,-1, -1, 0,
- 0xe2,-1, 0, -1, -1, -1, 0xee,-1, 0,
- 0, 0, 0xf4,0, -1, 0, 0xfb,-1, -1, 0,
- 0xc3,0, 0, 0, 0, 0, 0xa5,0, 0,
- 0, -1, 0xd5,0, 0, 0, 0xd7,0, 0, 0,
- 0xe3,0, 0, 0, 0, 0, 0xb5,0, 0,
- 0, -1, 0xf5,0, 0, 0, 0xf7,0, 0, 0,
- 0xc0,0, 0, 0xa2,0, 0, 0xa4,0, 0,
- 0, 0, 0xd2,0, 0, 0, 0xae,0, 0, 0,
- 0xe0,0, 0, 0xb2,0, 0, 0xb4,0, 0,
- 0, 0, 0xf2,0, 0, 0, 0xbe,0, 0, 0,
- -1, 0, 0, 0, -1, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, -1, 0, 0, 0,
- -1, 0, 0, 0, -1, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, -1, 0, 0, 0,
- 0, -1, 0, 0xcc,-1, 0, -1, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, -1,
- 0, -1, 0, 0xec,-1, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, -1,
- 0xc4,0, 0, 0xcb,0, 0, 0xcf,0, 0,
- 0, 0, 0xd6,0, 0, 0, 0xdc,0, -1, 0,
- 0xe4,0, 0, 0xeb,0, 0, 0xef,0, 0,
- 0, 0, 0xf6,0, 0, 0, 0xfc,0, -1, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0xc5,0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, -1, 0, 0, 0,
- 0xe5,0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, -1, 0, 0, 0,
- 0, -1, 0, 0, 0xa3,0, 0, 0, 0xa6,
- 0xa8,0xd1,0, -1, -1, -1, 0, 0, 0, 0,
- 0, -1, 0, 0, 0xb3,0, 0, 0, 0xb6,
- 0xb8,0xf1,0, -1, -1, -1, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, -1, 0, 0, 0, -1, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, -1, 0, 0, 0, -1, 0, 0, 0,
- 0xa1,0, 0, 0xca,0, 0, 0xc7,0, 0,
- 0, 0, 0, 0, 0, 0, 0xd9,0, 0, 0,
- 0xb1,0, 0, 0xea,0, 0, 0xe7,0, 0,
- 0, 0, 0, 0, 0, 0, 0xf9,0, 0, 0,
- 0, 0xc8,-1, -1, 0, 0, 0, 0, 0,
- -1, -1, 0, -1, 0xaa,-1, 0, 0, 0, 0xac,
- 0, 0xe8,-1, -1, 0, 0, 0, 0, 0,
- -1, -1, 0, -1, 0xba,-1, 0, 0, 0, 0xbc
-#else
- 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- -1, 0, 0, -1, 0, 0, -1, 0, 0,
- 0, 0, -1, 0, 0, 0, -1, 0, 0, 0,
- -1, 0, 0, -1, 0, 0, -1, 0, 0,
- 0, 0, -1, 0, 0, 0, -1, 0, 0, 0,
- -1, -1, 0, -1, 0, 0, -1, 0, 0,
- -1, -1, -1, -1, -1, 0, -1, 0, -1, -1,
- -1, -1, 0, -1, 0, 0, -1, 0, 0,
- -1, -1, -1, -1, -1, 0, -1, 0, -1, -1,
- -1, -1, 0, -1, -1, -1, -1, -1, 0,
- 0, 0, -1, 0, -1, 0, -1, -1, -1, 0,
- -1, -1, 0, -1, -1, -1, -1, -1, 0,
- 0, 0, -1, 0, -1, 0, -1, -1, -1, 0,
- -1, 0, 0, 0, 0, 0, -1, 0, 0,
- 0, -1, -1, 0, 0, 0, -1, 0, 0, 0,
- -1, 0, 0, 0, 0, 0, -1, 0, 0,
- 0, -1, -1, 0, 0, 0, -1, 0, 0, 0,
- -1, 0, 0, -1, 0, 0, -1, 0, 0,
- 0, 0, -1, 0, 0, 0, -1, 0, 0, 0,
- -1, 0, 0, -1, 0, 0, -1, 0, 0,
- 0, 0, -1, 0, 0, 0, -1, 0, 0, 0,
- -1, 0, 0, 0, -1, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, -1, 0, 0, 0,
- -1, 0, 0, 0, -1, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, -1, 0, 0, 0,
- 0, -1, 0, -1, -1, 0, -1, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, -1,
- 0, -1, 0, -1, -1, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, -1,
- -1, 0, 0, -1, 0, 0, -1, 0, 0,
- 0, 0, -1, 0, 0, 0, -1, 0, -1, 0,
- -1, 0, 0, -1, 0, 0, -1, 0, 0,
- 0, 0, -1, 0, 0, 0, -1, 0, -1, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- -1, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, -1, 0, 0, 0,
- -1, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, -1, 0, 0, 0,
- 0, -1, 0, 0, -1, 0, 0, 0, -1,
- -1, -1, 0, -1, -1, -1, 0, 0, 0, 0,
- 0, -1, 0, 0, -1, 0, 0, 0, -1,
- -1, -1, 0, -1, -1, -1, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, -1, 0, 0, 0, -1, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, -1, 0, 0, 0, -1, 0, 0, 0,
- -1, 0, 0, -1, 0, 0, -1, 0, 0,
- 0, 0, 0, 0, 0, 0, -1, 0, 0, 0,
- -1, 0, 0, -1, 0, 0, -1, 0, 0,
- 0, 0, 0, 0, 0, 0, -1, 0, 0, 0,
- 0, -1, -1, -1, 0, 0, 0, 0, 0,
- -1, -1, 0, -1, -1, -1, 0, 0, 0, -1,
- 0, -1, -1, -1, 0, 0, 0, 0, 0,
- -1, -1, 0, -1, -1, -1, 0, 0, 0, -1
-#endif
-};
-
-/*
---- T.61 characters [0xA0 .. 0xBF] -----------------
-*/
-static Couple trans_t61a_iso8859[32] = {
-#if (ISO_8859 == 1) || (ISO_8859 == 9)
- {'N','S'}, {0xa1,0}, {0xa2,0}, {0xa3,0},
- {'D','O'}, {0xa5,0}, {'C','u'}, {0xa7,0},
- {0xa4,0}, {'\'','6'},{'"','6'}, {0xab,0},
- {'<','-'}, {'-','!'}, {'-','>'}, {'-','v'},
- {0xb0,0}, {0xb1,0}, {0xb2,0}, {0xb3,0},
- {0xd7,0}, {0xb5,0}, {0xb6,0}, {0xb7,0},
- {0xf7,0}, {'\'','9'},{'"','9'}, {0xbb,0},
- {0xbc,0}, {0xbd,0}, {0xbe,0}, {0xbf,0}
-#elif (ISO_8859 == 2) || (ISO_8859 == 4)
- {'N','S'}, {'!','I'}, {'C','t'}, {'P','d'},
- {'D','O'}, {'Y','e'}, {'C','u'}, {0xa7,0},
- {0xa4,0}, {'\'','6'},{'"','6'}, {'<','<'},
- {'<','-'}, {'-','!'}, {'-','>'}, {'-','v'},
- {0xb0,0}, {'+','-'}, {'2','S'}, {'3','S'},
- {0xd7,0}, {'M','y'}, {'P','I'}, {'.','M'},
- {0xf7,0}, {'\'','9'},{'"','9'}, {'>','>'},
- {'1','4'}, {'1','2'}, {'3','4'}, {'?','I'},
-#elif (ISO_8859 == 3)
- {'N','S'}, {'!','I'}, {'C','t'}, {0xa3,0},
- {'D','O'}, {'Y','e'}, {'C','u'}, {0xa7,0},
- {0xa4,0}, {'\'','6'},{'"','6'}, {'<','<'},
- {'<','-'}, {'-','!'}, {'-','>'}, {'-','v'},
- {0xb0,0}, {'+','-'}, {0xb2,0}, {0xb3,0},
- {0xd7,0}, {0xb5,0}, {'P','I'}, {0xb7,0},
- {0xf7,0}, {'\'','9'},{'"','9'}, {'>','>'},
- {'1','4'}, {0xbd,0}, {'3','4'}, {'?','I'}
-#elif (ISO_8859 == 10)
- {'N','S'}, {'!','I'}, {'C','t'}, {'P','d'},
- {'D','O'}, {'Y','e'}, {'C','u'}, {0xa7,0},
- {'C','u'}, {'\'','6'},{'"','6'}, {'<','<'},
- {'<','-'}, {'-','!'}, {'-','>'}, {'-','v'},
- {0xb0,0}, {'+','-'}, {'2','S'}, {'3','S'},
- {'*','X'}, {'M','y'}, {'P','I'}, {0xb7,0},
- {'-',':'}, {'\'','9'},{'"','9'}, {'>','>'},
- {'1','4'}, {'1','2'}, {'3','4'}, {'?','I'}
-#else
- {'N','S'}, {'!','I'}, {'C','t'}, {'P','d'},
- {'D','O'}, {'Y','e'}, {'C','u'}, {'S','E'},
- {'X','O'}, {'\'','6'},{'"','6'}, {'<','<'},
- {'<','-'}, {'-','!'}, {'-','>'}, {'-','v'},
- {'D','G'}, {'+','-'}, {'2','S'}, {'3','S'},
- {'*','X'}, {'M','y'}, {'P','I'}, {'.','M'},
- {'-',':'}, {'\'','9'},{'"','9'}, {'>','>'},
- {'1','4'}, {'1','2'}, {'3','4'}, {'?','I'}
-#endif
-};
-
-/*
---- T.61 characters [0xE0 .. 0xFF] -----------------
-*/
-static Couple trans_t61b_iso8859[48] = {
-#if (ISO_8859 == 1)
- {'-','M'}, {0xb9,0}, {0xae,0}, {0xa9,0},
- {'T','M'}, {'M','8'}, {0xac,0}, {0xa6,0},
- {0,0}, {0,0}, {0,0}, {0,0},
- {'1','8'}, {'3','8'}, {'5','8'}, {'7','8'},
- {'O','m'}, {0xc6,0}, {0xd0,0}, {0xaa,0},
- {'H','/'}, {0,0}, {'I','J'}, {'L','.'},
- {'L','/'}, {0xd8,0}, {'O','E'}, {0xba,0},
- {0xde,0}, {'T','/'}, {'N','G'}, {'\'','n'},
- {'k','k'}, {0xe6,0}, {'d','/'}, {0xf0,0},
- {'h','/'}, {'i','.'}, {'i','j'}, {'l','.'},
- {'l','/'}, {0xf8,0}, {'o','e'}, {0xdf,0},
- {0xfe,0}, {'t','/'}, {'n','g'}, {'-','-'}
-#elif (ISO_8859 == 2)
- {'-','M'}, {'1','S'}, {'R','g'}, {'C','o'},
- {'T','M'}, {'M','8'}, {'N','O'}, {'B','B'},
- {0,0}, {0,0}, {0,0}, {0,0},
- {'1','8'}, {'3','8'}, {'5','8'}, {'7','8'},
- {'O','m'}, {'A','E'}, {0xd0,0}, {'-','a'},
- {'H','/'}, {0,0}, {'I','J'}, {'L','.'},
- {0xa3,0}, {'O','/'}, {'O','E'}, {'-','o'},
- {'T','H'}, {'T','/'}, {'N','G'}, {'\'','n'},
- {'k','k'}, {'a','e'}, {0xf0,0}, {'d','-'},
- {'h','/'}, {'i','.'}, {'i','j'}, {'l','.'},
- {0xb3,0}, {'o','/'}, {'o','e'}, {0xdf,0},
- {'t','h'}, {'t','/'}, {'n','g'}, {'-','-'}
-#elif (ISO_8859 == 3)
- {'-','M'}, {'1','S'}, {'R','g'}, {'C','o'},
- {'T','M'}, {'M','8'}, {'N','O'}, {'B','B'},
- {0,0}, {0,0}, {0,0}, {0,0},
- {'1','8'}, {'3','8'}, {'5','8'}, {'7','8'},
- {'O','m'}, {'A','E'}, {'D','/'}, {'-','a'},
- {0xa1,0}, {0,0}, {'I','J'}, {'L','.'},
- {'L','/'}, {'O','/'}, {'O','E'}, {'-','o'},
- {'T','H'}, {'T','/'}, {'N','G'}, {'\'','n'},
- {'k','k'}, {'a','e'}, {'d','/'}, {'d','-'},
- {0xb1,0}, {0xb9,0}, {'i','j'}, {'l','.'},
- {'l','/'}, {'o','/'}, {'o','e'}, {0xdf,0},
- {'t','h'}, {'t','/'}, {'n','g'}, {'-','-'}
-#elif (ISO_8859 == 4)
- {'-','M'}, {'1','S'}, {'R','g'}, {'C','o'},
- {'T','M'}, {'M','8'}, {'N','O'}, {'B','B'},
- {0,0}, {0,0}, {0,0}, {0,0},
- {'1','8'}, {'3','8'}, {'5','8'}, {'7','8'},
- {'O','m'}, {0xc6,0}, {0xd0,0}, {'-','a'},
- {'H','/'}, {0,0}, {'I','J'}, {'L','.'},
- {'L','/'}, {0xd8,0}, {'O','E'}, {'-','o'},
- {'T','H'}, {0xac,0}, {0xbd,0}, {'\'','n'},
- {0xa2,0}, {0xe6,0}, {0xf0,0}, {'d','-'},
- {'h','/'}, {'i','.'}, {'i','j'}, {'l','.'},
- {'l','/'}, {0xf8,0}, {'o','e'}, {0xdf,0},
- {'t','h'}, {0xbc,0}, {0xbf,0}, {'-','-'}
-#elif (ISO_8859 == 9)
- {'-','M'}, {0xb9,0}, {0xae,0}, {0xa9,0},
- {'T','M'}, {'M','8'}, {0xac,0}, {0xa6,0},
- {0,0}, {0,0}, {0,0}, {0,0},
- {'1','8'}, {'3','8'}, {'5','8'}, {'7','8'},
- {'O','m'}, {0xc6,0}, {'D','/'}, {0xaa,0},
- {'H','/'}, {0,0}, {'I','J'}, {'L','.'},
- {'L','/'}, {0xd8,0}, {'O','E'}, {0xba,0},
- {'T','H'}, {'T','/'}, {'N','G'}, {'\'','n'},
- {'k','k'}, {0xe6,0}, {'d','/'}, {'d','-'},
- {'h','/'}, {0xfd,0}, {'i','j'}, {'l','.'},
- {'l','/'}, {0xf8,0}, {'o','e'}, {0xdf,0},
- {'t','h'}, {'t','/'}, {'n','g'}, {'-','-'}
-#elif (ISO_8859 == 10)
- {0xbd,0}, {'1','S'}, {'R','g'}, {'C','o'},
- {'T','M'}, {'M','8'}, {'N','O'}, {'B','B'},
- {0,0}, {0,0}, {0,0}, {0,0},
- {'1','8'}, {'3','8'}, {'5','8'}, {'7','8'},
- {'O','m'}, {0xc6,0}, {0xa9,0}, {'-','a'},
- {'H','/'}, {0,0}, {'I','J'}, {'L','.'},
- {'L','/'}, {0xd8,0}, {'O','E'}, {'-','o'},
- {0xde,0}, {0xab,0}, {0xaf,0}, {'\'','n'},
- {0xff,0}, {0xe6,0}, {0xb9,0}, {0xf0,0},
- {'h','/'}, {'i','.'}, {'i','j'}, {'l','.'},
- {'l','/'}, {0xf8,0}, {'o','e'}, {0xdf,0},
- {0xfe,0}, {0xbb,0}, {0xbf,0}, {'-','-'}
-#else
- {'-','M'}, {'1','S'}, {'R','g'}, {'C','o'},
- {'T','M'}, {'M','8'}, {'N','O'}, {'B','B'},
- {0,0}, {0,0}, {0,0}, {0,0},
- {'1','8'}, {'3','8'}, {'5','8'}, {'7','8'},
- {'O','m'}, {'A','E'}, {'D','/'}, {'-','a'},
- {'H','/'}, {0,0}, {'I','J'}, {'L','.'},
- {'L','/'}, {'O','/'}, {'O','E'}, {'-','o'},
- {'T','H'}, {'T','/'}, {'N','G'}, {'\'','n'},
- {'k','k'}, {'a','e'}, {'d','/'}, {'d','-'},
- {'h','/'}, {'i','.'}, {'i','j'}, {'l','.'},
- {'l','/'}, {'o','/'}, {'o','e'}, {'s','s'},
- {'t','h'}, {'t','-'}, {'n','g'}, {'-','-'}
-#endif
-};
-
-/*
---- ISO 8859-n characters <0xA0 .. 0xFF> -------------------
-*/
-#if (ISO_8859 == 1)
-static Couple trans_iso8859_t61[96] = {
- {0xa0,0}, {0xa1,0}, {0xa2,0}, {0xa3,0},
- {0xa8,0}, {0xa5,0}, {0xd7,0}, {0xa7,0},
- {0xc8,ALONE}, {0xd3,0}, {0xe3,0}, {0xab,0},
- {0xd6,0}, {0xff,0}, {0xd2,0}, {0xc5,ALONE},
- {0xb0,0}, {0xb1,0}, {0xb2,0}, {0xb3,0},
- {0xc2,ALONE}, {0xb5,0}, {0xb6,0}, {0xb7,0},
- {0xcb,ALONE}, {0xd1,0}, {0xeb,0}, {0xbb,0},
- {0xbc,0}, {0xbd,0}, {0xbe,0}, {0xbf,0},
- {0xc1,'A'}, {0xc2,'A'}, {0xc3,'A'}, {0xc4,'A'},
- {0xc8,'A'}, {0xca,'A'}, {0xe1,0}, {0xcb,'C'},
- {0xc1,'E'}, {0xc2,'E'}, {0xc3,'E'}, {0xc8,'E'},
- {0xc1,'I'}, {0xc2,'I'}, {0xc3,'I'}, {0xc8,'I'},
- {0xe2,0}, {0xc4,'N'}, {0xc1,'O'}, {0xc2,'O'},
- {0xc3,'O'}, {0xc4,'O'}, {0xc8,'O'}, {0xb4,0},
- {0xe9,0}, {0xc1,'U'}, {0xc2,'U'}, {0xc3,'U'},
- {0xc8,'U'}, {0xc2,'Y'}, {0xec,0}, {0xfb,0},
- {0xc1,'a'}, {0xc2,'a'}, {0xc3,'a'}, {0xc4,'a'},
- {0xc8,'a'}, {0xca,'a'}, {0xf1,0}, {0xcb,'c'},
- {0xc1,'e'}, {0xc2,'e'}, {0xc3,'e'}, {0xc8,'e'},
- {0xc1,'i'}, {0xc2,'i'}, {0xc3,'i'}, {0xc8,'i'},
- {0xf3,0}, {0xc4,'n'}, {0xc1,'o'}, {0xc2,'o'},
- {0xc3,'o'}, {0xc4,'o'}, {0xc8,'o'}, {0xb8,0},
- {0xf9,0}, {0xc1,'u'}, {0xc2,'u'}, {0xc3,'u'},
- {0xc8,'u'}, {0xc2,'y'}, {0xfc,0}, {0xc8,'y'}
-};
-#elif (ISO_8859 == 2)
-static Couple trans_iso8859_t61[96] = {
- {0xa0,0}, {0xce,'A'}, {0xc6,ALONE}, {0xe8,0},
- {0xa8,0}, {0xcf,'L'}, {0xc2,'S'}, {0xa7,0},
- {0xc8,ALONE}, {0xcf,'S'}, {0xcb,'S'}, {0xcf,'T'},
- {0xc2,'Z'}, {0xff,0}, {0xcf,'Z'}, {0xc7,'Z'},
- {0xb0,0}, {0xce,'a'}, {0xce,ALONE}, {0xf8,0},
- {0xc2,ALONE}, {0xcf,'l'}, {0xc2,'s'}, {0xcf,ALONE},
- {0xcb,ALONE}, {0xcf,'s'}, {0xcb,'s'}, {0xcf,'t'},
- {0xc2,'z'}, {0xcd,ALONE}, {0xcf,'z'}, {0xc7,'z'},
- {0xc2,'R'}, {0xc2,'A'}, {0xc3,'A'}, {0xc6,'A'},
- {0xc8,'A'}, {0xc2,'L'}, {0xc2,'C'}, {0xcb,'C'},
- {0xcf,'C'}, {0xc2,'E'}, {0xce,'E'}, {0xc8,'E'},
- {0xcf,'E'}, {0xc2,'I'}, {0xc3,'I'}, {0xcf,'D'},
- {0xe2,0}, {0xc2,'N'}, {0xcf,'N'}, {0xc2,'O'},
- {0xc3,'O'}, {0xcd,'O'}, {0xc8,'O'}, {0xb4,0},
- {0xcf,'R'}, {0xca,'U'}, {0xc2,'U'}, {0xcd,'U'},
- {0xc8,'U'}, {0xc2,'Y'}, {0xcb,'T'}, {0xfb,0},
- {0xc2,'r'}, {0xc2,'a'}, {0xc3,'a'}, {0xc6,'a'},
- {0xc8,'a'}, {0xc2,'l'}, {0xc2,'c'}, {0xcb,'c'},
- {0xcf,'c'}, {0xc2,'e'}, {0xce,'e'}, {0xc8,'e'},
- {0xcf,'e'}, {0xc2,'i'}, {0xc3,'i'}, {0xcf,'d'},
- {0xf2,0}, {0xc2,'n'}, {0xcf,'n'}, {0xc2,'o'},
- {0xc3,'o'}, {0xcd,'o'}, {0xc8,'o'}, {0xb8,0},
- {0xcf,'r'}, {0xca,'u'}, {0xc2,'u'}, {0xcd,'u'},
- {0xc8,'u'}, {0xc2,'y'}, {0xcb,'t'}, {0xc7,ALONE}
-};
-#elif (ISO_8859 == 3)
-static Couple trans_iso8859_t61[96] = {
- {0xa0,0}, {0xe4,0}, {0xc6,ALONE}, {0xa3,0},
- {0xa8,0}, {0,0}, {0xc3,'H'}, {0xa7,0},
- {0xc8,ALONE}, {0xc7,'I'}, {0xcb,'S'}, {0xc6,'G'},
- {0xc3,'J'}, {0xff,0}, {0,0}, {0xc7,'Z'},
- {0xb0,0}, {0xf4,0}, {0xb2,0}, {0xb3,0},
- {0xc2,ALONE}, {0xb5,0}, {0xc3,'h'}, {0xb7,0},
- {0xcb,ALONE}, {0xf5,0}, {0xcb,'s'}, {0xc6,'g'},
- {0xc3,'j'}, {0xbd,0}, {0,0}, {0xc7,'z'},
- {0xc1,'A'}, {0xc2,'A'}, {0xc3,'A'}, {0,0},
- {0xc8,'A'}, {0xc7,'C'}, {0xc3,'C'}, {0xcb,'C'},
- {0xc1,'E'}, {0xc2,'E'}, {0xc3,'E'}, {0xc8,'E'},
- {0xc1,'I'}, {0xc2,'I'}, {0xc3,'I'}, {0xc8,'I'},
- {0,0}, {0xc4,'N'}, {0xc1,'O'}, {0xc2,'O'},
- {0xc3,'O'}, {0xc7,'G'}, {0xc8,'O'}, {0xb4,0},
- {0xc3,'G'}, {0xc1,'U'}, {0xc2,'U'}, {0xc3,'U'},
- {0xc8,'U'}, {0xc6,'U'}, {0xc3,'S'}, {0xfb,0},
- {0xc1,'a'}, {0xc2,'a'}, {0xc3,'a'}, {0,0},
- {0xc8,'a'}, {0xc7,'c'}, {0xc3,'c'}, {0xcb,'c'},
- {0xc1,'e'}, {0xc2,'e'}, {0xc3,'e'}, {0xc8,'e'},
- {0xc1,'i'}, {0xc2,'i'}, {0xc3,'i'}, {0xc8,'i'},
- {0,0}, {0xc4,'n'}, {0xc1,'o'}, {0xc2,'o'},
- {0xc3,'o'}, {0xc7,'g'}, {0xc8,'o'}, {0xb8,0},
- {0xc3,'g'}, {0xc1,'u'}, {0xc2,'u'}, {0xc3,'u'},
- {0xc8,'u'}, {0xc6,'u'}, {0xc3,'s'}, {0xc7,ALONE}
-};
-#elif (ISO_8859 == 4)
-static Couple trans_iso8859_t61[96] = {
- {0xa0,0}, {0xce,'A'}, {0xf0,0}, {0xcb,'R'},
- {0xa8,0}, {0xc4,'I'}, {0xcb,'L'}, {0xa7,0},
- {0xc8,ALONE}, {0xcf,'S'}, {0xc5,'E'}, {0xcb,'G'},
- {0xed,0}, {0xff,0}, {0xcf,'Z'}, {0xc5,ALONE},
- {0xb0,0}, {0xce,'a'}, {0xce,ALONE}, {0xcb,'r'},
- {0xc2,ALONE}, {0xc4,'i'}, {0xcb,'l'}, {0xcf,ALONE},
- {0xcb,ALONE}, {0xcf,'s'}, {0xc5,'e'}, {0xcb,'g'},
- {0xfd,0}, {0xee,0}, {0xcf,'z'}, {0xfe,0},
- {0xc5,'A'}, {0xc2,'A'}, {0xc3,'A'}, {0xc4,'A'},
- {0xc8,'A'}, {0xca,'A'}, {0xe1,0}, {0xce,'I'},
- {0xcf,'C'}, {0xc2,'E'}, {0xce,'E'}, {0xc8,'E'},
- {0xc7,'E'}, {0xc2,'I'}, {0xc3,'I'}, {0xc5,'I'},
- {0xe2,0}, {0xcb,'N'}, {0xc5,'O'}, {0xcb,'K'},
- {0xc3,'O'}, {0xc4,'O'}, {0xc8,'O'}, {0xb4,0},
- {0xe9,0}, {0xce,'U'}, {0xc2,'U'}, {0xc3,'U'},
- {0xc8,'U'}, {0xc4,'U'}, {0xc5,'U'}, {0xfb,0},
- {0xc5,'a'}, {0xc2,'a'}, {0xc3,'a'}, {0xc4,'a'},
- {0xc8,'a'}, {0xca,'a'}, {0xf1,0}, {0xce,'i'},
- {0xcf,'c'}, {0xc2,'e'}, {0xce,'e'}, {0xc8,'e'},
- {0xc7,'e'}, {0xc2,'i'}, {0xc3,'i'}, {0xc5,'i'},
- {0xf2,0}, {0xcb,'n'}, {0xc5,'o'}, {0xcb,'k'},
- {0xc3,'o'}, {0xc4,'o'}, {0xc8,'o'}, {0xb8,0},
- {0xf9,0}, {0xce,'u'}, {0xc2,'u'}, {0xc3,'u'},
- {0xc8,'u'}, {0xc4,'u'}, {0xc5,'u'}, {0xc7,ALONE}
-};
-#elif (ISO_8859 == 9)
-static Couple trans_iso8859_t61[96] = {
- {0xa0,0}, {0xa1,0}, {0xa2,0}, {0xa3,0},
- {0xa8,0}, {0xa5,0}, {0xd7,0}, {0xa7,0},
- {0xc8,ALONE}, {0xd3,0}, {0xe3,0}, {0xab,0},
- {0xd6,0}, {0xff,0}, {0xd2,0}, {0xc5,ALONE},
- {0xb0,0}, {0xb1,0}, {0xb2,0}, {0xb3,0},
- {0xc2,ALONE}, {0xb5,0}, {0xb6,0}, {0xb7,0},
- {0xcb,ALONE}, {0xd1,0}, {0xeb,0}, {0xbb,0},
- {0xbc,0}, {0xbd,0}, {0xbe,0}, {0xbf,0},
- {0xc1,'A'}, {0xc2,'A'}, {0xc3,'A'}, {0xc4,'A'},
- {0xc8,'A'}, {0xca,'A'}, {0xe1,0}, {0xcb,'C'},
- {0xc1,'E'}, {0xc2,'E'}, {0xc3,'E'}, {0xc8,'E'},
- {0xc1,'I'}, {0xc2,'I'}, {0xc3,'I'}, {0xc8,'I'},
- {0xc6,'G'}, {0xc4,'N'}, {0xc1,'O'}, {0xc2,'O'},
- {0xc3,'O'}, {0xc4,'O'}, {0xc8,'O'}, {0xb4,0},
- {0xe9,0}, {0xc1,'U'}, {0xc2,'U'}, {0xc3,'U'},
- {0xc8,'U'}, {0xc7,'I'}, {0xcb,'S'}, {0xfb,0},
- {0xc1,'a'}, {0xc2,'a'}, {0xc3,'a'}, {0xc4,'a'},
- {0xc8,'a'}, {0xca,'a'}, {0xf1,0}, {0xcb,'c'},
- {0xc1,'e'}, {0xc2,'e'}, {0xce,'e'}, {0xc8,'e'},
- {0xc7,'e'}, {0xc2,'i'}, {0xc3,'i'}, {0xc5,'i'},
- {0xc6,'g'}, {0xc4,'n'}, {0xc1,'o'}, {0xc2,'o'},
- {0xc3,'o'}, {0xc4,'o'}, {0xc8,'o'}, {0xb8,0},
- {0xf9,0}, {0xc1,'u'}, {0xc2,'u'}, {0xc3,'u'},
- {0xc8,'u'}, {0xf5,0}, {0xcb,'s'}, {0xc8,'y'}
-};
-#elif (ISO_8859 == 10)
-static Couple trans_iso8859_t61[96] = {
- {0xa0,0}, {0xce,'A'}, {0xc5,'E'}, {0xcb,'G'},
- {0xc5,'I'}, {0xc4,'I'}, {0xcb,'K'}, {0xa7,0},
- {0xcb,'L'}, {0xe2,0}, {0xcf,'S'}, {0xed,0},
- {0xcf,'Z'}, {0xff,0}, {0xc5,'U'}, {0xee,0},
- {0xb0,0}, {0xce,'a'}, {0xc5,'e'}, {0xcb,'g'},
- {0xc5,'i'}, {0xc4,'i'}, {0xcb,'k'}, {0xb7,0},
- {0xcb,'l'}, {0xf2,0}, {0xcf,'s'}, {0xfd,0},
- {0xcf,'z'}, {0xd0,0}, {0xc5,'u'}, {0xfe,0},
- {0xc5,'A'}, {0xc2,'A'}, {0xc3,'A'}, {0xc4,'A'},
- {0xc8,'A'}, {0xca,'A'}, {0xe1,0}, {0xce,'I'},
- {0xcf,'C'}, {0xc2,'E'}, {0xce,'E'}, {0xc8,'E'},
- {0xc7,'E'}, {0xc2,'I'}, {0xc3,'I'}, {0xc8,'I'},
- {0,0}, {0xcb,'N'}, {0xc5,'O'}, {0xc2,'O'},
- {0xc3,'O'}, {0xc4,'O'}, {0xc8,'O'}, {0xc4,'U'},
- {0xe9,0}, {0xce,'U'}, {0xc2,'U'}, {0xc3,'U'},
- {0xc8,'U'}, {0xc2,'Y'}, {0xec,0}, {0xfb,0},
- {0xc5,'a'}, {0xc2,'a'}, {0xc3,'a'}, {0xc4,'a'},
- {0xc8,'a'}, {0xca,'a'}, {0xf1,0}, {0xce,'i'},
- {0xcf,'c'}, {0xc2,'e'}, {0xce,'e'}, {0xc8,'e'},
- {0xc7,'e'}, {0xc2,'i'}, {0xc3,'i'}, {0xc8,'i'},
- {0xf3,0}, {0xcb,'n'}, {0xc5,'o'}, {0xc2,'o'},
- {0xc3,'o'}, {0xc4,'o'}, {0xc8,'o'}, {0xc4,'u'},
- {0xf9,0}, {0xce,'u'}, {0xc2,'u'}, {0xc3,'u'},
- {0xc8,'u'}, {0xc2,'y'}, {0xfc,0}, {0xf0,0}
-};
-#endif
-
-
-static Byte *
-c_to_hh( Byte *o, Byte c )
-{
- Byte n;
-
- *o++ = '{'; *o++ = 'x';
- n = c >> 4;
- *o++ = ((n < 0xA) ? '0' : 'A' - 0xA) + n;
- n = c & 0x0F;
- *o++ = ((n < 0xA) ? '0' : 'A' - 0xA) + n;
- *o++ = '}';
- return o;
-}
-
-
-static Byte *
-c_to_cc( Byte *o, Couple *cc, Byte c )
-{
- if ( (*cc).a != 0 ) {
- if ( (*cc).b == 0 )
- *o++ = (*cc).a;
- else {
- *o++ = '{';
- *o++ = (*cc).a;
- *o++ = (*cc).b;
- *o++ = '}';
- }
- return o;
- }
- else
- return c_to_hh( o, c );
-}
-
-/* --- routine to convert from T.61 to ISO 8859-n --- */
-
-int
-ldap_t61_to_8859( char **bufp, unsigned int *buflenp, int free_input )
-{
- Byte *s, *oo, *o;
- unsigned int n;
- int c;
- unsigned int len;
- Couple *cc;
-
- Debug( LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 111, "ldap_t61_to_8859 input length: %ld\n"),
- *buflenp, 0, 0 );
-
- len = *buflenp;
- s = (Byte *) *bufp;
-
- if ( (o = oo = (Byte *)malloc( 2 * len + 64 )) == NULL ) {
- return( 1 );
- }
-
- while ( (char *)s - *(char **)bufp < len ) {
- switch ( *s >> 4 ) {
-
- case 0xA: case 0xB:
- o = c_to_cc( o, &trans_t61a_iso8859[ *s - 0xA0 ], *s );
- s++;
- break;
-
- case 0xD: case 0xE: case 0xF:
- o = c_to_cc( o, &trans_t61b_iso8859[ *s - 0xD0 ], *s );
- s++;
- break;
-
- case 0xC:
- if ( (*s == 0xC0) || (*s == 0xC9) || (*s == 0xCC) ) {
- o = c_to_hh( o, *s++ );
- break;
- }
-
- n = (*s++) - 0xC0;
- switch ( *s ) {
-
- case 'A': c = letter_w_diacritic[n][0]; break;
- case 'C': c = letter_w_diacritic[n][1]; break;
- case 'D': c = letter_w_diacritic[n][2]; break;
- case 'E': c = letter_w_diacritic[n][3]; break;
- case 'G': c = letter_w_diacritic[n][4]; break;
- case 'H': c = letter_w_diacritic[n][5]; break;
- case 'I': c = letter_w_diacritic[n][6]; break;
- case 'J': c = letter_w_diacritic[n][7]; break;
- case 'K': c = letter_w_diacritic[n][8]; break;
- case 'L': c = letter_w_diacritic[n][9]; break;
- case 'N': c = letter_w_diacritic[n][10]; break;
- case 'O': c = letter_w_diacritic[n][11]; break;
- case 'R': c = letter_w_diacritic[n][12]; break;
- case 'S': c = letter_w_diacritic[n][13]; break;
- case 'T': c = letter_w_diacritic[n][14]; break;
- case 'U': c = letter_w_diacritic[n][15]; break;
- case 'W': c = letter_w_diacritic[n][16]; break;
- case 'Y': c = letter_w_diacritic[n][17]; break;
- case 'Z': c = letter_w_diacritic[n][18]; break;
-
- case 'a': c = letter_w_diacritic[n][19]; break;
- case 'c': c = letter_w_diacritic[n][20]; break;
- case 'd': c = letter_w_diacritic[n][21]; break;
- case 'e': c = letter_w_diacritic[n][22]; break;
- case 'g': c = letter_w_diacritic[n][23]; break;
- case 'h': c = letter_w_diacritic[n][24]; break;
- case 'i': c = letter_w_diacritic[n][25]; break;
- case 'j': c = letter_w_diacritic[n][26]; break;
- case 'k': c = letter_w_diacritic[n][27]; break;
- case 'l': c = letter_w_diacritic[n][28]; break;
- case 'n': c = letter_w_diacritic[n][29]; break;
- case 'o': c = letter_w_diacritic[n][30]; break;
- case 'r': c = letter_w_diacritic[n][31]; break;
- case 's': c = letter_w_diacritic[n][32]; break;
- case 't': c = letter_w_diacritic[n][33]; break;
- case 'u': c = letter_w_diacritic[n][34]; break;
- case 'w': c = letter_w_diacritic[n][35]; break;
- case 'y': c = letter_w_diacritic[n][36]; break;
- case 'z': c = letter_w_diacritic[n][37]; break;
-
- case ALONE: c = (( !diacritic[n].b ) ? diacritic[n].a : -1);
- break;
-
- default: c = 0;
- }
-
- if ( c > 0 ) {
- *o++ = c; s++;
- } else {
- *o++ = '{';
- if ( c == -1 ) {
- *o++ = ( ( *s == ALONE ) ? ' ' : *s );
- s++;
- } else {
- *o++ = '"';
- }
- *o++ = diacritic[n].a;
- *o++ = '}';
- }
- break;
-
-#if (ISO_8859 == 0)
- case 0x8: case 0x9:
- *o++ = 0x1B; /* <ESC> */
- *o++ = *s++ - 0x40;
- break;
-#endif
-
- default:
- *o++ = *s++;
- }
- }
-
- len = o - oo;
- o = oo;
-
- if ( (oo = (Byte *)realloc( o, len )) == NULL ) {
- free( o );
- return( 1 );
- }
-
- if ( free_input ) {
- free( *bufp );
- }
- *bufp = (char *) oo;
- *buflenp = len;
- return( 0 );
-}
-
-
-static int
-hh_to_c( Byte *h )
-{
- Byte c;
-
- if ( (*h >= '0') && (*h <= '9') ) c = *h++ - '0';
- else if ( (*h >= 'A') && (*h <= 'F') ) c = *h++ - 'A' + 10;
- else if ( (*h >= 'a') && (*h <= 'f') ) c = *h++ - 'a' + 10;
- else return -1;
-
- c <<= 4;
-
- if ( (*h >= '0') && (*h <= '9') ) c |= *h - '0';
- else if ( (*h >= 'A') && (*h <= 'F') ) c |= *h - 'A' + 10;
- else if ( (*h >= 'a') && (*h <= 'f') ) c |= *h - 'a' + 10;
- else return -1;
-
- return c;
-}
-
-
-static Byte *
-cc_to_t61( Byte *o, Byte *s )
-{
- int n, c = 0;
-
- switch ( *(s + 1) ) {
-
- case '`': c = -1; break; /* <grave-accent> */
-
- case '!':
- switch ( *s ) {
- case '!': c = 0x7C; break; /* <vertical-line> */
- case '(': c = 0x7B; break; /* <left-curly-bracket> */
- case '-': c = 0xAD; break; /* <upwards-arrow> */
- default: c = -1; /* <grave-accent> */
- }
- break;
-
-#if (ISO_8859 == 1) || (ISO_8859 == 2) || (ISO_8859 == 3) || \
- (ISO_8859 == 4) || (ISO_8859 == 9)
- case 0xB4:
-#endif
- case '\'': c = -2; break; /* <acute-accent> */
-
- case '^': c = -3; break; /* <circumflex-acent> */
-
- case '>':
- switch ( *s ) {
- case ')': c = 0x5D; break; /* <right-square-bracket> */
- case '>': c = 0xBB; break; /* <right-angle-quotation> */
- case '-': c = 0xAE; break; /* <rightwards-arrow> */
- default: c = -3; /* <circumflex-acent> */
- }
- break;
-
- case '~':
- case '?': c = -4; break; /* <tilde> */
-
-#if (ISO_8859 == 1) || (ISO_8859 == 4) || (ISO_8859 == 9)
- case 0xAF: c = -5; break; /* <macron> */
-#endif
-
- case '-':
- switch ( *s ) {
- case '-': c = 0xFF; break; /* <soft-hyphen> */
- case '<': c = 0xAC; break; /* <leftwards arrow> */
- case '+': c = 0xB1; break; /* <plus-minus> */
- case 'd': c = 0xF3; break; /* <eth> */
- default: c = -5; /* <macron> */
- }
- break;
-
-#if (ISO_8859 == 2) || (ISO_8859 == 3)
- case 0xA2: c = -6; break; /* <breve> */
-#endif
-
- case '(':
- if ( *s == '<' ) c = 0x5B; /* <left-square-bracket> */
- else c = -6; /* <breve> */
- break;
-
-#if (ISO_8859 == 2) || (ISO_8859 == 3) || (ISO_8859 == 4)
- case 0xFF: c = -7; break; /* <dot-accent> */
-#endif
-
- case '.':
- switch ( *s ) {
- case 'i': c = 0xF5; break; /* <dotless-i> */
- case 'L': c = 0xE7; break; /* <L-middle-dot> */
- case 'l': c = 0xF7; break; /* <l-middle-dot> */
- default: c = -7; /* <dot-accent> */
- }
- break;
-
-#if (ISO_8859 == 1) || (ISO_8859 == 2) || (ISO_8859 == 3) || \
- (ISO_8859 == 4) || (ISO_8859 == 9)
- case 0xA8: c = -8; break; /* <diaeresis> */
-#endif
-
- case ':':
- if ( *s == '-') c = 0xB8; /* <division-sign> */
- else c = -8; /* <diaeresis> */
- break;
-
-#if (ISO_8859 == 1) || (ISO_8859 == 2) || (ISO_8859 == 3) || \
- (ISO_8859 == 4) || (ISO_8859 == 9) || (ISO_8859 == 10)
- case 0xB0:
-#endif
- case '0': c = -10; break; /* <ring-above> */
-
-#if (ISO_8859 == 1) || (ISO_8859 == 2) || (ISO_8859 == 3) || \
- (ISO_8859 == 4) || (ISO_8859 == 9)
- case 0xB8:
-#endif
- case ',': c = -11; break; /* <cedilla> */
-
-#if (ISO_8859 == 2)
- case 0xBD:
-#endif
- case '"': c = -13; break; /* <double-acute-accent> */
-
-#if (ISO_8859 == 2) || (ISO_8859 == 4)
- case 0xB2:
-#endif
- case ';': c = -14; break; /* <ogonek> */
-
-#if (ISO_8859 == 2) || (ISO_8859 == 4)
- case 0xB7: c = -15; break; /* <caron> */
-#endif
-
- case ')':
- if ( *s == '!' ) c = 0x7D; /* <left-curly-bracket> */
- break;
-
- case '<':
- if ( *s == '<' ) c = 0xAB; /* <left-angle-quotation> */
- else c = -15; /* <caron> */
- break;
-
- case '/':
- switch ( *s ) {
- case '/': c = 0x5C; break; /* <reverse-solidus> */
- case 'D': c = 0xE2; break; /* <D-stroke> */
- case 'd': c = 0xF2; break; /* <d-stroke> */
- case 'H': c = 0xE4; break; /* <H-stroke> */
- case 'h': c = 0xF4; break; /* <h-stroke> */
- case 'L': c = 0xE8; break; /* <L-stroke> */
- case 'l': c = 0xF8; break; /* <l-stroke> */
- case 'O': c = 0xE9; break; /* <O-stroke> */
- case 'o': c = 0xF9; break; /* <o-stroke> */
- case 'T': c = 0xED; break; /* <T-stroke> */
- case 't': c = 0xFD; break; /* <t-stroke> */
- }
- break;
-
- case '2':
- if ( *s == '1' ) c = 0xBD; /* <one-half> */
- break;
-
- case '4':
- switch ( *s ) {
- case '1': c = 0xBC; break; /* <one-quarter> */
- case '3': c = 0xBE; break; /* <three-quarters> */
- }
- break;
-
- case '6':
- switch ( *s ) {
- case '\'': c = 0xA9; break; /* <left-single-quotation> */
- case '"': c = 0xAA; break; /* <left-double-quotation> */
- }
- break;
-
- case '8':
- switch ( *s ) {
- case '1': c = 0xDC; break; /* <one-eighth> */
- case '3': c = 0xDD; break; /* <three-eighths> */
- case '5': c = 0xDE; break; /* <five-eighths> */
- case '7': c = 0xDF; break; /* <seven-eighths> */
- case 'M': c = 0xD5; break; /* <eighth-note> */
- }
- break;
-
- case '9':
- switch ( *s ) {
- case '\'': c = 0xB9; break; /* <right-single-quotation> */
- case '"': c = 0xBA; break; /* <right-double-quotation> */
- }
- break;
-
- case 'A':
- if ( *s == 'A' ) c = -10; /* <ring-above> + <A> */
- break;
-
- case 'a':
- switch ( *s ) {
- case '-': c = 0xE3; break; /* <femenine-ordinal-a> */
- case 'a': c = -10; break; /* <ring-above> + <a> */
- }
- break;
-
- case 'B':
- if ( *s == 'B' ) c = 0xD7; /* <broken-bar> */
- break;
-
- case 'b':
- if ( *s == 'N' ) c = 0xA6; /* <number-sign> */
- break;
-
- case 'd':
- if ( *s == 'P' ) c = 0xA3; /* <pound-sign> */
- break;
-
- case 'E':
- switch ( *s ) {
- case 'S': c = 0xA7; break; /* <section-sign> */
- case 'A': c = 0xE1; break; /* <AE> */
- case 'O': c = 0xEA; break; /* <OE> */
- }
- break;
-
- case 'e':
- switch ( *s ) {
- case 'a': c = 0xF1; break; /* <ae> */
- case 'o': c = 0xFA; break; /* <oe> */
- case 'Y': c = 0xA5; break; /* <yen-sign> */
- }
- break;
-
- case 'G':
- switch ( *s ) {
- case 'D': c = 0xB0; break; /* <degree-sign> */
- case 'N': c = 0xEE; break; /* <Eng> */
- }
- break;
-
- case 'g':
- switch ( *s ) {
- case 'R': c = 0xD2; break; /* <registered-sign> */
- case 'n': c = 0xFE; break; /* <eng> */
- }
- break;
-
- case 'H':
- if ( *s == 'T' ) c = 0xEC; /* <Thorn> */
- break;
-
- case 'h':
- if ( *s == 't' ) c = 0xFC; /* <thorn> */
- break;
-
- case 'I':
- switch ( *s ) {
- case 'P': c = 0xB6; break; /* <pilcrow-sign> */
- case '!': c = 0xA1; break; /* <inverted-exclamation> */
- case '?': c = 0xBF; break; /* <inverted-question> */
- }
- break;
-
- case 'J':
- if ( *s == 'I' ) c = 0xE6; /* <IJ> */
- break;
-
- case 'j':
- if ( *s == 'i' ) c = 0xF6; /* <ij> */
- break;
-
- case 'k':
- if ( *s == 'k' ) c = 0xF0; /* <kra> */
- break;
-
- case 'M':
- switch ( *s ) {
- case '.': c = 0xB7; break; /* <middle-dot> */
- case '-': c = 0xD0; break; /* <em-dash> */
- case 'T': c = 0xD4; break; /* <trade-mark-sign> */
- }
- break;
-
- case 'm':
- switch ( *s ) {
- case '\'': /* <macron> RFC 1345 */
- case ' ': c = -5; break; /* <macron> */
- case 'O': c = 0xE0; break; /* <Ohm sign> */
- }
- break;
-
- case 'n':
- if ( *s == '\'' ) c = 0xEF; /* <n-preceded-by-apostrophe> */
- break;
-
- case 'O':
- switch ( *s ) {
- case 'D': c = 0xA4; break; /* <dollar-sign> */
- case 'N': c = 0xD6; break; /* <not-sign> */
- }
- break;
-
- case 'o':
- switch ( *s ) {
- case 'C': c = 0xD3; break; /* <copyright-sign> */
- case '-': c = 0xEB; break; /* <masculine-ordinal-o> */
- }
- break;
-
- case 'S':
- switch ( *s ) {
- case '1': c = 0xD1; break; /* <superscript-1> */
- case '2': c = 0xB2; break; /* <superscript-2> */
- case '3': c = 0xB3; break; /* <superscript-3> */
- case 'N': c = 0xA0; break; /* <no-break-space> */
- }
- break;
-
- case 's':
- if ( *s == 's' ) c = 0xFB; /* <sharp-s> */
- break;
-
- case 't':
- if ( *s == 'C' ) c = 0xA2; /* <cent-sign> */
- break;
-
- case 'u':
- if ( *s == 'C' ) c = 0xA8; /* <currency-sign> */
- break;
-
- case 'v':
- if ( *s == '-' ) c = 0xAF; /* <downwards-arrow> */
- break;
-
- case 'X':
- if ( *s == '*' ) c = 0xB4; /* <multiplication-sign> */
- break;
-
- case 'y':
- if ( *s == 'M' ) c = 0xB5; /* <micro-sign> */
- break;
- }
-
- if ( c > 0 ) {
- *o++ = c;
- return o;
- } else if ( !c )
- return NULL;
-
- /* else: c < 0 */
- n = -c;
- switch ( *s ) {
-
- case 'A': c = letter_w_diacritic[n][0]; break;
- case 'C': c = letter_w_diacritic[n][1]; break;
- case 'D': c = letter_w_diacritic[n][2]; break;
- case 'E': c = letter_w_diacritic[n][3]; break;
- case 'G': c = letter_w_diacritic[n][4]; break;
- case 'H': c = letter_w_diacritic[n][5]; break;
- case 'I': c = letter_w_diacritic[n][6]; break;
- case 'J': c = letter_w_diacritic[n][7]; break;
- case 'K': c = letter_w_diacritic[n][8]; break;
- case 'L': c = letter_w_diacritic[n][9]; break;
- case 'N': c = letter_w_diacritic[n][10]; break;
- case 'O': c = letter_w_diacritic[n][11]; break;
- case 'R': c = letter_w_diacritic[n][12]; break;
- case 'S': c = letter_w_diacritic[n][13]; break;
- case 'T': c = letter_w_diacritic[n][14]; break;
- case 'U': c = letter_w_diacritic[n][15]; break;
- case 'W': c = letter_w_diacritic[n][16]; break;
- case 'Y': c = letter_w_diacritic[n][17]; break;
- case 'Z': c = letter_w_diacritic[n][18]; break;
-
- case 'a': c = letter_w_diacritic[n][19]; break;
- case 'c': c = letter_w_diacritic[n][20]; break;
- case 'd': c = letter_w_diacritic[n][21]; break;
- case 'e': c = letter_w_diacritic[n][22]; break;
- case 'g': c = letter_w_diacritic[n][23]; break;
- case 'h': c = letter_w_diacritic[n][24]; break;
- case 'i': c = letter_w_diacritic[n][25]; break;
- case 'j': c = letter_w_diacritic[n][26]; break;
- case 'k': c = letter_w_diacritic[n][27]; break;
- case 'l': c = letter_w_diacritic[n][28]; break;
- case 'n': c = letter_w_diacritic[n][29]; break;
- case 'o': c = letter_w_diacritic[n][30]; break;
- case 'r': c = letter_w_diacritic[n][31]; break;
- case 's': c = letter_w_diacritic[n][32]; break;
- case 't': c = letter_w_diacritic[n][33]; break;
- case 'u': c = letter_w_diacritic[n][34]; break;
- case 'w': c = letter_w_diacritic[n][35]; break;
- case 'y': c = letter_w_diacritic[n][36]; break;
- case 'z': c = letter_w_diacritic[n][37]; break;
-
- case '\'':
- case ' ': c = -1; break;
-
- default: c = 0;
- }
-
- if ( !c )
- return NULL;
-
- *o++ = n + 0xC0;
- *o++ = ( ( (*s == ' ') || (*s == '\'') ) ? ALONE : *s );
- return o;
-}
-
-
-/* --- routine to convert from ISO 8859-n to T.61 --- */
-
-int
-ldap_8859_to_t61( char **bufp, unsigned int *buflenp, int free_input )
-{
- Byte *s, *oo, *o, *aux;
- int c;
- unsigned int len;
- Couple *cc;
-
- Debug( LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 112, "ldap_8859_to_t61 input length: %ld\n"),
- *buflenp, 0, 0 );
-
- len = *buflenp;
- s = (Byte *) *bufp;
-
- if ( (o = oo = (Byte *)malloc( 2 * len + 64 )) == NULL ) {
- return( 1 );
- }
-
- while ( (char *)s - *(char **)bufp < len ) {
- switch( *s >> 5 ) {
-
- case 2:
- switch ( *s ) {
-
- case '^': *o++ = 0xC3; *o++ = ALONE; s++; break;
-
- case '\\':
- s++;
- if ( (c = hh_to_c( s )) != -1 ) {
- *o++ = c;
- s += 2;
- } else
- *o++ = '\\';
- break;
-
- default: *o++ = *s++;
- }
- break;
-
- case 3:
- switch ( *s ) {
-
- case '`': *o++ = 0xC1; *o++ = ALONE; s++; break;
- case '~': *o++ = 0xC4; *o++ = ALONE; s++; break;
-
- case '{':
- s++;
- if ( *(s + 2) == '}' ) {
- if ( (aux = cc_to_t61( o, s )) != NULL ) {
- o = aux;
- s += 3;
- } else {
- *o++ = '{';
- }
- } else if ( (*(s + 3) == '}') && ( (*s == 'x') || (*s == 'X') ) &&
- ( (c = hh_to_c( s + 1 )) != -1 ) ) {
- *o++ = c;
- s += 4;
- } else {
- *o++ = '{';
- }
- break;
-
- default:
- *o++ = *s++;
- }
- break;
-
-#if (ISO_8859 == 0)
- case 4: case 5: case 6: case 7:
- s++;
- break;
-#else
- case 5: case 6: case 7:
-# if (ISO_8859 == 1) || (ISO_8859 == 2) || (ISO_8859 == 3) || \
- (ISO_8859 == 4) || (ISO_8859 == 9) || (ISO_8859 == 10)
- if ( (*(cc = &trans_iso8859_t61[ *s - 0xA0 ])).a ) {
- *o++ = (*cc).a;
- if ( (*cc).b ) *o++ = (*cc).b;
- }
-# endif
- s++;
- break;
-#endif
-
- default:
- *o++ = *s++;
- }
- }
-
- len = o - oo;
- o = oo;
-
- if ( (oo = (Byte *)realloc( o, len )) == NULL ) {
- free( o );
- return( 1 );
- }
-
- if ( free_input ) {
- free( *bufp );
- }
- *bufp = (char *) oo;
- *buflenp = len;
- return( 0 );
-}
-
-
-#ifdef NOT_NEEDED_IN_LIBLDAP /* mcs@umich.edu 12 Oct 1995 */
-/* --- routine to convert "escaped" (\hh) characters to 8bits --- */
-
-void convert_escaped_to_8bit( s )
-char *s;
-{
- char *o = s;
- int c;
-
- while ( *s ) {
- if ( *s == '\\' ) {
- if ( (c = hh_to_c( ++s )) != -1 ) {
- *o++ = c;
- s += 2;
- } else
- *o++ = '\\';
- } else
- *o++ = *s++;
- }
- *o = '\0';
-}
-
-/* --- routine to convert 8bits characters to the "escaped" (\hh) form --- */
-
-char *convert_8bit_to_escaped( s )
-Byte *s;
-{
- Byte *o, *oo;
- Byte n;
-
- if ( (o = oo = (Byte *)malloc( 2 * strlen( s ) + 64 )) == NULL ) {
- return( NULL );
- }
-
- while ( *s ) {
- if ( *s < 0x80 )
- *o++ = *s++;
- else {
- *o++ = '\\';
- n = *s >> 4;
- *o++ = ((n < 0xA) ? '0' : 'A' - 0xA) + n;
- n = *s++ & 0x0F;
- *o++ = ((n < 0xA) ? '0' : 'A' - 0xA) + n;
- }
- }
- *o = '\0';
-
- o = oo;
-
- if ( (oo = (Byte *)realloc( o, strlen( o ) + 1 )) == NULL ) {
- free( o );
- return( NULL );
- }
-
- return( (char *)oo );
-}
-
-/* --- routine to convert from T.61 to printable characters --- */
-
-/*
- printable characters [RFC 1488]: 'A'..'Z', 'a'..'z', '0'..'9',
- '\'', '(', ')', '+', ',', '-', '.', '/', ':', '?, ' '.
-
- that conversion is language dependent.
-*/
-
-static Couple last_t61_printabled[32] = {
- {0,0}, {'A','E'}, {'D',0}, {0,0},
- {'H',0}, {0,0}, {'I','J'}, {'L',0},
- {'L',0}, {'O',0}, {'O','E'}, {0,0},
- {'T','H'}, {'T',0}, {'N','G'}, {'n',0},
- {'k',0}, {'a','e'}, {'d',0}, {'d',0},
- {'h',0}, {'i',0}, {'i','j'}, {'l',0},
- {'l',0}, {'o',0}, {'o','e'}, {'s','s'},
- {'t','h'}, {'t',0}, {'n','g'}, {0,0}
-};
-
-char *t61_printable( s )
-Byte *s;
-{
- Byte *o, *oo;
- Byte n;
- Couple *cc;
-
- if ( (o = oo = (Byte *)malloc( 2 * strlen( s ) + 64 )) == NULL ) {
- return( NULL );
- }
-
- while ( *s ) {
- if ( ( (*s >= 'A') && (*s <= 'Z') ) ||
- ( (*s >= 'a') && (*s <= 'z') ) ||
- ( (*s >= '0') && (*s <= '9') ) ||
- ( (*s >= '\'') && (*s <= ')') ) ||
- ( (*s >= '+') && (*s <= '/') ) ||
- ( *s == '?' ) || ( *s == ' ' ) )
- *o++ = *s++;
- else {
- if ( *s >= 0xE0 ) {
- if ( (*(cc = &last_t61_printabled[ *s - 0xE0 ])).a ) {
- *o++ = (*cc).a;
- if ( (*cc).b ) *o++ = (*cc).b;
- }
- }
- else if ( (*s >> 4) == 0xC ) {
- switch ( *s ) {
- case 0xCA: /* ring */
- switch ( *(s + 1) ) {
- case 'A': *o++ = 'A'; *o++ = 'A'; s++; break; /* Swedish */
- case 'a': *o++ = 'a'; *o++ = 'a'; s++; break; /* Swedish */
- }
- break;
-
- case 0xC8: /* diaeresis */
- switch ( *(s + 1) ) {
- case 'Y': *o++ = 'I'; *o++ = 'J'; s++; break; /* Dutch */
- case 'y': *o++ = 'i'; *o++ = 'j'; s++; break; /* Dutch */
- }
- break;
- }
- }
- s++;
- }
- }
- *o = '\0';
-
- o = oo;
-
- if ( (oo = (Byte *)realloc( o, strlen( o ) + 1 )) == NULL ) {
- free( o );
- return( NULL );
- }
-
- return( (char *)oo );
-}
-#endif /* NOT_NEEDED_IN_LIBLDAP */ /* mcs@umich.edu 12 Oct 1995 */
-
-#endif /* LDAP_CHARSET_8859 */
-#endif /* STR_TRANSLATION */
diff --git a/usr/src/lib/libldap4/common/cldap.c b/usr/src/lib/libldap4/common/cldap.c
deleted file mode 100644
index 809fa4cce7..0000000000
--- a/usr/src/lib/libldap4/common/cldap.c
+++ /dev/null
@@ -1,597 +0,0 @@
-/*
- * Portions Copyright 1998 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*
- * Copyright (c) 1990, 1994 Regents of the University of Michigan.
- * All rights reserved.
- *
- * cldap.c - synchronous, retrying interface to the cldap protocol
- */
-
-
-#ifdef CLDAP
-
-#ifndef lint
-static char copyright[] = "@(#) Copyright (c) 1990, 1994 Regents of the University of Michigan.\nAll rights reserved.\n";
-#endif
-
-#include <stdio.h>
-#include <string.h>
-#include <errno.h>
-#ifdef MACOS
-#include <stdlib.h>
-#include "macos.h"
-#else /* MACOS */
-#ifdef DOS
-#include "msdos.h"
-#else /* DOS */
-#include <sys/time.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <netdb.h>
-#endif /* DOS */
-#endif /* MACOS */
-#ifdef SUN
-#include <nss_dbdefs.h>
-#endif
-
-#include "lber.h"
-#include "ldap.h"
-#include "ldap-private.h"
-#include "ldap-int.h"
-
-#define DEF_CLDAP_TIMEOUT 3
-#define DEF_CLDAP_TRIES 4
-
-#ifndef INADDR_LOOPBACK
-#define INADDR_LOOPBACK ((in_addr_t) 0x7f000001)
-#endif
-
-
-struct cldap_retinfo {
- int cri_maxtries;
- int cri_try;
- int cri_useaddr;
- time_t cri_timeout;
-};
-
-#ifdef NEEDPROTOS
-static int add_addr( LDAP *ld, struct sockaddr *sap );
-static int cldap_result( LDAP *ld, int msgid, LDAPMessage **res,
- struct cldap_retinfo *crip, char *base );
-static int cldap_parsemsg( LDAP *ld, int msgid, BerElement *ber,
- LDAPMessage **res, char *base );
-#else /* NEEDPROTOS */
-static int add_addr();
-static int cldap_result();
-static int cldap_parsemsg();
-#endif /* NEEDPROTOS */
-
-/*
- * cldap_open - initialize and connect to an ldap server. A magic cookie to
- * be used for future communication is returned on success, NULL on failure.
- *
- * Example:
- * LDAP *ld;
- * ld = cldap_open( hostname, port );
- */
-
-LDAP *
-cldap_open( char *host, int port )
-{
- int s;
- in_addr_t address;
- struct sockaddr_in sock;
- struct hostent *hp;
- LDAP *ld;
- char *p;
- int i;
-#ifdef SUN
- struct hostent hpret;
- char hpbuf[NSS_BUFLEN_HOSTS];
- int hperrno;
-#endif
- in_addr_t inet_addr(const char *);
- int close(int);
-
- Debug( LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 113, "ldap_open\n"), 0, 0, 0 );
-
- if ( port == 0 ) {
- port = LDAP_PORT;
- }
-
- if ( (s = socket( AF_INET, SOCK_DGRAM, 0 )) < 0 ) {
- return( NULL );
- }
-
- sock.sin_addr.s_addr = 0;
- sock.sin_family = AF_INET;
- sock.sin_port = 0;
- if ( bind(s, (struct sockaddr *) &sock, sizeof(sock)) < 0) {
- close( s );
- return( NULL );
- }
-
- if (( ld = ldap_init( host, port )) == NULL ) {
- close( s );
- return( NULL );
- }
- if ( (ld->ld_sb.sb_fromaddr = (void *) calloc( 1,
- sizeof( struct sockaddr ))) == NULL ) {
- free( ld );
- close( s );
- return( NULL );
- }
- ld->ld_sb.sb_sd = s;
- ld->ld_sb.sb_naddr = 0;
- ld->ld_version = LDAP_VERSION;
-
- sock.sin_family = AF_INET;
- sock.sin_port = htons( port );
-
- /*
- * 'host' may be a space-separated list.
- */
- if ( host != NULL ) {
- for ( ; host != NULL; host = p ) {
- if (( p = strchr( host, ' ' )) != NULL ) {
- for (*p++ = '\0'; *p == ' '; p++) {
- ;
- }
- }
-
- if ( (address = inet_addr( host )) == -1 ) {
-#ifdef SUN
- if ( (hp = gethostbyname_r( host, &hpret, hpbuf, NSS_BUFLEN_HOSTS, &hperrno)) == NULL ) {
- errno = EHOSTUNREACH;
- continue;
- }
-#else
- if ( (hp = gethostbyname( host )) == NULL ) {
- errno = EHOSTUNREACH;
- continue;
- }
-#endif
-
- for ( i = 0; hp->h_addr_list[ i ] != 0; ++i ) {
- SAFEMEMCPY( (char *)&sock.sin_addr.s_addr,
- (char *)hp->h_addr_list[ i ],
- sizeof(sock.sin_addr.s_addr));
- if ( add_addr( ld, (struct sockaddr *)&sock ) < 0 ) {
- close( s );
- free( ld );
- return( NULL );
- }
- }
-
- } else {
- sock.sin_addr.s_addr = address;
- if ( add_addr( ld, (struct sockaddr *)&sock ) < 0 ) {
- close( s );
- free( ld );
- return( NULL );
- }
- }
-
- if ( ld->ld_host == NULL ) {
- ld->ld_host = strdup( host );
- }
- }
-
- } else {
- address = INADDR_LOOPBACK;
- sock.sin_addr.s_addr = htonl( address );
- if ( add_addr( ld, (struct sockaddr *)&sock ) < 0 ) {
- close( s );
- free( ld );
- return( NULL );
- }
- }
-
- if ( ld->ld_sb.sb_addrs == NULL
-#ifdef LDAP_REFERRALS
- || ( ld->ld_defconn = new_connection( ld, NULL, 1,0,0 )) == NULL
-#endif /* LDAP_REFERRALS */
- ) {
- free( ld );
- return( NULL );
- }
-
- ld->ld_sb.sb_useaddr = ld->ld_sb.sb_addrs[ 0 ];
- cldap_setretryinfo( ld, 0, 0 );
-
-#ifdef LDAP_DEBUG
- putchar( '\n' );
- for ( i = 0; i < ld->ld_sb.sb_naddr; ++i ) {
- Debug( LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 114, "end of cldap_open address %1$d is %2$s\n"),
- i, inet_ntoa( ((struct sockaddr_in *)
- ld->ld_sb.sb_addrs[ i ])->sin_addr ), 0 );
- }
-#endif
-
- return( ld );
-}
-
-
-
-void
-cldap_close( LDAP *ld )
-{
- ldap_ld_free( ld, 0 );
-}
-
-
-void
-cldap_setretryinfo( LDAP *ld, int tries, time_t timeout )
-{
-#if defined( SUN ) && defined( _REENTRANT )
- LOCK_LDAP(ld);
-#endif
- ld->ld_cldaptries = ( tries <= 0 ) ? DEF_CLDAP_TRIES : tries;
- ld->ld_cldaptimeout = ( timeout <= 0 ) ? DEF_CLDAP_TIMEOUT : timeout;
-#if defined( SUN ) && defined( _REENTRANT )
- UNLOCK_LDAP(ld);
-#endif
-}
-
-
-int
-cldap_search_s( LDAP *ld, char *base, int scope, char *filter, char **attrs,
- int attrsonly, LDAPMessage **res, char *logdn )
-{
- int ret, msgid;
- struct cldap_retinfo cri;
-
- *res = NULLMSG;
-
- (void) memset( &cri, 0, sizeof( cri ));
-
-#if defined( SUN ) && defined( _REENTRANT )
- LOCK_LDAP(ld);
-#endif
-
- if ( logdn != NULL ) {
- ld->ld_cldapdn = logdn;
- } else if ( ld->ld_cldapdn == NULL ) {
- ld->ld_cldapdn = "";
- }
-
- do {
- if ( cri.cri_try != 0 ) {
- --ld->ld_msgid; /* use same id as before */
- }
- ld->ld_sb.sb_useaddr = ld->ld_sb.sb_addrs[ cri.cri_useaddr ];
-
- Debug( LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 115, "cldap_search_s try %1$d (to %2$s)\n"),
- cri.cri_try, inet_ntoa( ((struct sockaddr_in *)
- ld->ld_sb.sb_useaddr)->sin_addr ), 0 );
-
- if ( (msgid = ldap_search( ld, base, scope, filter, attrs,
- attrsonly )) == -1 ) {
-#if defined( SUN ) && defined( _REENTRANT )
- UNLOCK_LDAP(ld);
-#endif
- return( ld->ld_errno );
- }
-#ifndef NO_CACHE
-#if defined( SUN ) && defined( _REENTRANT )
- LOCK_RESPONSE(ld);
-#endif
- if ( ld->ld_cache != NULL && ld->ld_responses != NULL ) {
- Debug( LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 116, "cldap_search_s res from cache\n"),
- 0, 0, 0 );
- *res = ld->ld_responses;
- ld->ld_responses = ld->ld_responses->lm_next;
-#if defined( SUN ) && defined( _REENTRANT )
- UNLOCK_LDAP(ld);
- ret = ldap_result2error( ld, *res, 0 );
- UNLOCK_RESPONSE(ld);
- return( ret );
-#else
- return( ldap_result2error( ld, *res, 0 ));
-#endif
- }
-#endif /* NO_CACHE */
- ret = cldap_result( ld, msgid, res, &cri, base );
-#if defined( SUN ) && defined( _REENTRANT )
- UNLOCK_RESPONSE(ld);
-#endif
- } while (ret == -1);
-
- return( ret );
-}
-
-
-static int
-add_addr( LDAP *ld, struct sockaddr *sap )
-{
- struct sockaddr *newsap, **addrs;
-
- if (( newsap = (struct sockaddr *)malloc( sizeof( struct sockaddr )))
- == NULL ) {
- ld->ld_errno = LDAP_NO_MEMORY;
- return( -1 );
- }
-
- if ( ld->ld_sb.sb_naddr == 0 ) {
- addrs = (struct sockaddr **)malloc( sizeof(struct sockaddr *));
- } else {
- addrs = (struct sockaddr **)realloc( ld->ld_sb.sb_addrs,
- ( ld->ld_sb.sb_naddr + 1 ) * sizeof(struct sockaddr *));
- }
-
- if ( addrs == NULL ) {
- free( newsap );
- ld->ld_errno = LDAP_NO_MEMORY;
- return( -1 );
- }
-
- SAFEMEMCPY( (char *)newsap, (char *)sap, sizeof( struct sockaddr ));
- addrs[ ld->ld_sb.sb_naddr++ ] = newsap;
- ld->ld_sb.sb_addrs = (void **)addrs;
- return( 0 );
-}
-
-
-static int
-cldap_result( LDAP *ld, int msgid, LDAPMessage **res,
- struct cldap_retinfo *crip, char *base )
-{
- Sockbuf *sb;
- BerElement ber;
- char *logdn;
- int ret, id, fromaddr, i;
- struct timeval tv;
-
-#if defined( SUN ) && defined( _REENTRANT )
- LOCK_LDAP(ld);
-#endif
-
- sb = &ld->ld_sb;
- fromaddr = -1;
-
- if ( crip->cri_try == 0 ) {
- crip->cri_maxtries = ld->ld_cldaptries * sb->sb_naddr;
- crip->cri_timeout = ld->ld_cldaptimeout;
- crip->cri_useaddr = 0;
- Debug( LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 117, "cldap_result tries %1$d timeout %2$d\n"),
- ld->ld_cldaptries, ld->ld_cldaptimeout, 0 );
- }
-
- if ((tv.tv_sec = crip->cri_timeout / sb->sb_naddr) < 1 ) {
- tv.tv_sec = 1;
- }
- tv.tv_usec = 0;
-
- Debug( LDAP_DEBUG_TRACE,
- catgets(slapdcat, 1, 118, "cldap_result waiting up to %d seconds for a response\n"),
- tv.tv_sec, 0, 0 );
- ber_zero_init( &ber, 0 );
- set_ber_options( ld, &ber );
-
- if ( cldap_getmsg( ld, &tv, &ber ) == -1 ) {
- ret = ld->ld_errno;
- Debug( LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 119, "cldap_getmsg returned -1 (%d)\n"),
- ret, 0, 0 );
- } else if ( ld->ld_errno == LDAP_TIMEOUT ) {
- Debug( LDAP_DEBUG_TRACE,
- catgets(slapdcat, 1, 120, "cldap_result timed out\n"), 0, 0, 0 );
- /*
- * It timed out; is it time to give up?
- */
- if ( ++crip->cri_try >= crip->cri_maxtries ) {
- ret = LDAP_TIMEOUT;
- --crip->cri_try;
- } else {
- if ( ++crip->cri_useaddr >= sb->sb_naddr ) {
- /*
- * new round: reset address to first one and
- * double the timeout
- */
- crip->cri_useaddr = 0;
- crip->cri_timeout <<= 1;
- }
- ret = -1;
- }
-
- } else {
- /*
- * Got a response. It should look like:
- * { msgid, logdn, { searchresponse...}}
- */
- logdn = NULL;
-
- if ( ber_scanf( &ber, "ia", &id, &logdn ) == LBER_ERROR ) {
- free( ber.ber_buf ); /* gack! */
- ret = LDAP_DECODING_ERROR;
- Debug( LDAP_DEBUG_TRACE,
- catgets(slapdcat, 1, 121, "cldap_result: ber_scanf returned LBER_ERROR (%d)\n"),
- ret, 0, 0 );
- } else if ( id != msgid ) {
- free( ber.ber_buf ); /* gack! */
- Debug( LDAP_DEBUG_TRACE,
- catgets(slapdcat, 1, 122, "cldap_result: looking for msgid %1$d; got %2$d\n"),
- msgid, id, 0 );
- ret = -1; /* ignore and keep looking */
- } else {
- /*
- * got a result: determine which server it came from
- * decode into ldap message chain
- */
- for ( fromaddr = 0; fromaddr < sb->sb_naddr; ++fromaddr ) {
- if ( memcmp( &((struct sockaddr_in *)
- sb->sb_addrs[ fromaddr ])->sin_addr,
- &((struct sockaddr_in *)sb->sb_fromaddr)->sin_addr,
- sizeof( struct in_addr )) == 0 ) {
- break;
- }
- }
- ret = cldap_parsemsg( ld, msgid, &ber, res, base );
- free( ber.ber_buf ); /* gack! */
- Debug( LDAP_DEBUG_TRACE,
- catgets(slapdcat, 1, 123, "cldap_result got result (%d)\n"), ret, 0, 0 );
- }
-
- if ( logdn != NULL ) {
- free( logdn );
- }
- }
-
-
- /*
- * If we are giving up (successfully or otherwise) then
- * abandon any outstanding requests.
- */
- if ( ret != -1 ) {
- i = crip->cri_try;
- if ( i >= sb->sb_naddr ) {
- i = sb->sb_naddr - 1;
- }
-
- for ( ; i >= 0; --i ) {
- if ( i == fromaddr ) {
- continue;
- }
- sb->sb_useaddr = sb->sb_addrs[ i ];
- Debug( LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 124, "cldap_result abandoning id %1$d (to %2$s)\n"),
- msgid, inet_ntoa( ((struct sockaddr_in *)
- sb->sb_useaddr)->sin_addr ), 0 );
- (void) ldap_abandon( ld, msgid );
- }
- }
-
-#if defined( SUN ) && defined( _REENTRANT )
- UNLOCK_LDAP(ld);
-#endif
- return( ld->ld_errno = ret );
-}
-
-
-static int
-cldap_parsemsg( LDAP *ld, int msgid, BerElement *ber,
- LDAPMessage **res, char *base )
-{
- unsigned int tag, len;
- int rc;
- size_t baselen, slen;
- char *dn, *p, *cookie;
- LDAPMessage *chain, *prev, *ldm;
- struct berval *bv;
-
- rc = LDAP_DECODING_ERROR; /* pessimistic */
- ldm = chain = prev = NULLMSG;
- baselen = ( base == NULL ) ? 0 : strlen( base );
- bv = NULL;
-
- for ( tag = ber_first_element( ber, &len, &cookie );
- tag != LBER_DEFAULT && rc != LDAP_SUCCESS;
- tag = ber_next_element( ber, &len, cookie )) {
- if (( ldm = (LDAPMessage *)calloc( 1, sizeof(LDAPMessage)))
- == NULL || ( ldm->lm_ber = alloc_ber_with_options( ld ))
- == NULLBER ) {
- rc = LDAP_NO_MEMORY;
- break; /* return w/error*/
- }
- ldm->lm_msgid = msgid;
- ldm->lm_msgtype = tag;
-
- if ( tag == LDAP_RES_SEARCH_RESULT ) {
- Debug( LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 125, "cldap_parsemsg got search result\n"),
- 0, 0, 0 );
-
- if ( ber_get_stringal( ber, &bv ) == LBER_DEFAULT ) {
- break; /* return w/error */
- }
-
- if ( ber_printf( ldm->lm_ber, "to", tag, bv->bv_val,
- bv->bv_len ) == -1 ) {
- break; /* return w/error */
- }
- ber_bvfree( bv );
- bv = NULL;
- rc = LDAP_SUCCESS;
-
- } else if ( tag == LDAP_RES_SEARCH_ENTRY ) {
- if ( ber_scanf( ber, "{aO", &dn, &bv ) == LBER_ERROR ) {
- break; /* return w/error */
- }
- Debug( LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 126, "cldap_parsemsg entry %s\n"), dn, 0, 0 );
- if ( dn != NULL && *(dn + ( slen = strlen(dn)) - 1) == '*' &&
- baselen > 0 ) {
- /*
- * substitute original searchbase for trailing '*'
- */
- if (( p = (char *)malloc( slen + baselen )) == NULL ) {
- rc = LDAP_NO_MEMORY;
- free( dn );
- break; /* return w/error */
- }
- strcpy( p, dn );
- strcpy( p + slen - 1, base );
- free( dn );
- dn = p;
- }
-
- if ( ber_printf( ldm->lm_ber, "t{so}", tag, dn, bv->bv_val,
- bv->bv_len ) == -1 ) {
- break; /* return w/error */
- }
- free( dn );
- ber_bvfree( bv );
- bv = NULL;
-
- } else {
- Debug( LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 127, "cldap_parsemsg got unknown tag %d\n"),
- tag, 0, 0 );
- rc = LDAP_PROTOCOL_ERROR;
- break; /* return w/error */
- }
-
- /* Reset message ber so we can read from it later. Gack! */
- ldm->lm_ber->ber_end = ldm->lm_ber->ber_ptr;
- ldm->lm_ber->ber_ptr = ldm->lm_ber->ber_buf;
-
-#ifdef LDAP_DEBUG
- if ( ldap_debug & LDAP_DEBUG_PACKETS ) {
- fprintf( stderr, "cldap_parsemsg add message id %d type %d:\n",
- ldm->lm_msgid, ldm->lm_msgtype );
- ber_dump( ldm->lm_ber, 1 );
- }
-#endif /* LDAP_DEBUG */
-
-#ifndef NO_CACHE
- if ( ld->ld_cache != NULL ) {
- add_result_to_cache( ld, ldm );
- }
-#endif /* NO_CACHE */
-
- if ( chain == NULL ) {
- chain = ldm;
- } else {
- prev->lm_chain = ldm;
- }
- prev = ldm;
- ldm = NULL;
- }
-
- /* dispose of any leftovers */
- if ( ldm != NULL ) {
- if ( ldm->lm_ber != NULLBER ) {
- ber_free( ldm->lm_ber, 1 );
- }
- free( ldm );
- }
- if ( bv != NULL ) {
- ber_bvfree( bv );
- }
-
- /* return chain, calling result2error if we got anything at all */
- *res = chain;
- return(( *res == NULLMSG ) ? rc : ldap_result2error( ld, *res, 0 ));
-}
-#endif /* CLDAP */
diff --git a/usr/src/lib/libldap4/common/compare.c b/usr/src/lib/libldap4/common/compare.c
deleted file mode 100644
index 8202580a7b..0000000000
--- a/usr/src/lib/libldap4/common/compare.c
+++ /dev/null
@@ -1,259 +0,0 @@
-/*
- * Portions Copyright 1998 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*
- * Copyright (c) 1990 Regents of the University of Michigan.
- * All rights reserved.
- *
- * compare.c
- */
-
-#ifndef lint
-static char copyright[] = "@(#) Copyright (c) 1990 Regents of the University of Michigan.\nAll rights reserved.\n";
-#endif
-
-#include <stdio.h>
-#include <string.h>
-
-#ifdef MACOS
-#include "macos.h"
-#endif /* MACOS */
-
-#if !defined( MACOS ) && !defined( DOS )
-#include <sys/types.h>
-#include <sys/socket.h>
-#endif
-
-#include "lber.h"
-#include "ldap.h"
-#include "ldap-private.h"
-#include "ldap-int.h"
-
-BerElement * ldap_build_compare_req(LDAP *ld, char *dn, char *attr,
- struct berval *bvalue, LDAPControl **serverctrls)
-{
- BerElement *ber;
- int rc, rv;
-
- /* The compare request looks like this:
- * CompareRequest ::= SEQUENCE {
- * entry DistinguishedName,
- * ava SEQUENCE {
- * type AttributeType,
- * value AttributeValue
- * }
- * }
- * and must be wrapped in an LDAPMessage.
- */
- /* create a message to send */
- if ( (ber = alloc_ber_with_options( ld )) == NULLBER ) {
- ld->ld_errno = LDAP_NO_MEMORY;
- return( NULLBER );
- }
-
- if ( ber_printf( ber, "{it{s{so}}", ++ld->ld_msgid, LDAP_REQ_COMPARE,
- dn, attr, bvalue->bv_val, bvalue->bv_len ) == -1 ) {
- ld->ld_errno = LDAP_ENCODING_ERROR;
- ber_free( ber, 1 );
- return( NULLBER );
- }
-
- /* LDAPv3 */
- /* Code controls if any */
- if (serverctrls && serverctrls[0]) {
- if (ldap_controls_code(ber, serverctrls) != LDAP_SUCCESS){
- ld->ld_errno = LDAP_ENCODING_ERROR;
- return( NULLBER );
- }
- } else if (ld->ld_srvctrls && ld->ld_srvctrls[0]) {
- /* Otherwise, is there any global server ctrls ? */
- if (ldap_controls_code(ber, ld->ld_srvctrls) != LDAP_SUCCESS){
- ld->ld_errno = LDAP_ENCODING_ERROR;
- return( NULLBER );
- }
- }
- if (ber_printf(ber, "}") == -1) {
- ld->ld_errno = LDAP_ENCODING_ERROR;
- ber_free(ber, 1);
- return (NULLBER);
- }
-
- return (ber);
-}
-
-/*
- * ldap_compare - perform an ldap (and X.500) compare operation. The dn
- * of the entry to compare to and the attribute and value to compare (in
- * attr and value) are supplied. The msgid of the response is returned.
- *
- * Example:
- * ldap_compare( ld, "c=us@cn=bob", "userPassword", "secret" )
- */
-int
-ldap_compare( LDAP *ld, char *dn, char *attr, char *value )
-{
- BerElement *ber;
- struct berval bv;
- int rv;
-
- /* The compare request looks like this:
- * CompareRequest ::= SEQUENCE {
- * entry DistinguishedName,
- * ava SEQUENCE {
- * type AttributeType,
- * value AttributeValue
- * }
- * }
- * and must be wrapped in an LDAPMessage.
- */
-
-#ifdef _REENTRANT
- LOCK_LDAP(ld);
-#endif
- Debug( LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 128, "ldap_compare\n"), 0, 0, 0 );
-
- bv.bv_val = value;
- bv.bv_len = strlen(value);
-
- if ((ber = ldap_build_compare_req(ld, dn, attr, &bv, NULL)) == NULLBER) {
-#ifdef _REENTRANT
- UNLOCK_LDAP(ld);
-#endif
- return (-1);
- }
-
-#ifndef NO_CACHE
- if ( ld->ld_cache != NULL ) {
- if ( check_cache( ld, LDAP_REQ_COMPARE, ber ) == 0 ) {
- ber_free( ber, 1 );
- ld->ld_errno = LDAP_SUCCESS;
-#ifdef _REENTRANT
- UNLOCK_LDAP(ld);
-#endif
- return( ld->ld_msgid );
- }
- add_request_to_cache( ld, LDAP_REQ_COMPARE, ber );
- }
-#endif /* NO_CACHE */
-
- /* send the message */
- rv = send_initial_request( ld, LDAP_REQ_COMPARE, dn, ber );
-#ifdef _REENTRANT
- UNLOCK_LDAP(ld);
-#endif
- return (rv);
-}
-
-int
-ldap_compare_s( LDAP *ld, char *dn, char *attr, char *value )
-{
- int msgid;
- LDAPMessage *res;
-
- if ( (msgid = ldap_compare( ld, dn, attr, value )) == -1 )
- return( ld->ld_errno );
-
- if ( ldap_result( ld, msgid, 1, (struct timeval *) NULL, &res ) == -1 )
- return( ld->ld_errno );
-
- return( ldap_result2error( ld, res, 1 ) );
-}
-
-/* LDAPv3 API extensions */
-int ldap_compare_ext(LDAP *ld, char *dn, char *attr, struct berval *bvalue,
- LDAPControl ** serverctrls, LDAPControl **clientctrls, int *msgidp)
-{
- BerElement *ber;
- struct berval bv;
- int rv;
-
- /* The compare request looks like this:
- * CompareRequest ::= SEQUENCE {
- * entry DistinguishedName,
- * ava SEQUENCE {
- * type AttributeType,
- * value AttributeValue
- * }
- * }
- * and must be wrapped in an LDAPMessage.
- */
-
-#ifdef _REENTRANT
- LOCK_LDAP(ld);
-#endif
- Debug( LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 128, "ldap_compare\n"), 0, 0, 0 );
-
- if ((ber = ldap_build_compare_req(ld, dn, attr, bvalue, NULL)) == NULLBER) {
- rv = ld->ld_errno;
- if (rv == LDAP_SUCCESS)
- rv = LDAP_OTHER;
-#ifdef _REENTRANT
- UNLOCK_LDAP(ld);
-#endif
- return (rv);
- }
-
-#ifndef NO_CACHE
- if ( ld->ld_cache != NULL ) {
- if ( check_cache( ld, LDAP_REQ_COMPARE, ber ) == 0 ) {
- ber_free( ber, 1 );
- ld->ld_errno = LDAP_SUCCESS;
- *msgidp = ld->ld_msgid;
-#ifdef _REENTRANT
- UNLOCK_LDAP(ld);
-#endif
- return( LDAP_SUCCESS );
- }
- add_request_to_cache( ld, LDAP_REQ_COMPARE, ber );
- }
-#endif /* NO_CACHE */
-
- /* send the message */
- rv = send_initial_request( ld, LDAP_REQ_COMPARE, dn, ber );
- if (rv == -1) {
- rv = ld->ld_errno;
- if (rv == LDAP_SUCCESS){
- rv = LDAP_OTHER;
- }
-#ifdef _REENTRANT
- UNLOCK_LDAP(ld);
-#endif
- return (rv);
- }
-
- *msgidp = rv;
-#ifdef _REENTRANT
- UNLOCK_LDAP(ld);
-#endif
- return (LDAP_SUCCESS);
-}
-
-int ldap_compare_ext_s(LDAP *ld, char *dn, char *attr, struct berval *bvalue,
- LDAPControl ** serverctrls, LDAPControl **clientctrls)
-{
- int msgid, retcode = LDAP_SUCCESS;
- LDAPMessage *res;
-
- if ( (retcode = ldap_compare_ext( ld, dn, attr, bvalue, serverctrls, clientctrls, &msgid )) != LDAP_SUCCESS )
- return( retcode );
-
- if ( ldap_result( ld, msgid, 1, (struct timeval *) NULL, &res ) == -1 )
- return( ld->ld_errno );
-
-#ifdef _REENTRANT
- LOCK_LDAP(ld);
-#endif
- retcode = ldap_parse_result( ld, res, &ld->ld_errno, &ld->ld_matched, &ld->ld_error,
- &ld->ld_referrals, &ld->ld_ret_ctrls, 1);
- if (retcode == LDAP_SUCCESS)
- retcode = ld->ld_errno;
-#ifdef _REENTRANT
- UNLOCK_LDAP(ld);
-#endif
- return (retcode);
-}
-
diff --git a/usr/src/lib/libldap4/common/controls.c b/usr/src/lib/libldap4/common/controls.c
deleted file mode 100644
index fb61e5e56c..0000000000
--- a/usr/src/lib/libldap4/common/controls.c
+++ /dev/null
@@ -1,291 +0,0 @@
-/*
- *
- * Copyright 1999 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- *
- *
- * Comments:
- *
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#include <stdio.h>
-#include <string.h>
-#include "lber.h"
-#include "ldap.h"
-#include "ldap-private.h"
-#include "ldap-int.h"
-
-static int ldap_control_copy_contents(LDAPControl *, LDAPControl *);
-
-void ldap_control_free (LDAPControl *ctrl)
-{
- if (ctrl != NULL){
- if (ctrl->ldctl_oid)
- free (ctrl->ldctl_oid);
- if (ctrl->ldctl_value.bv_val != NULL)
- free (ctrl->ldctl_value.bv_val);
- free ((char *)ctrl);
- }
- return;
-}
-
-void ldap_controls_free (LDAPControl **ctrls)
-{
- int i;
-
- if (ctrls == NULL)
- return;
-
- for (i = 0; ctrls[i] != NULL; i++){
- ldap_control_free(ctrls[i]);
- }
- free((char *)ctrls);
-}
-
-LDAPControl * ldap_control_dup(LDAPControl *ctrl)
-{
- LDAPControl *newctrl;
-
- if ((newctrl = (LDAPControl *)calloc(1, sizeof(LDAPControl))) == NULL)
- return (NULL);
-
- if (ldap_control_copy_contents(newctrl, ctrl) != LDAP_SUCCESS) {
- free(newctrl);
- return (NULL);
- }
-
- return(newctrl);
-}
-
-
-static int ldap_control_copy_contents(LDAPControl *ctrl_dst,
-LDAPControl *ctrl_src)
-{
- size_t len;
-
- if (NULL == ctrl_dst || NULL == ctrl_src) {
- return (LDAP_PARAM_ERROR);
- }
-
- ctrl_dst->ldctl_iscritical = ctrl_src->ldctl_iscritical;
-
- /* fill in the fields of this new control */
- if ((ctrl_dst->ldctl_oid = strdup(ctrl_src->ldctl_oid)) == NULL) {
- return (LDAP_NO_MEMORY);
- }
-
- len = (size_t)(ctrl_src->ldctl_value).bv_len;
- if (ctrl_src->ldctl_value.bv_val == NULL || len <= 0) {
- ctrl_dst->ldctl_value.bv_len = 0;
- ctrl_dst->ldctl_value.bv_val = NULL;
- } else {
- ctrl_dst->ldctl_value.bv_len = len;
- if ((ctrl_dst->ldctl_value.bv_val = malloc(len))
- == NULL) {
- free(ctrl_dst->ldctl_oid);
- return (LDAP_NO_MEMORY);
- }
- SAFEMEMCPY(ctrl_dst->ldctl_value.bv_val,
- ctrl_src->ldctl_value.bv_val, len);
- }
-
- return (LDAP_SUCCESS);
-}
-
-
-LDAPControl ** ldap_controls_dup(LDAPControl ** ctrls)
-{
- int i;
- LDAPControl **newctrls;
-
- for (i = 0; ctrls[i] != NULL; i++);
- newctrls = (LDAPControl **)calloc(i+1, sizeof(LDAPControl*));
- if (newctrls == NULL) {
- return (NULL);
- }
-
- for (i = 0; ctrls[i] != NULL; i++) {
- newctrls[i] = ldap_control_dup(ctrls[i]);
- if (newctrls[i] == NULL) {
- ldap_controls_free(newctrls);
- return (NULL);
- }
- }
- return (newctrls);
-}
-
-int ldap_controls_code (BerElement *ber, LDAPControl **ctrls)
-{
- int i, rc;
-
- if (ctrls && ctrls[0]){
- rc = ber_printf(ber, "t{", LDAP_TAG_CONTROL_LIST);
- if (rc == -1){
- ber_free(ber, 1);
- return(LDAP_ENCODING_ERROR);
- }
-
- for (i = 0; ctrls[i] != NULL; i++){
- rc = ber_printf(ber, "{s", ctrls[i]->ldctl_oid);
- if (rc == -1){
- ber_free(ber, 1);
- return(LDAP_ENCODING_ERROR);
- }
- if (ctrls[i]->ldctl_iscritical){
- rc = ber_printf(ber, "b", ctrls[i]->ldctl_iscritical);
- if (rc == -1){
- ber_free(ber, 1);
- return(LDAP_ENCODING_ERROR);
- }
- }
-
- if (ctrls[i]->ldctl_value.bv_val)
- rc = ber_printf(ber, "o}", ctrls[i]->ldctl_value.bv_val, ctrls[i]->ldctl_value.bv_len);
- else
- rc = ber_printf(ber, "}");
- if (rc == -1){
- ber_free(ber, 1);
- return(LDAP_ENCODING_ERROR);
- }
- }
-
- rc = ber_printf(ber, "}");
- if (rc == -1){
- ber_free(ber, 1);
- return(LDAP_ENCODING_ERROR);
- }
- }
- return (LDAP_SUCCESS);
-}
-
-/* Decode the sequence of control from the ber, return a NULL terminated list of LDAPControl* */
-LDAPControl ** ldap_controls_decode(BerElement *ber, int *errcode)
-{
- LDAPControl ** ctrls = NULL;
-
- char *opaque;
- unsigned int tag, len;
- int i = 0, count = 0;
-
- BerElement tmpber = *ber;
-
- for (tag = ber_first_element(&tmpber, &len, &opaque);
- tag != LBER_DEFAULT;
- tag = ber_next_element(&tmpber, &len, opaque )) {
- count ++;
- ber_skip_tag(&tmpber, &len);
- }
-
-
- if ((ctrls = (LDAPControl **)calloc(count + 1, sizeof(LDAPControl *))) == NULL){
- *errcode = LDAP_NO_MEMORY;
- return(NULL);
- }
-
- for (tag = ber_first_element(ber, &len, &opaque );
- tag != LBER_DEFAULT;
- tag = ber_next_element (ber, &len, opaque )) {
- LDAPControl *aCtrl;
- unsigned int ttag, tlen;
-
- if ((aCtrl = (LDAPControl *)calloc(1, sizeof(LDAPControl))) == NULL) {
- *errcode = LDAP_NO_MEMORY;
- ldap_controls_free(ctrls);
- return (NULL);
- }
- if (ber_scanf(ber, "{a", &aCtrl->ldctl_oid) == LBER_ERROR){
- *errcode = LDAP_PROTOCOL_ERROR;
- free(aCtrl);
- ldap_controls_free(ctrls);
- return (NULL);
- }
- aCtrl->ldctl_iscritical = 0;
- ttag = ber_peek_tag(ber, &tlen);
- if (ttag == 0x01) { /* Boolean : criticality */
- if (ber_scanf(ber, "b", &aCtrl->ldctl_iscritical) == LBER_ERROR){
- *errcode = LDAP_PROTOCOL_ERROR;
- free(aCtrl);
- ldap_controls_free(ctrls);
- return (NULL);
- }
- ttag = ber_peek_tag(ber, &tlen);
- }
- if (ttag == 0x04) { /* Octet string : value (it's optional)*/
- if (ber_scanf(ber, "o", &aCtrl->ldctl_value) == LBER_ERROR){
- *errcode = LDAP_PROTOCOL_ERROR;
- free(aCtrl);
- ldap_controls_free(ctrls);
- return (NULL);
- }
-
- } else if (ttag != LBER_DEFAULT){
- *errcode = LDAP_PROTOCOL_ERROR;
- free(aCtrl);
- ldap_controls_free(ctrls);
- return (NULL);
- }
-
- if (ber_scanf(ber, "}") == LBER_ERROR){
- *errcode = LDAP_PROTOCOL_ERROR;
- free(aCtrl);
- ldap_controls_free(ctrls);
- return (NULL);
- }
- /* add aCtrl in ctrls */
- ctrls[i++] = aCtrl;
- }
- return (ctrls);
-}
-
-/* build an allocated LDAPv3 control. Returns an LDAP error code. */
-int ldap_build_control(char *oid, BerElement *ber, int freeber,
-char iscritical, LDAPControl **ctrlp)
-{
- int rc;
- struct berval *bvp;
-
- if (ber == NULL) {
- bvp = NULL;
- } else {
- /* allocate struct berval with contents of the BER encoding */
- rc = ber_flatten(ber, &bvp);
- if (freeber) {
- ber_free(ber, 1);
- }
- if (rc == -1) {
- return (LDAP_NO_MEMORY);
- }
- }
-
- /* allocate the new control structure */
- if ((*ctrlp = (LDAPControl *)calloc(1, sizeof (LDAPControl)))
- == NULL) {
- if (bvp != NULL) {
- ber_bvfree(bvp);
- }
- return (LDAP_NO_MEMORY);
- }
-
- /* fill in the fields of this new control */
- (*ctrlp)->ldctl_iscritical = iscritical;
- if (((*ctrlp)->ldctl_oid = strdup(oid)) == NULL) {
- free(*ctrlp);
- *ctrlp = NULL;
- if (bvp != NULL) {
- ber_bvfree(bvp);
- }
- return (LDAP_NO_MEMORY);
- }
-
- if (bvp == NULL) {
- (*ctrlp)->ldctl_value.bv_len = 0;
- (*ctrlp)->ldctl_value.bv_val = NULL;
- } else {
- (*ctrlp)->ldctl_value = *bvp; /* struct copy */
- free(bvp); /* free container, not contents! */
- }
-
- return (LDAP_SUCCESS);
-}
diff --git a/usr/src/lib/libldap4/common/delete.c b/usr/src/lib/libldap4/common/delete.c
deleted file mode 100644
index 287abd8ac8..0000000000
--- a/usr/src/lib/libldap4/common/delete.c
+++ /dev/null
@@ -1,203 +0,0 @@
-/*
- * Portions Copyright 1998 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-/*
- * Copyright (c) 1990 Regents of the University of Michigan.
- * All rights reserved.
- *
- * delete.c
- */
-
-#ifndef lint
-static char copyright[] = "@(#) Copyright (c) 1990 Regents of the University of Michigan.\nAll rights reserved.\n";
-#endif
-
-#include <stdio.h>
-#include <string.h>
-
-#ifdef MACOS
-#include "macos.h"
-#endif /* MACOS */
-
-#if defined( DOS ) || defined( _WIN32 )
-#include "msdos.h"
-#endif /* DOS */
-
-#if !defined( MACOS ) && !defined( DOS )
-#include <sys/types.h>
-#include <sys/socket.h>
-#endif
-
-#include "lber.h"
-#include "ldap.h"
-#include "ldap-private.h"
-#include "ldap-int.h"
-
-BerElement * ldap_build_delete_req(LDAP *ld, char *dn, LDAPControl **serverctrls)
-{
- BerElement *ber;
- int rv;
-
- /* create a message to send */
- if ( (ber = alloc_ber_with_options( ld )) == NULLBER ) {
- ld->ld_errno = LDAP_NO_MEMORY;
- return(NULLBER );
- }
-
- if ( ber_printf( ber, "{its", ++ld->ld_msgid, LDAP_REQ_DELETE, dn ) == -1 ) {
- ld->ld_errno = LDAP_ENCODING_ERROR;
- ber_free( ber, 1 );
- return(NULLBER );
- }
-
- /* LDAPv3 */
- /* Code controls if any */
- if (serverctrls && serverctrls[0]) {
- if (ldap_controls_code(ber, serverctrls) != LDAP_SUCCESS){
- ld->ld_errno = LDAP_ENCODING_ERROR;
- ber_free( ber, 1 );
- return( NULLBER );
- }
- } else if (ld->ld_srvctrls && ld->ld_srvctrls[0]) {
- /* Otherwise, is there any global server ctrls ? */
- if (ldap_controls_code(ber, ld->ld_srvctrls) != LDAP_SUCCESS){
- ld->ld_errno = LDAP_ENCODING_ERROR;
- ber_free( ber, 1 );
- return( NULLBER );
- }
- }
-
- if ( ber_printf( ber, "}" ) == -1 ) {
- ld->ld_errno = LDAP_ENCODING_ERROR;
- ber_free( ber, 1 );
- return( NULLBER );
- }
-
- return (ber);
-}
-
-/*
- * ldap_delete - initiate an ldap (and X.500) delete operation. Parameters:
- *
- * ld LDAP descriptor
- * dn DN of the object to delete
- *
- * Example:
- * msgid = ldap_delete( ld, dn );
- */
-int
-ldap_delete( LDAP *ld, char *dn )
-{
- BerElement *ber;
- int rv;
-
- /*
- * A delete request looks like this:
- * DelRequet ::= DistinguishedName,
- */
-
- Debug( LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 129, "ldap_delete\n"), 0, 0, 0 );
-
-#ifdef _REENTRANT
- LOCK_LDAP(ld);
-#endif
-
- if (( ber = ldap_build_delete_req(ld, dn, NULL)) == NULLBER) {
-#ifdef _REENTRANT
- UNLOCK_LDAP(ld);
-#endif
- return (-1);
- }
-
- /* send the message */
- rv = send_initial_request( ld, LDAP_REQ_DELETE, dn, ber );
-#ifdef _REENTRANT
- UNLOCK_LDAP(ld);
-#endif
- return ( rv );
-}
-
-
-int
-ldap_delete_s( LDAP *ld, char *dn )
-{
- int msgid;
- LDAPMessage *res;
-
- if ( (msgid = ldap_delete( ld, dn )) == -1 )
- return( ld->ld_errno );
-
- if ( ldap_result( ld, msgid, 1, (struct timeval *) NULL, &res ) == -1 )
- return( ld->ld_errno );
-
- return( ldap_result2error( ld, res, 1 ) );
-}
-
-/* ldapv3 API extensions */
-
-int ldap_delete_ext(LDAP *ld, char *dn, LDAPControl **serverctrls, LDAPControl **clientctrls, int *msgidp)
-{
- BerElement *ber;
- int rv;
-
-#ifdef _REENTRANT
- LOCK_LDAP(ld);
-#endif
-
- Debug( LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 192, "ldap_modify\n"), 0, 0, 0 );
-
- if ((ber = ldap_build_delete_req(ld, dn, serverctrls)) == NULLBER){
- rv = ld->ld_errno;
- if (rv == LDAP_SUCCESS)
- rv = LDAP_OTHER;
-#ifdef _REENTRANT
- UNLOCK_LDAP(ld);
-#endif
- return (rv);
- }
-
- /* send the message */
- rv = send_initial_request( ld, LDAP_REQ_DELETE, dn, ber );
- if (rv == -1){
- rv = ld->ld_errno;
- if (rv == LDAP_SUCCESS){
- rv = LDAP_OTHER;
- }
-#ifdef _REENTRANT
- UNLOCK_LDAP(ld);
-#endif
- return (rv);
- }
- *msgidp = rv;
-#ifdef _REENTRANT
- UNLOCK_LDAP(ld);
-#endif
- return ( LDAP_SUCCESS );
-}
-
-int ldap_delete_ext_s(LDAP *ld, char *dn, LDAPControl **serverctrls, LDAPControl **clientctrls)
-{
- int msgid;
- int retcode = LDAP_SUCCESS;
- LDAPMessage *res;
-
- if ((retcode = ldap_delete_ext(ld, dn, serverctrls, clientctrls, &msgid)) != LDAP_SUCCESS)
- return (retcode);
- if (ldap_result(ld, msgid, 1, (struct timeval *)NULL, &res ) == -1)
- return (ld->ld_errno );
-
-#ifdef _REENTRANT
- LOCK_LDAP(ld);
-#endif
- retcode = ldap_parse_result( ld, res, &ld->ld_errno, &ld->ld_matched, &ld->ld_error,
- &ld->ld_referrals, &ld->ld_ret_ctrls, 1);
- if (retcode == LDAP_SUCCESS)
- retcode = ld->ld_errno;
-#ifdef _REENTRANT
- UNLOCK_LDAP(ld);
-#endif
- return (retcode);
-}
diff --git a/usr/src/lib/libldap4/common/disptmpl.c b/usr/src/lib/libldap4/common/disptmpl.c
deleted file mode 100644
index ea2413c990..0000000000
--- a/usr/src/lib/libldap4/common/disptmpl.c
+++ /dev/null
@@ -1,751 +0,0 @@
-/*
- * Portions Copyright 1998 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-/*
- * Copyright (c) 1993, 1994 Regents of the University of Michigan.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms are permitted
- * provided that this notice is preserved and that due credit is given
- * to the University of Michigan at Ann Arbor. The name of the University
- * may not be used to endorse or promote products derived from this
- * software without specific prior written permission. This software
- * is provided ``as is'' without express or implied warranty.
- *
- * disptmpl.c: display template library routines for LDAP clients
- * 7 March 1994 by Mark C Smith
- */
-
-#include <stdio.h>
-#include <ctype.h>
-#include <string.h>
-#include <stdlib.h>
-#ifdef MACOS
-#include "macos.h"
-#else /* MACOS */
-#ifdef DOS
-#include <malloc.h>
-#include "msdos.h"
-#else /* DOS */
-#include <sys/types.h>
-#include <sys/file.h>
-#ifndef VMS
-#include <unistd.h>
-#endif /* VMS */
-#endif /* DOS */
-#endif /* MACOS */
-
-#include "lber.h"
-#include "ldap.h"
-#include "ldap-private.h"
-#include "ldap-int.h"
-
-#ifndef NEEDPROTOS
-static void free_disptmpl();
-static int read_next_tmpl();
-int next_line_tokens();
-#else /* !NEEDPROTOS */
-static void free_disptmpl( struct ldap_disptmpl *tmpl );
-static int read_next_tmpl( char **bufp, ssize_t *blenp,
- struct ldap_disptmpl **tmplp, int dtversion );
-int next_line_tokens( char **bufp, ssize_t *blenp, char ***toksp );
-#endif /* !NEEDPROTOS */
-
-static char *tmploptions[] = {
- "addable", "modrdn",
- "altview",
- NULL
-};
-
-
-static unsigned int tmploptvals[] = {
- LDAP_DTMPL_OPT_ADDABLE, LDAP_DTMPL_OPT_ALLOWMODRDN,
- LDAP_DTMPL_OPT_ALTVIEW,
-};
-
-
-static char *itemtypes[] = {
- "cis", "mls", "dn",
- "bool", "jpeg", "jpegbtn",
- "fax", "faxbtn", "audiobtn",
- "time", "date", "url",
- "searchact", "linkact", "adddnact",
- "addact", "verifyact", "mail",
-#ifdef SUN
- "protected",
-#endif
- NULL
-};
-
-static unsigned int itemsynids[] = {
- LDAP_SYN_CASEIGNORESTR, LDAP_SYN_MULTILINESTR, LDAP_SYN_DN,
- LDAP_SYN_BOOLEAN, LDAP_SYN_JPEGIMAGE, LDAP_SYN_JPEGBUTTON,
- LDAP_SYN_FAXIMAGE, LDAP_SYN_FAXBUTTON, LDAP_SYN_AUDIOBUTTON,
- LDAP_SYN_TIME, LDAP_SYN_DATE, LDAP_SYN_LABELEDURL,
- LDAP_SYN_SEARCHACTION, LDAP_SYN_LINKACTION, LDAP_SYN_ADDDNACTION,
- LDAP_SYN_ADDDNACTION, LDAP_SYN_VERIFYDNACTION,LDAP_SYN_RFC822ADDR,
-#ifdef SUN
- LDAP_SYN_PROTECTED,
-#endif
-};
-
-
-static char *itemoptions[] = {
- "ro", "sort",
- "1val", "hide",
- "required", "hideiffalse",
- NULL
-};
-
-
-static unsigned int itemoptvals[] = {
- LDAP_DITEM_OPT_READONLY, LDAP_DITEM_OPT_SORTVALUES,
- LDAP_DITEM_OPT_SINGLEVALUED, LDAP_DITEM_OPT_HIDEIFEMPTY,
- LDAP_DITEM_OPT_VALUEREQUIRED, LDAP_DITEM_OPT_HIDEIFFALSE,
-};
-
-
-#define ADDEF_CONSTANT "constant"
-#define ADDEF_ADDERSDN "addersdn"
-
-#ifdef SUN
-/* LP@Sun : right_trim */
-static void right_trim(char *aStr)
-{
- char * theEnd = aStr + strlen(aStr);
- while ((theEnd > aStr) && isspace(*(theEnd - 1)))
- theEnd--;
- theEnd;
- *theEnd= '\0';
-}
-#endif
-
-int
-ldap_init_templates( char *file, struct ldap_disptmpl **tmpllistp )
-{
- FILE *fp;
- char *buf;
- ssize_t rlen, len;
- int rc, eof;
-
- *tmpllistp = NULLDISPTMPL;
-
- if (( fp = fopen( file, "r" )) == NULL ) {
- return( LDAP_TMPL_ERR_FILE );
- }
-
- if ( fseek( fp, 0L, SEEK_END ) != 0 ) { /* move to end to get len */
- fclose( fp );
- return( LDAP_TMPL_ERR_FILE );
- }
-
- len = ftell( fp );
-
- if ( fseek( fp, 0L, SEEK_SET ) != 0 ) { /* back to start of file */
- fclose( fp );
- return( LDAP_TMPL_ERR_FILE );
- }
-
- if (( buf = malloc( len )) == NULL ) {
- fclose( fp );
- return( LDAP_TMPL_ERR_MEM );
- }
-
- rlen = fread( buf, (size_t) 1, len, fp );
- eof = feof( fp );
- fclose( fp );
-
- if ( rlen != len && !eof ) { /* error: didn't get the whole file */
- free( buf );
- return( LDAP_TMPL_ERR_FILE );
- }
-
- rc = ldap_init_templates_buf( buf, rlen, tmpllistp );
- free( buf );
-
- return( rc );
-}
-
-
-int
-ldap_init_templates_buf( char *buf, ssize_t buflen,
- struct ldap_disptmpl **tmpllistp )
-{
- int rc, version;
- char **toks;
- struct ldap_disptmpl *prevtmpl, *tmpl;
-
- *tmpllistp = prevtmpl = NULLDISPTMPL;
-
- if ( next_line_tokens( &buf, &buflen, &toks ) != 2 ||
- strcasecmp( toks[ 0 ], "version" ) != 0 ) {
- free_strarray( toks );
- return( LDAP_TMPL_ERR_SYNTAX );
- }
- version = atoi( toks[ 1 ] );
- free_strarray( toks );
- if ( version != LDAP_TEMPLATE_VERSION ) {
- return( LDAP_TMPL_ERR_VERSION );
- }
-
- while ( buflen > 0 && ( rc = read_next_tmpl( &buf, &buflen, &tmpl,
- version )) == 0 && tmpl != NULLDISPTMPL ) {
- if ( prevtmpl == NULLDISPTMPL ) {
- *tmpllistp = tmpl;
- } else {
- prevtmpl->dt_next = tmpl;
- }
- prevtmpl = tmpl;
- }
-
- if ( rc != 0 ) {
- ldap_free_templates( *tmpllistp );
- }
-
- return( rc );
-}
-
-
-
-void
-ldap_free_templates( struct ldap_disptmpl *tmpllist )
-{
- struct ldap_disptmpl *tp, *nexttp;
-
- if ( tmpllist != NULL ) {
- for ( tp = tmpllist; tp != NULL; tp = nexttp ) {
- nexttp = tp->dt_next;
- free_disptmpl( tp );
- }
- }
-}
-
-
-static void
-free_disptmpl( struct ldap_disptmpl *tmpl )
-{
- if ( tmpl != NULL ) {
- if ( tmpl->dt_name != NULL ) {
- free( tmpl->dt_name );
- }
-
- if ( tmpl->dt_pluralname != NULL ) {
- free( tmpl->dt_pluralname );
- }
-
- if ( tmpl->dt_iconname != NULL ) {
- free( tmpl->dt_iconname );
- }
-
- if ( tmpl->dt_authattrname != NULL ) {
- free( tmpl->dt_authattrname );
- }
-
- if ( tmpl->dt_defrdnattrname != NULL ) {
- free( tmpl->dt_defrdnattrname );
- }
-
- if ( tmpl->dt_defaddlocation != NULL ) {
- free( tmpl->dt_defaddlocation );
- }
-
- if ( tmpl->dt_oclist != NULL ) {
- struct ldap_oclist *ocp, *nextocp;
-
- for ( ocp = tmpl->dt_oclist; ocp != NULL; ocp = nextocp ) {
- nextocp = ocp->oc_next;
- free_strarray( ocp->oc_objclasses );
- free( ocp );
- }
- }
-
- if ( tmpl->dt_adddeflist != NULL ) {
- struct ldap_adddeflist *adp, *nextadp;
-
- for ( adp = tmpl->dt_adddeflist; adp != NULL; adp = nextadp ) {
- nextadp = adp->ad_next;
- if( adp->ad_attrname != NULL ) {
- free( adp->ad_attrname );
- }
- if( adp->ad_value != NULL ) {
- free( adp->ad_value );
- }
- free( adp );
- }
- }
-
- if ( tmpl->dt_items != NULL ) {
- struct ldap_tmplitem *rowp, *nextrowp, *colp, *nextcolp;
-
- for ( rowp = tmpl->dt_items; rowp != NULL; rowp = nextrowp ) {
- nextrowp = rowp->ti_next_in_col;
- for ( colp = rowp; colp != NULL; colp = nextcolp ) {
- nextcolp = colp->ti_next_in_row;
- if ( colp->ti_attrname != NULL ) {
- free( colp->ti_attrname );
- }
- if ( colp->ti_label != NULL ) {
- free( colp->ti_label );
- }
- if ( colp->ti_args != NULL ) {
- free_strarray( colp->ti_args );
- }
- free( colp );
- }
- }
- }
-
- free( tmpl );
- }
-}
-
-
-struct ldap_disptmpl *
-ldap_first_disptmpl( struct ldap_disptmpl *tmpllist )
-{
- return( tmpllist );
-}
-
-
-struct ldap_disptmpl *
-ldap_next_disptmpl( struct ldap_disptmpl *tmpllist,
- struct ldap_disptmpl *tmpl )
-{
- return( tmpl == NULLDISPTMPL ? tmpl : tmpl->dt_next );
-}
-
-
-struct ldap_disptmpl *
-ldap_name2template( char *name, struct ldap_disptmpl *tmpllist )
-{
- struct ldap_disptmpl *dtp;
-
- for ( dtp = ldap_first_disptmpl( tmpllist ); dtp != NULLDISPTMPL;
- dtp = ldap_next_disptmpl( tmpllist, dtp )) {
- if ( strcasecmp( name, dtp->dt_name ) == 0 ) {
- return( dtp );
- }
- }
-
- return( NULLDISPTMPL );
-}
-
-
-struct ldap_disptmpl *
-ldap_oc2template( char **oclist, struct ldap_disptmpl *tmpllist )
-{
- struct ldap_disptmpl *dtp;
- struct ldap_oclist *oclp;
- int i, j, needcnt, matchcnt;
-
- if ( tmpllist == NULL || oclist == NULL || oclist[ 0 ] == NULL ) {
- return( NULLDISPTMPL );
- }
-
- for ( dtp = ldap_first_disptmpl( tmpllist ); dtp != NULLDISPTMPL;
- dtp = ldap_next_disptmpl( tmpllist, dtp )) {
- for ( oclp = dtp->dt_oclist; oclp != NULLOCLIST;
- oclp = oclp->oc_next ) {
- needcnt = matchcnt = 0;
- for ( i = 0; oclp->oc_objclasses[ i ] != NULL; ++i ) {
- for ( j = 0; oclist[ j ] != NULL; ++j ) {
-#ifdef SUN
- /* LP@Sun : remove ending space from objectclass */
- right_trim(oclist[j]);
-#endif
- if ( strcasecmp( oclist[ j ], oclp->oc_objclasses[ i ] )
- == 0 ) {
- ++matchcnt;
- }
- }
- ++needcnt;
- }
-
- if ( matchcnt == needcnt ) {
- return( dtp );
- }
- }
- }
-
- return( NULLDISPTMPL );
-}
-
-
-struct ldap_tmplitem *
-ldap_first_tmplrow( struct ldap_disptmpl *tmpl )
-{
- return( tmpl->dt_items );
-}
-
-
-struct ldap_tmplitem *
-ldap_next_tmplrow( struct ldap_disptmpl *tmpl, struct ldap_tmplitem *row )
-{
- return( row == NULLTMPLITEM ? row : row->ti_next_in_col );
-}
-
-
-struct ldap_tmplitem *
-ldap_first_tmplcol( struct ldap_disptmpl *tmpl, struct ldap_tmplitem *row )
-{
- return( row );
-}
-
-
-struct ldap_tmplitem *
-ldap_next_tmplcol( struct ldap_disptmpl *tmpl, struct ldap_tmplitem *row,
- struct ldap_tmplitem *col )
-{
- return( col == NULLTMPLITEM ? col : col->ti_next_in_row );
-}
-
-
-char **
-ldap_tmplattrs( struct ldap_disptmpl *tmpl, char **includeattrs,
- int exclude, unsigned int syntaxmask )
-{
-/*
- * this routine should filter out duplicate attributes...
- */
- struct ldap_tmplitem *tirowp, *ticolp;
- int i, attrcnt, memerr;
- char **attrs;
-
- attrcnt = 0;
- memerr = 0;
-
- if (( attrs = (char **)malloc( sizeof( char * ))) == NULL ) {
- return( NULL );
- }
-
- if ( includeattrs != NULL ) {
- for ( i = 0; !memerr && includeattrs[ i ] != NULL; ++i ) {
- if (( attrs = (char **)realloc( attrs, ( attrcnt + 2 ) *
- sizeof( char * ))) == NULL || ( attrs[ attrcnt++ ] =
- strdup( includeattrs[ i ] )) == NULL ) {
- memerr = 1;
- } else {
- attrs[ attrcnt ] = NULL;
- }
- }
- }
-
- for ( tirowp = ldap_first_tmplrow( tmpl );
- !memerr && tirowp != NULLTMPLITEM;
- tirowp = ldap_next_tmplrow( tmpl, tirowp )) {
- for ( ticolp = ldap_first_tmplcol( tmpl, tirowp );
- ticolp != NULLTMPLITEM;
- ticolp = ldap_next_tmplcol( tmpl, tirowp, ticolp )) {
-
- if ( syntaxmask != 0 ) {
- if (( exclude &&
- ( syntaxmask & ticolp->ti_syntaxid ) != 0 ) ||
- ( !exclude &&
- ( syntaxmask & ticolp->ti_syntaxid ) == 0 )) {
- continue;
- }
- }
-
- if ( ticolp->ti_attrname != NULL ) {
- if (( attrs = (char **)realloc( attrs, ( attrcnt + 2 ) *
- sizeof( char * ))) == NULL || ( attrs[ attrcnt++ ] =
- strdup( ticolp->ti_attrname )) == NULL ) {
- memerr = 1;
- } else {
- attrs[ attrcnt ] = NULL;
- }
- }
- }
- }
-
- if ( memerr || attrcnt == 0 ) {
- for ( i = 0; i < attrcnt; ++i ) {
- if ( attrs[ i ] != NULL ) {
- free( attrs[ i ] );
- }
- }
-
- free( (char *)attrs );
- return( NULL );
- }
-
- return( attrs );
-}
-
-
-static int
-read_next_tmpl( char **bufp, ssize_t *blenp, struct ldap_disptmpl **tmplp,
- int dtversion )
-{
- int i, j, tokcnt, samerow, adsource;
- char **toks, *itemopts;
- struct ldap_disptmpl *tmpl;
- struct ldap_oclist *ocp, *prevocp;
- struct ldap_adddeflist *adp, *prevadp;
- struct ldap_tmplitem *rowp, *ip, *previp;
-
- *tmplp = NULL;
-
- /*
- * template name comes first
- */
- if (( tokcnt = next_line_tokens( bufp, blenp, &toks )) != 1 ) {
- free_strarray( toks );
- return( tokcnt == 0 ? 0 : LDAP_TMPL_ERR_SYNTAX );
- }
-
- if (( tmpl = (struct ldap_disptmpl *)calloc( (size_t) 1,
- sizeof( struct ldap_disptmpl ))) == NULL ) {
- free_strarray( toks );
- return( LDAP_TMPL_ERR_MEM );
- }
- tmpl->dt_name = toks[ 0 ];
- free( (char *)toks );
-
- /*
- * template plural name comes next
- */
- if (( tokcnt = next_line_tokens( bufp, blenp, &toks )) != 1 ) {
- free_strarray( toks );
- free_disptmpl( tmpl );
- return( LDAP_TMPL_ERR_SYNTAX );
- }
- tmpl->dt_pluralname = toks[ 0 ];
- free( (char *)toks );
-
- /*
- * template icon name is next
- */
- if (( tokcnt = next_line_tokens( bufp, blenp, &toks )) != 1 ) {
- free_strarray( toks );
- free_disptmpl( tmpl );
- return( LDAP_TMPL_ERR_SYNTAX );
- }
- tmpl->dt_iconname = toks[ 0 ];
- free( (char *)toks );
-
- /*
- * template options come next
- */
- if (( tokcnt = next_line_tokens( bufp, blenp, &toks )) < 1 ) {
- free_strarray( toks );
- free_disptmpl( tmpl );
- return( LDAP_TMPL_ERR_SYNTAX );
- }
- for ( i = 0; toks[ i ] != NULL; ++i ) {
- for ( j = 0; tmploptions[ j ] != NULL; ++j ) {
- if ( strcasecmp( toks[ i ], tmploptions[ j ] ) == 0 ) {
- tmpl->dt_options |= tmploptvals[ j ];
- }
- }
- }
- free_strarray( toks );
-
- /*
- * object class list is next
- */
- while (( tokcnt = next_line_tokens( bufp, blenp, &toks )) > 0 ) {
- if (( ocp = (struct ldap_oclist *)calloc( (size_t) 1,
- sizeof( struct ldap_oclist ))) == NULL ) {
- free_strarray( toks );
- free_disptmpl( tmpl );
- return( LDAP_TMPL_ERR_MEM );
- }
- ocp->oc_objclasses = toks;
- if ( tmpl->dt_oclist == NULL ) {
- tmpl->dt_oclist = ocp;
- } else {
- prevocp->oc_next = ocp;
- }
- prevocp = ocp;
- }
- if ( tokcnt < 0 ) {
- free_disptmpl( tmpl );
- return( LDAP_TMPL_ERR_SYNTAX );
- }
-
- /*
- * read name of attribute to authenticate as
- */
- if (( tokcnt = next_line_tokens( bufp, blenp, &toks )) != 1 ) {
- free_strarray( toks );
- free_disptmpl( tmpl );
- return( LDAP_TMPL_ERR_SYNTAX );
- }
- if ( toks[ 0 ][ 0 ] != '\0' ) {
- tmpl->dt_authattrname = toks[ 0 ];
- } else {
- free( toks[ 0 ] );
- }
- free( (char *)toks );
-
- /*
- * read default attribute to use for RDN
- */
- if (( tokcnt = next_line_tokens( bufp, blenp, &toks )) != 1 ) {
- free_strarray( toks );
- free_disptmpl( tmpl );
- return( LDAP_TMPL_ERR_SYNTAX );
- }
- tmpl->dt_defrdnattrname = toks[ 0 ];
- free( (char *)toks );
-
- /*
- * read default location for new entries
- */
- if (( tokcnt = next_line_tokens( bufp, blenp, &toks )) != 1 ) {
- free_strarray( toks );
- free_disptmpl( tmpl );
- return( LDAP_TMPL_ERR_SYNTAX );
- }
- if ( toks[ 0 ][ 0 ] != '\0' ) {
- tmpl->dt_defaddlocation = toks[ 0 ];
- } else {
- free( toks[ 0 ] );
- }
- free( (char *)toks );
-
- /*
- * read list of rules used to define default values for new entries
- */
- while (( tokcnt = next_line_tokens( bufp, blenp, &toks )) > 0 ) {
- if ( strcasecmp( ADDEF_CONSTANT, toks[ 0 ] ) == 0 ) {
- adsource = LDAP_ADSRC_CONSTANTVALUE;
- } else if ( strcasecmp( ADDEF_ADDERSDN, toks[ 0 ] ) == 0 ) {
- adsource = LDAP_ADSRC_ADDERSDN;
- } else {
- adsource = 0;
- }
- if ( adsource == 0 || tokcnt < 2 ||
- ( adsource == LDAP_ADSRC_CONSTANTVALUE && tokcnt != 3 ) ||
- ( adsource == LDAP_ADSRC_ADDERSDN && tokcnt != 2 )) {
- free_strarray( toks );
- free_disptmpl( tmpl );
- return( LDAP_TMPL_ERR_SYNTAX );
- }
-
- if (( adp = (struct ldap_adddeflist *)calloc( (size_t) 1,
- sizeof( struct ldap_adddeflist ))) == NULL ) {
- free_strarray( toks );
- free_disptmpl( tmpl );
- return( LDAP_TMPL_ERR_MEM );
- }
- adp->ad_source = adsource;
- adp->ad_attrname = toks[ 1 ];
- if ( adsource == LDAP_ADSRC_CONSTANTVALUE ) {
- adp->ad_value = toks[ 2 ];
- }
- free( toks[ 0 ] );
- free( (char *)toks );
-
- if ( tmpl->dt_adddeflist == NULL ) {
- tmpl->dt_adddeflist = adp;
- } else {
- prevadp->ad_next = adp;
- }
- prevadp = adp;
- }
-
- /*
- * item list is next
- */
- samerow = 0;
- while (( tokcnt = next_line_tokens( bufp, blenp, &toks )) > 0 ) {
- if ( strcasecmp( toks[ 0 ], "item" ) == 0 ) {
- if ( tokcnt < 4 ) {
- free_strarray( toks );
- free_disptmpl( tmpl );
- return( LDAP_TMPL_ERR_SYNTAX );
- }
-
- if (( ip = (struct ldap_tmplitem *)calloc( (size_t) 1,
- sizeof( struct ldap_tmplitem ))) == NULL ) {
- free_strarray( toks );
- free_disptmpl( tmpl );
- return( LDAP_TMPL_ERR_MEM );
- }
-
- /*
- * find syntaxid from config file string
- */
- while (( itemopts = strrchr( toks[ 1 ], ',' )) != NULL ) {
- *itemopts++ = '\0';
- for ( i = 0; itemoptions[ i ] != NULL; ++i ) {
- if ( strcasecmp( itemopts, itemoptions[ i ] ) == 0 ) {
- break;
- }
- }
- if ( itemoptions[ i ] == NULL ) {
- free_strarray( toks );
- free_disptmpl( tmpl );
- return( LDAP_TMPL_ERR_SYNTAX );
- }
- ip->ti_options |= itemoptvals[ i ];
- }
-
- for ( i = 0; itemtypes[ i ] != NULL; ++i ) {
- if ( strcasecmp( toks[ 1 ], itemtypes[ i ] ) == 0 ) {
- break;
- }
- }
- if ( itemtypes[ i ] == NULL ) {
- free_strarray( toks );
- free_disptmpl( tmpl );
- return( LDAP_TMPL_ERR_SYNTAX );
- }
-
- free( toks[ 0 ] );
- free( toks[ 1 ] );
- ip->ti_syntaxid = itemsynids[ i ];
- ip->ti_label = toks[ 2 ];
- if ( toks[ 3 ][ 0 ] == '\0' ) {
- ip->ti_attrname = NULL;
- free( toks[ 3 ] );
- } else {
- ip->ti_attrname = toks[ 3 ];
- }
- if ( toks[ 4 ] != NULL ) { /* extra args. */
- for ( i = 0; toks[ i + 4 ] != NULL; ++i ) {
- ;
- }
- if (( ip->ti_args = (char **) calloc( (size_t) (i + 1), sizeof( char * )))
- == NULL ) {
- free_disptmpl( tmpl );
- return( LDAP_TMPL_ERR_MEM );
- }
- for ( i = 0; toks[ i + 4 ] != NULL; ++i ) {
- ip->ti_args[ i ] = toks[ i + 4 ];
- }
- }
- free( (char *)toks );
-
- if ( tmpl->dt_items == NULL ) {
- tmpl->dt_items = rowp = ip;
- } else if ( samerow ) {
- previp->ti_next_in_row = ip;
- } else {
- rowp->ti_next_in_col = ip;
- rowp = ip;
- }
- previp = ip;
- samerow = 0;
- } else if ( strcasecmp( toks[ 0 ], "samerow" ) == 0 ) {
- free_strarray( toks );
- samerow = 1;
- } else {
- free_strarray( toks );
- free_disptmpl( tmpl );
- return( LDAP_TMPL_ERR_SYNTAX );
- }
- }
- if ( tokcnt < 0 ) {
- free_disptmpl( tmpl );
- return( LDAP_TMPL_ERR_SYNTAX );
- }
-
- *tmplp = tmpl;
- return( 0 );
-}
diff --git a/usr/src/lib/libldap4/common/dsparse.c b/usr/src/lib/libldap4/common/dsparse.c
deleted file mode 100644
index c14af4e3ea..0000000000
--- a/usr/src/lib/libldap4/common/dsparse.c
+++ /dev/null
@@ -1,214 +0,0 @@
-/*
- * Portions Copyright 1998 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*
- * Copyright (c) 1993, 1994 Regents of the University of Michigan.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms are permitted
- * provided that this notice is preserved and that due credit is given
- * to the University of Michigan at Ann Arbor. The name of the University
- * may not be used to endorse or promote products derived from this
- * software without specific prior written permission. This software
- * is provided ``as is'' without express or implied warranty.
- *
- * dsparse.c: parsing routines used by display template and search
- * preference file library routines for LDAP clients.
- *
- * 7 March 1994 by Mark C Smith
- */
-
-#include <stdio.h>
-#include <ctype.h>
-#include <string.h>
-#ifdef MACOS
-#include <stdlib.h>
-#include "macos.h"
-#else /* MACOS */
-#ifdef DOS
-#include <malloc.h>
-#include "msdos.h"
-#else /* DOS */
-#include <sys/types.h>
-#include <sys/file.h>
-#include <stdlib.h>
-#endif /* DOS */
-#endif /* MACOS */
-
-#include "lber.h"
-#include "ldap.h"
-#include "ldap-private.h"
-#include "ldap-int.h"
-
-#ifndef NEEDPROTOS
-int next_line_tokens();
-static ssize_t next_line();
-static char *next_token();
-#else /* !NEEDPROTOS */
-int next_line_tokens( char **bufp, ssize_t *blenp, char ***toksp );
-static ssize_t next_line( char **bufp, ssize_t *blenp, char **linep );
-static char *next_token( char ** sp );
-#endif /* !NEEDPROTOS */
-
-
-
-int
-next_line_tokens( char **bufp, ssize_t *blenp, char ***toksp )
-{
- char *p, *line, *token, **toks;
- ssize_t rc;
- int tokcnt;
-
- *toksp = NULL;
-
- if (( rc = next_line( bufp, blenp, &line )) <= 0 ) {
- return( (int)rc );
- }
-
- if (( toks = (char **)calloc( (size_t) 1, sizeof( char * ))) == NULL ) {
- free( line );
- return( -1 );
- }
- tokcnt = 0;
-
- p = line;
- while (( token = next_token( &p )) != NULL ) {
- if (( toks = (char **)realloc( toks, ( tokcnt + 2 ) *
- sizeof( char * ))) == NULL ) {
- free( (char *)toks );
- free( line );
- return( -1 );
- }
- toks[ tokcnt ] = token;
- toks[ ++tokcnt ] = NULL;
- }
-
- if ( tokcnt == 1 && strcasecmp( toks[ 0 ], "END" ) == 0 ) {
- tokcnt = 0;
- free_strarray( toks );
- toks = NULL;
- }
-
- free( line );
-
- if ( tokcnt == 0 ) {
- if ( toks != NULL ) {
- free( (char *)toks );
- }
- } else {
- *toksp = toks;
- }
-
- return( tokcnt );
-}
-
-
-static ssize_t
-next_line( char **bufp, ssize_t *blenp, char **linep )
-{
- char *linestart, *line, *p;
- ssize_t plen;
-
- linestart = *bufp;
- p = *bufp;
- plen = *blenp;
-
- do {
- for ( linestart = p; plen > 0; ++p, --plen ) {
- if ( *p == '\r' ) {
- if ( plen > 1 && *(p+1) == '\n' ) {
- ++p;
- --plen;
- }
- break;
- }
-
- if ( *p == '\n' ) {
- if ( plen > 1 && *(p+1) == '\r' ) {
- ++p;
- --plen;
- }
- break;
- }
- }
- ++p;
- --plen;
- } while ( plen > 0 && ( *linestart == '#' || linestart + 1 == p ));
-
-
- *bufp = p;
- *blenp = plen;
-
-
- if ( plen <= 0 ) {
- *linep = NULL;
- return( 0 ); /* end of file */
- }
-
- if (( line = malloc( p - linestart )) == NULL ) {
- *linep = NULL;
- return( -1 ); /* fatal error */
- }
-
- (void) memcpy( line, linestart, p - linestart );
- line[ p - linestart - 1 ] = '\0';
- *linep = line;
- return( strlen( line ));
-}
-
-
-static char *
-next_token( char **sp )
-{
- int in_quote = 0;
- char *p, *tokstart, *t;
-
- if ( **sp == '\0' ) {
- return( NULL );
- }
-
- p = *sp;
-
- while ( isspace( *p )) { /* skip leading white space */
- ++p;
- }
-
- if ( *p == '\0' ) {
- return( NULL );
- }
-
- if ( *p == '\"' ) {
- in_quote = 1;
- ++p;
- }
- t = tokstart = p;
-
- for ( ;; ) {
- if ( *p == '\0' || ( isspace( *p ) && !in_quote )) {
- if ( *p != '\0' ) {
- ++p;
- }
- *t++ = '\0'; /* end of token */
- break;
- }
-
- if ( *p == '\"' ) {
- in_quote = !in_quote;
- ++p;
- } else {
- *t++ = *p++;
- }
- }
-
- *sp = p;
-
- if ( t == tokstart ) {
- return( NULL );
- }
-
- return( strdup( tokstart ));
-}
diff --git a/usr/src/lib/libldap4/common/error.c b/usr/src/lib/libldap4/common/error.c
deleted file mode 100644
index bbf01622f0..0000000000
--- a/usr/src/lib/libldap4/common/error.c
+++ /dev/null
@@ -1,345 +0,0 @@
-/*
- * Portions Copyright 1999 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h> /* free() for Solaris */
-#ifdef MACOS
-#include <stdlib.h>
-#else /* MACOS */
-#if defined( DOS ) || defined( _WIN32 )
-#include <malloc.h>
-#include "msdos.h"
-#else /* DOS */
-#include <sys/types.h>
-#include <sys/socket.h>
-#endif /* DOS */
-#endif /* MACOS */
-#include "lber.h"
-#include "ldap.h"
-#include "ldap-private.h"
-#include "ldap-int.h"
-
-struct ldaperror {
- int e_code;
- char *e_reason;
-};
-
-static struct ldaperror ldap_errlist[] = {
-#ifdef SUN
- LDAP_SUCCESS, 0,
- LDAP_OPERATIONS_ERROR, 0,
- LDAP_PROTOCOL_ERROR, 0,
- LDAP_TIMELIMIT_EXCEEDED, 0,
- LDAP_SIZELIMIT_EXCEEDED, 0,
- LDAP_COMPARE_FALSE, 0,
- LDAP_COMPARE_TRUE, 0,
- LDAP_AUTH_METHOD_NOT_SUPPORTED, 0,
- LDAP_STRONG_AUTH_REQUIRED, 0,
- LDAP_PARTIAL_RESULTS, 0,
-/* new with ldapv3 */
- LDAP_REFERRAL, 0,
- LDAP_ADMINLIMIT_EXCEEDED, 0,
- LDAP_UNAVAILABLE_CRITICAL_EXTENSION, 0,
- LDAP_CONFIDENTIALITY_REQUIRED, 0,
-/* end of new */
- LDAP_NO_SUCH_ATTRIBUTE, 0,
- LDAP_UNDEFINED_TYPE, 0,
- LDAP_INAPPROPRIATE_MATCHING, 0,
- LDAP_CONSTRAINT_VIOLATION, 0,
- LDAP_TYPE_OR_VALUE_EXISTS, 0,
- LDAP_INVALID_SYNTAX, 0,
- LDAP_NO_SUCH_OBJECT, 0,
- LDAP_ALIAS_PROBLEM, 0,
- LDAP_INVALID_DN_SYNTAX, 0,
- LDAP_IS_LEAF, 0,
- LDAP_ALIAS_DEREF_PROBLEM, 0,
- LDAP_INAPPROPRIATE_AUTH, 0,
- LDAP_INVALID_CREDENTIALS, 0,
- LDAP_INSUFFICIENT_ACCESS, 0,
- LDAP_BUSY, 0,
- LDAP_UNAVAILABLE, 0,
- LDAP_UNWILLING_TO_PERFORM, 0,
- LDAP_LOOP_DETECT, 0,
- LDAP_NAMING_VIOLATION, 0,
- LDAP_OBJECT_CLASS_VIOLATION, 0,
- LDAP_NOT_ALLOWED_ON_NONLEAF, 0,
- LDAP_NOT_ALLOWED_ON_RDN, 0,
- LDAP_ALREADY_EXISTS, 0,
- LDAP_NO_OBJECT_CLASS_MODS, 0,
- LDAP_RESULTS_TOO_LARGE, 0,
-/* new with ldapv3 */
- LDAP_AFFECTS_MULTIPLE_DSAS, 0,
-/* end of new */
- LDAP_OTHER, 0,
- LDAP_SERVER_DOWN, 0,
- LDAP_LOCAL_ERROR, 0,
- LDAP_ENCODING_ERROR, 0,
- LDAP_DECODING_ERROR, 0,
- LDAP_TIMEOUT, 0,
- LDAP_AUTH_UNKNOWN, 0,
- LDAP_FILTER_ERROR, 0,
- LDAP_USER_CANCELLED, 0,
- LDAP_PARAM_ERROR, 0,
- LDAP_NO_MEMORY, 0,
-/* new with ldapv3 */
- LDAP_CONNECT_ERROR, 0,
- LDAP_NOT_SUPPORTED, 0,
- LDAP_CONTROL_NOT_FOUND, 0,
- LDAP_NO_RESULTS_RETURNED, 0,
- LDAP_MORE_RESULTS_TO_RETURN, 0,
- LDAP_CLIENT_LOOP, 0,
- LDAP_REFERRAL_LIMIT_EXCEEDED, 0,
-/* end of new */
-#else
- LDAP_SUCCESS, "Success",
- LDAP_OPERATIONS_ERROR, "Operations error",
- LDAP_PROTOCOL_ERROR, "Protocol error",
- LDAP_TIMELIMIT_EXCEEDED, "Timelimit exceeded",
- LDAP_SIZELIMIT_EXCEEDED, "Sizelimit exceeded",
- LDAP_COMPARE_FALSE, "Compare false",
- LDAP_COMPARE_TRUE, "Compare true",
- LDAP_AUTH_METHOD_NOT_SUPPORTED, "Authentication method not supported",
- LDAP_STRONG_AUTH_REQUIRED, "Strong authentication required",
- LDAP_PARTIAL_RESULTS, "Partial results and referral received",
-/* new with ldapv3 */
- LDAP_REFERRAL, "Referral received",
- LDAP_ADMINLIMIT_EXCEEDED, "Admin. limit exceeded",
- LDAP_UNAVAILABLE_CRITICAL_EXTENSION, "Unavailable critical extension",
- LDAP_CONFIDENTIALITY_REQUIRED, "Confidentiality required",
-/* end of new */
- LDAP_NO_SUCH_ATTRIBUTE, "No such attribute",
- LDAP_UNDEFINED_TYPE, "Undefined attribute type",
- LDAP_INAPPROPRIATE_MATCHING, "Inappropriate matching",
- LDAP_CONSTRAINT_VIOLATION, "Constraint violation",
- LDAP_TYPE_OR_VALUE_EXISTS, "Type or value exists",
- LDAP_INVALID_SYNTAX, "Invalid syntax",
- LDAP_NO_SUCH_OBJECT, "No such object",
- LDAP_ALIAS_PROBLEM, "Alias problem",
- LDAP_INVALID_DN_SYNTAX, "Invalid DN syntax",
- LDAP_IS_LEAF, "Object is a leaf",
- LDAP_ALIAS_DEREF_PROBLEM, "Alias dereferencing problem",
- LDAP_INAPPROPRIATE_AUTH, "Inappropriate authentication",
- LDAP_INVALID_CREDENTIALS, "Invalid credentials",
- LDAP_INSUFFICIENT_ACCESS, "Insufficient access",
- LDAP_BUSY, "DSA is busy",
- LDAP_UNAVAILABLE, "DSA is unavailable",
- LDAP_UNWILLING_TO_PERFORM, "DSA is unwilling to perform",
- LDAP_LOOP_DETECT, "Loop detected",
- LDAP_NAMING_VIOLATION, "Naming violation",
- LDAP_OBJECT_CLASS_VIOLATION, "Object class violation",
- LDAP_NOT_ALLOWED_ON_NONLEAF, "Operation not allowed on nonleaf",
- LDAP_NOT_ALLOWED_ON_RDN, "Operation not allowed on RDN",
- LDAP_ALREADY_EXISTS, "Already exists",
- LDAP_NO_OBJECT_CLASS_MODS, "Cannot modify object class",
- LDAP_RESULTS_TOO_LARGE, "Results too large",
-/* new with ldapv3 */
- LDAP_AFFECTS_MULTIPLE_DSAS, "Affects multiple DSAs",
-/* end of new */
- LDAP_OTHER, "Unknown error",
- LDAP_SERVER_DOWN, "Can't contact LDAP server",
- LDAP_LOCAL_ERROR, "Local error",
- LDAP_ENCODING_ERROR, "Encoding error",
- LDAP_DECODING_ERROR, "Decoding error",
- LDAP_TIMEOUT, "Timed out",
- LDAP_AUTH_UNKNOWN, "Unknown authentication method",
- LDAP_FILTER_ERROR, "Bad search filter",
- LDAP_USER_CANCELLED, "User cancelled operation",
- LDAP_PARAM_ERROR, "Bad parameter to an ldap routine",
- LDAP_NO_MEMORY, "Out of memory",
-/* new with ldapv3 */
- LDAP_CONNECT_ERROR, "Connection error",
- LDAP_NOT_SUPPORTED, "Not supported",
- LDAP_CONTROL_NOT_FOUND, "Control not found",
- LDAP_NO_RESULTS_RETURNED, "No results have been returned",
- LDAP_MORE_RESULTS_TO_RETURN, "More results to return",
- LDAP_CLIENT_LOOP, "Loop detected in referrals",
- LDAP_REFERRAL_LIMIT_EXCEEDED, "Too many referrals followed",
-/* end of new */
-#endif
- -1, 0
-};
-
-#ifdef SUN
-#pragma init (fill_ldap_errlist)
-
-static void fill_ldap_errlist()
-{
- int i=0;
- Debug(LDAP_DEBUG_TRACE, "fill_ldap_errlist\n", 0, 0, 0 );
- ldap_errlist[i++].e_reason = catgets(slapdcat, 1, 130, "Success");
- ldap_errlist[i++].e_reason = catgets(slapdcat, 1, 131, "Operations error");
- ldap_errlist[i++].e_reason = catgets(slapdcat, 1, 132, "Protocol error");
- ldap_errlist[i++].e_reason = catgets(slapdcat, 1, 133, "Timelimit exceeded");
- ldap_errlist[i++].e_reason = catgets(slapdcat, 1, 134, "Sizelimit exceeded");
- ldap_errlist[i++].e_reason = catgets(slapdcat, 1, 135, "Compare false");
- ldap_errlist[i++].e_reason = catgets(slapdcat, 1, 136, "Compare true");
- ldap_errlist[i++].e_reason = catgets(slapdcat, 1, 137, "Strong authentication not supported");
- ldap_errlist[i++].e_reason = catgets(slapdcat, 1, 138, "Strong authentication required");
- ldap_errlist[i++].e_reason = catgets(slapdcat, 1, 139, "Partial results and referral received");
-/* new with ldapv3 */
- ldap_errlist[i++].e_reason = catgets(slapdcat, 1, 1262, "Referral received");
- ldap_errlist[i++].e_reason = catgets(slapdcat, 1, 1263, "Admin. limit exceeded");
- ldap_errlist[i++].e_reason = catgets(slapdcat, 1, 1264, "Unavailable critical extension");
- ldap_errlist[i++].e_reason = catgets(slapdcat, 1, 1265, "Confidentiality required");
-/* end of new */
- ldap_errlist[i++].e_reason = catgets(slapdcat, 1, 140, "No such attribute");
- ldap_errlist[i++].e_reason = catgets(slapdcat, 1, 141, "Undefined attribute type");
- ldap_errlist[i++].e_reason = catgets(slapdcat, 1, 142, "Inappropriate matching");
- ldap_errlist[i++].e_reason = catgets(slapdcat, 1, 143, "Constraint violation");
- ldap_errlist[i++].e_reason = catgets(slapdcat, 1, 144, "Type or value exists");
- ldap_errlist[i++].e_reason = catgets(slapdcat, 1, 145, "Invalid syntax");
- ldap_errlist[i++].e_reason = catgets(slapdcat, 1, 146, "No such object");
- ldap_errlist[i++].e_reason = catgets(slapdcat, 1, 147, "Alias problem");
- ldap_errlist[i++].e_reason = catgets(slapdcat, 1, 148, "Invalid DN syntax");
- ldap_errlist[i++].e_reason = catgets(slapdcat, 1, 149, "Object is a leaf");
- ldap_errlist[i++].e_reason = catgets(slapdcat, 1, 150, "Alias dereferencing problem");
- ldap_errlist[i++].e_reason = catgets(slapdcat, 1, 151, "Inappropriate authentication");
- ldap_errlist[i++].e_reason = catgets(slapdcat, 1, 152, "Invalid credentials");
- ldap_errlist[i++].e_reason = catgets(slapdcat, 1, 153, "Insufficient access");
- ldap_errlist[i++].e_reason = catgets(slapdcat, 1, 154, "DSA is busy");
- ldap_errlist[i++].e_reason = catgets(slapdcat, 1, 155, "DSA is unavailable");
- ldap_errlist[i++].e_reason = catgets(slapdcat, 1, 156, "DSA is unwilling to perform");
- ldap_errlist[i++].e_reason = catgets(slapdcat, 1, 157, "Loop detected");
- ldap_errlist[i++].e_reason = catgets(slapdcat, 1, 158, "Naming violation");
- ldap_errlist[i++].e_reason = catgets(slapdcat, 1, 159, "Object class violation");
- ldap_errlist[i++].e_reason = catgets(slapdcat, 1, 160, "Operation not allowed on nonleaf");
- ldap_errlist[i++].e_reason = catgets(slapdcat, 1, 161, "Operation not allowed on RDN");
- ldap_errlist[i++].e_reason = catgets(slapdcat, 1, 162, "Already exists");
- ldap_errlist[i++].e_reason = catgets(slapdcat, 1, 163, "Cannot modify object class");
- ldap_errlist[i++].e_reason = catgets(slapdcat, 1, 164, "Results too large");
-/* new with ldapv3 */
- ldap_errlist[i++].e_reason = catgets(slapdcat, 1, 1266, "Affects multiple DSAs");
-/* end of new */
- ldap_errlist[i++].e_reason = catgets(slapdcat, 1, 165, "Unknown error");
- ldap_errlist[i++].e_reason = catgets(slapdcat, 1, 166, "Can't contact LDAP server");
- ldap_errlist[i++].e_reason = catgets(slapdcat, 1, 167, "Local error");
- ldap_errlist[i++].e_reason = catgets(slapdcat, 1, 168, "Encoding error");
- ldap_errlist[i++].e_reason = catgets(slapdcat, 1, 169, "Decoding error");
- ldap_errlist[i++].e_reason = catgets(slapdcat, 1, 170, "Timed out");
- ldap_errlist[i++].e_reason = catgets(slapdcat, 1, 171, "Unknown authentication method");
- ldap_errlist[i++].e_reason = catgets(slapdcat, 1, 172, "Bad search filter");
- ldap_errlist[i++].e_reason = catgets(slapdcat, 1, 173, "User cancelled operation");
- ldap_errlist[i++].e_reason = catgets(slapdcat, 1, 174, "Bad parameter to an ldap routine");
- ldap_errlist[i++].e_reason = catgets(slapdcat, 1, 175, "Out of memory");
-
- ldap_errlist[i++].e_reason = catgets(slapdcat, 1, 1267, "Connection error");
- ldap_errlist[i++].e_reason = catgets(slapdcat, 1, 1268, "Not supported");
- ldap_errlist[i++].e_reason = catgets(slapdcat, 1, 1269, "Control not found");
- ldap_errlist[i++].e_reason = catgets(slapdcat, 1, 1270, "No results have been returned");
- ldap_errlist[i++].e_reason = catgets(slapdcat, 1, 1271, "More results to return");
- ldap_errlist[i++].e_reason = catgets(slapdcat, 1, 1272, "Loop detected in referrals");
- ldap_errlist[i++].e_reason = catgets(slapdcat, 1, 1273, "Too many referrals followed");
-}
-#endif
-
-char *
-ldap_err2string( int err )
-{
- int i;
-
- Debug( LDAP_DEBUG_TRACE, "ldap_err2string\n", 0, 0, 0 );
-
- for ( i = 0; ldap_errlist[i].e_code != -1; i++ ) {
- if ( err == ldap_errlist[i].e_code )
- return( ldap_errlist[i].e_reason );
- }
-
- return( catgets(slapdcat, 1 , 165, "Unknown error") );
-}
-
-#ifndef NO_USERINTERFACE
-void
-ldap_perror( LDAP *ld, char *s )
-{
- int i;
-
- Debug( LDAP_DEBUG_TRACE, "ldap_perror\n", 0, 0, 0 );
-
- if ( ld == NULL ) {
- perror( s );
- return;
- }
-#ifdef SUN
- /* for I18N */
- if ( ldap_errlist[0].e_reason == NULL ) {
- fill_ldap_errlist();
- } /* end if */
-#endif
-
- for ( i = 0; ldap_errlist[i].e_code != -1; i++ ) {
- if ( ld->ld_errno == ldap_errlist[i].e_code ) {
- (void) fprintf( stderr, "%s: %s\n", s,
- ldap_errlist[i].e_reason );
- if ( ld->ld_matched != NULL && *ld->ld_matched != '\0' )
- (void) fprintf( stderr, catgets(slapdcat, 1, 176, "%1$s: matched: %2$s\n"), s,
- ld->ld_matched );
- if ( ld->ld_error != NULL && *ld->ld_error != '\0' )
- (void) fprintf( stderr, catgets(slapdcat, 1, 177, "%1$s: additional info: %2$s\n"),
- s, ld->ld_error );
- (void) fflush( stderr );
- return;
- }
- }
-
- (void) fprintf( stderr, catgets(slapdcat, 1, 178, "%1$s: Not an LDAP errno %2$d\n"), s, ld->ld_errno );
- (void) fflush( stderr );
-}
-
-#else
-
-void
-ldap_perror( LDAP *ld, char *s )
-{
-}
-
-#endif /* NO_USERINTERFACE */
-
-
-int
-ldap_result2error( LDAP *ld, LDAPMessage *r, int freeit )
-{
- LDAPMessage *lm;
- BerElement ber;
- int along;
- int rc;
-
- Debug( LDAP_DEBUG_TRACE, "ldap_result2error\n", 0, 0, 0 );
-
- if ( r == NULLMSG )
- return( LDAP_PARAM_ERROR );
-
- for ( lm = r; lm->lm_chain != NULL; lm = lm->lm_chain )
- ; /* NULL */
-
- if ( ld->ld_error ) {
- free( ld->ld_error );
- ld->ld_error = NULL;
- }
- if ( ld->ld_matched ) {
- free( ld->ld_matched );
- ld->ld_matched = NULL;
- }
-
- ber = *(lm->lm_ber);
- if ( ld->ld_version == LDAP_VERSION2 ) {
- rc = ber_scanf( &ber, "{iaa}", &along, &ld->ld_matched,
- &ld->ld_error );
- } else {
- rc = ber_scanf( &ber, "{ia}", &along, &ld->ld_error );
- }
- if ( rc == LBER_ERROR ) {
- ld->ld_errno = LDAP_DECODING_ERROR;
- } else {
- ld->ld_errno = along;
- }
-
- if ( freeit )
- ldap_msgfree( r );
-
- return( ld->ld_errno );
-}
diff --git a/usr/src/lib/libldap4/common/extensions.c b/usr/src/lib/libldap4/common/extensions.c
deleted file mode 100644
index 247ad2baa5..0000000000
--- a/usr/src/lib/libldap4/common/extensions.c
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- *
- * Copyright 1999 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- *
- *
- * Comments:
- *
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#include <stdio.h>
-#include <string.h>
-
-#ifdef MACOS
-#include "macos.h"
-#endif /* MACOS */
-
-#if !defined( MACOS ) && !defined( DOS )
-#include <sys/types.h>
-#include <sys/socket.h>
-#endif
-
-#include "lber.h"
-#include "ldap.h"
-#include "ldap-private.h"
-#include "ldap-int.h"
-
-int ldap_create_page_control(LDAP *ld, unsigned int pagesize, struct berval *cookie, char isCritical, LDAPControl **output)
-{
- BerElement *ber;
- int rc;
-
- if (NULL == ld || NULL == output)
- return (LDAP_PARAM_ERROR);
-
- if ((ber = ber_alloc_t(LBER_USE_DER)) == NULLBER){
- return (LDAP_NO_MEMORY);
- }
-
- if (ber_printf(ber, "{io}", pagesize,
- (cookie && cookie->bv_val) ? cookie->bv_val : "",
- (cookie && cookie->bv_val) ? cookie->bv_len : 0)
- == LBER_ERROR) {
- ber_free(ber, 1);
- return (LDAP_ENCODING_ERROR);
- }
-
- rc = ldap_build_control(LDAP_CONTROL_SIMPLE_PAGE, ber, 1, isCritical,
- output);
-
- ld->ld_errno = rc;
- return (rc);
-}
-
-int ldap_parse_page_control(LDAP *ld, LDAPControl **controls, unsigned int *totalcount, struct berval **cookie)
-{
- int i, rc;
- BerElement *theBer;
- LDAPControl *listCtrlp;
-
- for (i = 0; controls[i] != NULL; i++){
- if (strcmp(controls[i]->ldctl_oid, "1.2.840.113556.1.4.319") == 0) {
- listCtrlp = controls[i];
- if ((theBer = ber_init(&listCtrlp->ldctl_value)) == NULLBER){
- return (LDAP_NO_MEMORY);
- }
- if ((rc = ber_scanf(theBer, "{iO}", totalcount, cookie)) == LBER_ERROR){
- ber_free(theBer, 1);
- return (LDAP_DECODING_ERROR);
- }
- ber_free(theBer, 1);
- return (LDAP_SUCCESS);
- }
- }
- return (LDAP_CONTROL_NOT_FOUND);
-}
-
diff --git a/usr/src/lib/libldap4/common/extop.c b/usr/src/lib/libldap4/common/extop.c
deleted file mode 100644
index a299b1dd61..0000000000
--- a/usr/src/lib/libldap4/common/extop.c
+++ /dev/null
@@ -1,156 +0,0 @@
-/*
- *
- * Copyright 1999 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- *
- *
- * Comments:
- *
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#include <stdio.h>
-#include <string.h>
-
-#ifdef MACOS
-#include "macos.h"
-#endif /* MACOS */
-
-#if !defined( MACOS ) && !defined( DOS )
-#include <sys/types.h>
-#include <sys/socket.h>
-#endif
-
-#include "lber.h"
-#include "ldap.h"
-#include "ldap-private.h"
-#include "ldap-int.h"
-
-BerElement * ldap_build_extended_operation_req(LDAP *ld, char *exoid, struct berval *exdata, LDAPControl ** serverctrls)
-{
- BerElement *ber;
- int rv;
-
- /* an extended operation request looks like this:
- * ExtendedRequest ::= [APPLICATION 23] SEQUENCE {
- * requestName [0] LDAPOID,
- * requestValue [1] OCTECT STRING OPTIONAL
- * }
- */
- if ( (ber = alloc_ber_with_options( ld )) == NULLBER ) {
- ld->ld_errno = LDAP_NO_MEMORY;
- return( NULLBER );
- }
-
- if ( ber_printf( ber, "{it{ts", ++ld->ld_msgid, LDAP_REQ_EXTENDED, LDAP_TAG_EXT_NAME, exoid ) == -1 ) {
- ld->ld_errno = LDAP_ENCODING_ERROR;
- ber_free( ber, 1 );
- return( NULLBER );
- }
-
- if (exdata && (ber_printf(ber, "to", LDAP_TAG_EXT_VAL, exdata->bv_val, exdata->bv_len) == -1 )) {
- ld->ld_errno = LDAP_ENCODING_ERROR;
- ber_free( ber, 1 );
- return( NULLBER );
- }
-
- if ( ber_printf( ber, "}" ) == -1 ) {
- ld->ld_errno = LDAP_ENCODING_ERROR;
- ber_free( ber, 1 );
- return( NULLBER );
- }
- /* LDAPv3 */
- /* Code controls if any */
- if (serverctrls && serverctrls[0]) {
- if (ldap_controls_code(ber, serverctrls) != LDAP_SUCCESS){
- ld->ld_errno = LDAP_ENCODING_ERROR;
- ber_free( ber, 1 );
- return( NULLBER );
- }
- } else if (ld->ld_srvctrls && ld->ld_srvctrls[0]) {
- /* Otherwise, is there any global server ctrls ? */
- if (ldap_controls_code(ber, ld->ld_srvctrls) != LDAP_SUCCESS){
- ld->ld_errno = LDAP_ENCODING_ERROR;
- ber_free( ber, 1 );
- return( NULLBER );
- }
- }
-
- if ( ber_printf( ber, "}" ) == -1 ) {
- ld->ld_errno = LDAP_ENCODING_ERROR;
- ber_free( ber, 1 );
- return( NULLBER );
- }
-
- return (ber);
-}
-
-/* ldap_extended_operation - initiate an ldap extended operation.
- * Parameters :
- * ld : LDAP descriptor.
- * exoid : OID of the request.
- * exdata : Arbitrary data required by the operation.
- * serverctrls : List of server controls.
- * clientctrls : List of client controls.
- * msgidp : msg id returned if operation succeeded.
- * Returns LDAP_SUCCESS or error code.
- */
-
-int ldap_extended_operation(LDAP *ld, char *exoid, struct berval *exdata,
- LDAPControl **serverctrls, LDAPControl **clientctrls, int *msgidp)
-{
- BerElement *ber;
- int rv;
-
-#ifdef _REENTRANT
- LOCK_LDAP(ld);
-#endif
- Debug( LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 242, "ldap_extended_operation\n"), 0, 0, 0 );
-
- if (( ber = ldap_build_extended_operation_req( ld, exoid, exdata, serverctrls)) == NULLBER ) {
- rv = ld->ld_errno;
- if (rv == LDAP_SUCCESS)
- rv = LDAP_OTHER;
-#ifdef _REENTRANT
- UNLOCK_LDAP(ld);
-#endif
- return( rv);
- }
-
- /* send the message */
- rv = send_initial_request( ld, LDAP_REQ_EXTENDED, NULL, ber );
- if (rv == -1) {
- rv = ld->ld_errno;
- if (rv == LDAP_SUCCESS){
- rv = LDAP_OTHER;
- }
-#ifdef _REENTRANT
- UNLOCK_LDAP(ld);
-#endif
- return (rv);
- }
-
- *msgidp = rv;
-#if _REENTRANT
- UNLOCK_LDAP(ld);
-#endif
- return ( LDAP_SUCCESS );
-}
-
-
-int ldap_extended_operation_s(LDAP *ld, char *exoid, struct berval *exdata,
- LDAPControl **serverctrls, LDAPControl **clientctrls,
- char **retoidp, struct berval **retdatap)
-{
- int msgid;
- int retcode;
- LDAPMessage *res = NULL;
-
- if ((retcode = ldap_extended_operation(ld, exoid, exdata, serverctrls, clientctrls, &msgid)) != LDAP_SUCCESS)
- return (retcode);
- if (ldap_result(ld, msgid, 1, (struct timeval *)NULL, &res ) == -1)
- return (ld->ld_errno );
-
- return (ldap_parse_extended_result(ld, res, retoidp, retdatap, 1));
-}
diff --git a/usr/src/lib/libldap4/common/free.c b/usr/src/lib/libldap4/common/free.c
deleted file mode 100644
index a9d4bd0675..0000000000
--- a/usr/src/lib/libldap4/common/free.c
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- *
- * Portions Copyright 1999 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- *
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*
- * Copyright (c) 1994 The Regents of the University of Michigan.
- * All rights reserved.
- *
- * free.c - some free routines are included here to avoid having to
- * link in lots of extra code when not using certain features
- */
-
-#ifndef lint
-static char copyright[] = "@(#) Copyright (c) 1994 The Regents of the University of Michigan.\nAll rights reserved.\n";
-#endif
-
-
-#include <stdio.h>
-#include <string.h>
-#include <ctype.h>
-#ifdef MACOS
-#include <stdlib.h>
-#include "macos.h"
-#else /* MACOS */
-#ifdef DOS
-#include <malloc.h>
-#include "msdos.h"
-#else /* DOS */
-#include <sys/types.h>
-#include <stdlib.h>
-#endif /* DOS */
-#endif /* MACOS */
-
-#include "lber.h"
-#include "ldap.h"
-#include "ldap-private.h"
-
-void
-ldap_getfilter_free( LDAPFiltDesc *lfdp )
-{
- LDAPFiltList *flp, *nextflp;
- LDAPFiltInfo *fip, *nextfip;
-
- for ( flp = lfdp->lfd_filtlist; flp != NULL; flp = nextflp ) {
- for ( fip = flp->lfl_ilist; fip != NULL; fip = nextfip ) {
- nextfip = fip->lfi_next;
- free( fip->lfi_filter );
- free( fip->lfi_desc );
- free( fip );
- }
- nextflp = flp->lfl_next;
- free( flp->lfl_pattern );
- free( flp->lfl_delims );
- free( flp->lfl_tag );
- free( flp );
- }
-
- if ( lfdp->lfd_curvalcopy != NULL ) {
- free( lfdp->lfd_curvalcopy );
- }
- if ( lfdp->lfd_curvalwords != NULL ) {
- free( lfdp->lfd_curvalwords );
- }
- if ( lfdp->lfd_filtprefix != NULL ) {
- free( lfdp->lfd_filtprefix );
- }
- if ( lfdp->lfd_filtsuffix != NULL ) {
- free( lfdp->lfd_filtsuffix );
- }
-
- free( lfdp );
-}
-
-/*
- * free a null-terminated array of pointers to mod structures. the
- * structures are freed, not the array itself, unless the freemods
- * flag is set.
- */
-
-void
-ldap_mods_free( LDAPMod **mods, int freemods )
-{
- int i;
-
- if ( mods == NULL )
- return;
-
- for ( i = 0; mods[i] != NULL; i++ ) {
- if ( mods[i]->mod_op & LDAP_MOD_BVALUES ) {
- ber_bvecfree( mods[i]->mod_bvalues );
- } else {
- ldap_value_free( mods[i]->mod_values );
- }
- if (mods[i]->mod_type)
- free(mods[i]->mod_type);
- free( (char *) mods[i] );
- }
-
- if ( freemods )
- free( (char *) mods );
-}
diff --git a/usr/src/lib/libldap4/common/friendly.c b/usr/src/lib/libldap4/common/friendly.c
deleted file mode 100644
index 1142722970..0000000000
--- a/usr/src/lib/libldap4/common/friendly.c
+++ /dev/null
@@ -1,142 +0,0 @@
-/*
- *
- * Portions Copyright 1998 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- *
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*
- * Copyright (c) 1990 Regents of the University of Michigan.
- * All rights reserved.
- *
- * friendly.c
- */
-
-#ifndef lint
-static char copyright[] = "@(#) Copyright (c) 1993 Regents of the University of Michigan.\nAll rights reserved.\n";
-#endif
-
-#include <stdio.h>
-#include <ctype.h>
-#include <string.h>
-#include <stdlib.h> /* malloc(), free() for Solaris */
-#ifdef MACOS
-#include <stdlib.h>
-#include "macos.h"
-#endif /* MACOS */
-
-#if defined( DOS ) || defined( _WIN32 )
-#include <malloc.h>
-#include "msdos.h"
-#endif /* DOS */
-
-#if !defined( MACOS ) && !defined( DOS )
-#include <errno.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#endif
-
-#include "lber.h"
-#include "ldap.h"
-#include "ldap-private.h"
-#include "ldap-int.h"
-
-char *
-ldap_friendly_name( char *filename, char *uname, FriendlyMap **map )
-{
- int i, entries;
- FILE *fp;
- char *s;
- char buf[BUFSIZ];
-
- if ( map == NULL ) {
-#if !defined( MACOS ) && !defined( DOS )
- errno = EINVAL;
-#endif
- return( uname );
- }
-
- if ( *map == NULL ) {
- if ( (fp = fopen( filename, "r" )) == NULL )
- return( uname );
-
- entries = 0;
- while ( fgets( buf, sizeof(buf), fp ) != NULL ) {
- if ( buf[0] != '#' )
- entries++;
- }
- rewind( fp );
-
- if ( (*map = (FriendlyMap *) malloc( (entries + 1) *
- sizeof(FriendlyMap) )) == NULL ) {
- (void) fclose( fp );
- return( uname );
- }
-
- i = 0;
- while ( fgets( buf, sizeof(buf), fp ) != NULL && i < entries ) {
- if ( buf[0] == '#' )
- continue;
-
- if ( (s = strchr( buf, '\n' )) != NULL )
- *s = '\0';
-
- if ( (s = strchr( buf, '\t' )) == NULL )
- continue;
- *s++ = '\0';
-
- if ( *s == '"' ) {
- int esc = 0, found = 0;
-
- for ( ++s; *s && !found; s++ ) {
- switch ( *s ) {
- case '\\':
- esc = 1;
- break;
- case '"':
- if ( !esc )
- found = 1;
- /* FALL */
- default:
- esc = 0;
- break;
- }
- }
- }
-
- (*map)[i].f_unfriendly = strdup( buf );
- (*map)[i].f_friendly = strdup( s );
- i++;
- }
-
- (void) fclose( fp );
- (*map)[i].f_unfriendly = NULL;
- }
-
- for ( i = 0; (*map)[i].f_unfriendly != NULL; i++ ) {
- if ( strcasecmp( uname, (*map)[i].f_unfriendly ) == 0 )
- return( (*map)[i].f_friendly );
- }
- return( uname );
-}
-
-
-void
-ldap_free_friendlymap( FriendlyMap **map )
-{
- struct friendly* pF = *map;
-
- if ( pF == NULL )
- return;
-
- while ( pF->f_unfriendly )
- {
- free( pF->f_unfriendly );
- free( pF->f_friendly );
- pF++;
- }
- free( *map );
- *map = NULL;
-}
diff --git a/usr/src/lib/libldap4/common/getattr.c b/usr/src/lib/libldap4/common/getattr.c
deleted file mode 100644
index 26f7b064f2..0000000000
--- a/usr/src/lib/libldap4/common/getattr.c
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * Portions Copyright 2001 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*
- * Copyright (c) 1990 Regents of the University of Michigan.
- * All rights reserved.
- *
- * getattr.c
- */
-
-#ifndef lint
-static char copyright[] = "@(#) Copyright (c) 1990 Regents of the University of Michigan.\nAll rights reserved.\n";
-#endif
-
-#include <stdio.h>
-#include <ctype.h>
-#include <string.h>
-#ifdef MACOS
-#include <stdlib.h>
-#include "macos.h"
-#else /* MACOS */
-#if defined( DOS ) || defined( _WIN32 )
-#include <malloc.h>
-#include "msdos.h"
-#else /* DOS */
-#include <sys/types.h>
-#include <sys/socket.h>
-#endif /* DOS */
-#endif /* MACOS */
-
-#include "lber.h"
-#include "ldap.h"
-#include "ldap-private.h"
-#include "ldap-int.h"
-
-char *
-ldap_first_attribute( LDAP *ld, LDAPMessage *entry, BerElement **ber )
-{
- int len;
- char *attrbuffer;
-
- if ((attrbuffer = (char *)malloc(LDAP_MAX_ATTR_LEN)) == NULL) {
- return (NULL);
- }
-
- Debug( LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 179, "ldap_first_attribute\n"), 0, 0, 0 );
-
- if ( (*ber = alloc_ber_with_options( ld )) == NULLBER ) {
- free(attrbuffer);
- return( NULL );
- }
-
- **ber = *entry->lm_ber;
-
- /*
- * Skip past the sequence, dn, sequence of sequence, snarf the
- * attribute type, and skip the set of values, leaving us
- * positioned right before the next attribute type/value sequence.
- */
-
- len = LDAP_MAX_ATTR_LEN;
- if ( ber_scanf( *ber, "{x{{sx}", attrbuffer, &len )
- == LBER_ERROR ) {
- ld->ld_errno = LDAP_DECODING_ERROR;
- ber_free( *ber, 0 );
- *ber = NULL;
- free(attrbuffer);
- return( NULL );
- }
-
- return( attrbuffer );
-}
-
-/* ARGSUSED */
-char *
-ldap_next_attribute( LDAP *ld, LDAPMessage *entry, BerElement *ber )
-{
- int len;
- char *attrbuffer;
-
- if ((attrbuffer = (char *)malloc(LDAP_MAX_ATTR_LEN)) == NULL) {
- return (NULL);
- }
-
- Debug( LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 180, "ldap_next_attribute\n"), 0, 0, 0 );
-
- /* skip sequence, snarf attribute type, skip values */
- len = LDAP_MAX_ATTR_LEN;
- if ( ber_scanf( ber, "{sx}", attrbuffer, &len )
- == LBER_ERROR ) {
- ld->ld_errno = LDAP_DECODING_ERROR;
- free(attrbuffer);
- return( NULL );
- }
- ld->ld_errno = LDAP_SUCCESS;
- return( attrbuffer );
-}
-
-void ldap_memfree(char *mem)
-{
- free(mem);
-}
-
diff --git a/usr/src/lib/libldap4/common/getdn.c b/usr/src/lib/libldap4/common/getdn.c
deleted file mode 100644
index d0cb89a213..0000000000
--- a/usr/src/lib/libldap4/common/getdn.c
+++ /dev/null
@@ -1,412 +0,0 @@
-/*
- * Portions Copyright 1998 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*
- * Copyright (c) 1994 Regents of the University of Michigan.
- * All rights reserved.
- *
- * getdn.c
- */
-
-#ifndef lint
-static char copyright[] = "@(#) Copyright (c) 1990 Regents of the University of Michigan.\nAll rights reserved.\n";
-#endif
-
-#include <stdio.h>
-#include <ctype.h>
-#include <string.h>
-#include <stdlib.h> /* malloc(), realloc(), calloc() for Solaris */
-#ifdef MACOS
-#include <stdlib.h>
-#include "macos.h"
-#else /* MACOS */
-#if defined( DOS ) || defined( _WIN32 )
-#include <malloc.h>
-#include "msdos.h"
-#else /* DOS */
-#include <sys/types.h>
-#include <sys/socket.h>
-#endif /* DOS */
-#endif /* MACOS */
-
-#include "lber.h"
-#include "ldap.h"
-#include "ldap-private.h"
-#include "ldap-int.h"
-
-char *
-ldap_get_dn( LDAP *ld, LDAPMessage *entry )
-{
- char *dn;
- BerElement tmp;
-
- Debug( LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 181, "ldap_get_dn\n"), 0, 0, 0 );
-
- if ( entry == NULL ) {
- ld->ld_errno = LDAP_PARAM_ERROR;
- return( NULL );
- }
-
- tmp = *entry->lm_ber; /* struct copy */
- if ( ber_scanf( &tmp, "{a", &dn ) == LBER_ERROR ) {
- ld->ld_errno = LDAP_DECODING_ERROR;
- return( NULL );
- }
-
- return( dn );
-}
-
-char *
-ldap_dn2ufn( char *dn )
-{
- char *p, *ufn, *r;
- int state;
-
- Debug( LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 182, "ldap_dn2ufn\n"), 0, 0, 0 );
-
- if ( ldap_is_dns_dn( dn ) || ( p = strchr( dn, '=' )) == NULL )
- return( strdup( dn ));
-
- ufn = strdup( ++p );
-
-#define INQUOTE 1
-#define OUTQUOTE 2
- state = OUTQUOTE;
- for ( p = ufn, r = ufn; *p; p++ ) {
- switch ( *p ) {
- case '\\':
- if ( *++p == '\0' )
- p--;
- else {
- *r++ = '\\';
- *r++ = *p;
- }
- break;
- case '"':
- if ( state == INQUOTE )
- state = OUTQUOTE;
- else
- state = INQUOTE;
- *r++ = *p;
- break;
- case ';':
- case ',':
- if ( state == OUTQUOTE )
- *r++ = ',';
- else
- *r++ = *p;
- break;
- case '=':
- if ( state == INQUOTE )
- *r++ = *p;
- else {
- char *rsave = r;
-
- *r-- = '\0';
- while ( !isspace( *r ) && *r != ';'
- && *r != ',' && r > ufn )
- r--;
- r++;
-
- if ( strcasecmp( r, "c" )
- && strcasecmp( r, "o" )
- && strcasecmp( r, "ou" )
- && strcasecmp( r, "st" )
- && strcasecmp( r, "l" )
- && strcasecmp( r, "cn" ) ) {
- r = rsave;
- *r++ = '=';
- }
- }
- break;
- default:
- *r++ = *p;
- break;
- }
- }
- *r = '\0';
-
- return( ufn );
-}
-
-char **
-ldap_explode_dns( char *dn )
-{
- int ncomps, maxcomps;
- char *s;
- char **rdns;
-
- if ( (rdns = (char **) malloc( 8 * sizeof(char *) )) == NULL ) {
- return( NULL );
- }
-
- maxcomps = 8;
- ncomps = 0;
- for ( s = strtok( dn, "@." ); s != NULL; s = strtok( NULL, "@." ) ) {
- if ( ncomps == maxcomps ) {
- maxcomps *= 2;
- if ( (rdns = (char **) realloc( rdns, maxcomps *
- sizeof(char *) )) == NULL ) {
- return( NULL );
- }
- }
- rdns[ncomps++] = strdup( s );
- }
- rdns[ncomps] = NULL;
-
- return( rdns );
-}
-
-char **
-ldap_explode_dn( char *dn, int notypes )
-{
- char *p, *q, *rdnstart, **rdns = NULL;
- int state, count = 0, endquote;
- ssize_t len;
-
- Debug( LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 183, "ldap_explode_dn\n"), 0, 0, 0 );
-
- if ( ldap_is_dns_dn( dn ) ) {
- return( ldap_explode_dns( dn ) );
- }
-
- rdnstart = dn;
- p = dn-1;
- state = OUTQUOTE;
-
- do {
-
- ++p;
- switch ( *p ) {
- case '\\':
- if ( *++p == '\0' )
- p--;
- break;
- case '"':
- if ( state == INQUOTE )
- state = OUTQUOTE;
- else
- state = INQUOTE;
- break;
- case ';':
- case ',':
- case '\0':
- if ( state == OUTQUOTE ) {
- ++count;
- if ( rdns == NULL ) {
- if (( rdns = (char **)malloc( 8
- * sizeof( char *))) == NULL )
- return( NULL );
- } else if ( count >= 8 ) {
- if (( rdns = (char **)realloc( rdns,
- (count+1) * sizeof( char *)))
- == NULL )
- return( NULL );
- }
- rdns[ count ] = NULL;
- endquote = 0;
- if ( notypes ) {
- for ( q = rdnstart;
- q < p && *q != '='; ++q ) {
- ;
- }
- if ( q < p ) {
- rdnstart = ++q;
- }
- if ( *rdnstart == '"' ) {
- ++rdnstart;
- }
-
- if ( *(p-1) == '"' ) {
- endquote = 1;
- --p;
- }
- }
-
- len = p - rdnstart;
- if (( rdns[ count-1 ] = (char *)calloc( 1,
- len + 1 )) != NULL ) {
- (void) SAFEMEMCPY( rdns[ count-1 ], rdnstart,
- len );
- rdns[ count-1 ][ len ] = '\0';
- }
-
- /*
- * Don't forget to increment 'p' back to where
- * it should be. If we don't, then we will
- * never get past an "end quote."
- */
- if ( endquote == 1 )
- p++;
-
- rdnstart = *p ? p + 1 : p;
- while ( isspace( *rdnstart ))
- ++rdnstart;
- }
- break;
- }
- } while ( *p );
-
- return( rdns );
-}
-
-
-int
-ldap_is_dns_dn( char *dn )
-{
- return( dn[ 0 ] != '\0' && strchr( dn, '=' ) == NULL &&
- strchr( dn, ',' ) == NULL );
-}
-
-
-#if defined( ultrix ) || defined( NeXT )
-
-char *strdup( char *s )
-{
- char *p;
-
- if ( (p = (char *) malloc( strlen( s ) + 1 )) == NULL )
- return( NULL );
-
- strcpy( p, s );
-
- return( p );
-}
-
-#endif /* ultrix */
-
-
-/*
- * Convert a DNS domain name into an X.500 distinguished name.
- * For example, "sales.wiz.com" -> "dc=sales,dc=wiz,dc=com"
- *
- * If an error is encountered zero is returned, otherwise a string
- * distinguished name and the number of nameparts is returned.
- * The caller should free the returned string if it is non-zero.
- */
-
-char *
-ldap_dns_to_dn(
- char *dns_name,
- int *nameparts
-)
-{
- size_t dns_len;
- char *dn = 0;
- char *cp;
-
- /* check for NULL string, empty name and name ending in '.' */
- if (dns_name && (dns_len = strlen(dns_name)) &&
- (dns_name[dns_len - 1] != '.')) {
- if (dn = (char *)malloc(dns_len * 3 + 1)) {
- *nameparts = 0;
- cp = dn;
- while (*dns_name) {
- *cp++ = 'd';
- *cp++ = 'c';
- *cp++ = '=';
-
- while (*dns_name && (*dns_name != '.')) {
- *cp++ = *dns_name++;
- }
- if (*dns_name == '.') {
- dns_name++;
- *cp++ = ',';
- }
- (*nameparts)++;
- }
- *cp = '\0';
- }
- }
- return (dn);
-}
-
-char **
-ldap_explode_rdn( char *rdn, int notypes )
-{
- char *p, *q, *rdnstart, **rdncomps = NULL;
- int state, count = 0, endquote;
- size_t len;
-
- Debug( LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 183, "ldap_explode_rdn\n"), 0, 0, 0 );
-
- rdnstart = rdn;
- p = rdn-1;
- state = OUTQUOTE;
-
- do {
-
- ++p;
- switch ( *p ) {
- case '\\':
- if ( *++p == '\0' )
- p--;
- break;
- case '"':
- if ( state == INQUOTE )
- state = OUTQUOTE;
- else
- state = INQUOTE;
- break;
- case '+':
- case '\0':
- if ( state == OUTQUOTE ) {
- ++count;
- if ( rdncomps == NULL ) {
- if (( rdncomps = (char **)malloc( 8 * sizeof( char *))) == NULL )
- return( NULL );
- } else if ( count >= 8 ) {
- if (( rdncomps = (char **)realloc( rdncomps,
- (count+1) * sizeof( char *)))
- == NULL )
- return( NULL );
- }
- rdncomps[ count ] = NULL;
- endquote = 0;
- if ( notypes ) {
- for ( q = rdnstart;
- q < p && *q != '='; ++q ) {
- ;
- }
- if ( q < p ) {
- rdnstart = ++q;
- }
- if ( *rdnstart == '"' ) {
- ++rdnstart;
- }
-
- if ( *(p-1) == '"' ) {
- endquote = 1;
- --p;
- }
- }
-
- len = p - rdnstart;
- if (( rdncomps[ count-1 ] = (char *)calloc( 1, len + 1 )) != NULL ) {
- SAFEMEMCPY( rdncomps[ count-1 ], rdnstart,
- len );
- rdncomps[ count-1 ][ len ] = '\0';
- }
-
- /*
- * Don't forget to increment 'p' back to where
- * it should be. If we don't, then we will
- * never get past an "end quote."
- */
- if ( endquote == 1 )
- p++;
-
- rdnstart = *p ? p + 1 : p;
- while ( isspace( *rdnstart ))
- ++rdnstart;
- }
- break;
- }
- } while ( *p );
-
- return( rdncomps );
-}
diff --git a/usr/src/lib/libldap4/common/getdxbyname.c b/usr/src/lib/libldap4/common/getdxbyname.c
deleted file mode 100644
index e6316e0436..0000000000
--- a/usr/src/lib/libldap4/common/getdxbyname.c
+++ /dev/null
@@ -1,227 +0,0 @@
-/*
- * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#ifdef LDAP_DNS
-/*
- * Copyright (c) 1995 Regents of the University of Michigan.
- * All rights reserved.
- *
- * getdxbyname - retrieve DX records from the DNS (from TXT records for now)
- */
-#include <stdio.h>
-#include <string.h>
-#include <ctype.h>
-
-#ifdef MACOS
-#include <stdlib.h>
-#include "macos.h"
-#endif /* MACOS */
-
-#if !defined(MACOS) && !defined(DOS) && !defined( _WIN32 )
-#include <sys/types.h>
-#include <netinet/in.h>
-#include <arpa/nameser.h>
-#include <sys/time.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netdb.h>
-#include <resolv.h>
-#endif
-#include "lber.h"
-#include "ldap.h"
-#include "ldap-private.h"
-#include "ldap-int.h"
-
-#if defined( DOS ) || defined( _WIN32 )
-#include "msdos.h"
-#endif /* DOS */
-
-
-#ifdef NEEDPROTOS
-static char ** decode_answer( unsigned char *answer, int len );
-#else /* NEEDPROTOS */
-static char **decode_answer();
-#endif /* NEEDPROTOS */
-
-extern int h_errno;
-extern char *h_errlist[];
-
-
-#define MAX_TO_SORT 32
-
-
-/*
- * getdxbyname - lookup DNS DX records for domain and return an ordered
- * array.
- */
-char **
-getdxbyname( char *domain )
-{
- unsigned char buf[ PACKETSZ ];
- char **dxs;
- int rc;
-
- Debug( LDAP_DEBUG_TRACE, "getdxbyname( %s )\n", domain, 0, 0 );
-
- memset( buf, 0, sizeof( buf ));
-
- if (( rc = res_search( domain, C_IN, T_TXT, buf, sizeof( buf ))) < 0
- || ( dxs = decode_answer( buf, rc )) == NULL ) {
- /*
- * punt: return list conisting of the original domain name only
- */
- if (( dxs = (char **)malloc( 2 * sizeof( char * ))) == NULL ||
- ( dxs[ 0 ] = strdup( domain )) == NULL ) {
- if ( dxs != NULL ) {
- free( dxs );
- }
- dxs = NULL;
- } else {
- dxs[ 1 ] = NULL;
- }
- }
-
- return( dxs );
-}
-
-
-static char **
-decode_answer( unsigned char *answer, int len )
-{
- HEADER *hp;
- char buf[ 256 ], **dxs;
- unsigned char *eom, *p;
- int ancount, err, rc, type, class, dx_count, rr_len;
- int dx_pref[ MAX_TO_SORT ];
-
- int _getshort( unsigned char * );
-#ifdef LDAP_DEBUG
- if ( ldap_debug & LDAP_DEBUG_PACKETS ) {
-/* __p_query( answer ); */
- }
-#endif /* LDAP_DEBUG */
-
- dxs = NULL;
- hp = (HEADER *)answer;
- eom = answer + len;
-
- if ( ntohs( hp->qdcount ) != 1 ) {
- h_errno = NO_RECOVERY;
- return( NULL );
- }
-
- ancount = ntohs( hp->ancount );
- if ( ancount < 1 ) {
- h_errno = NO_DATA;
- return( NULL );
- }
-
- /*
- * skip over the query
- */
- p = answer + HFIXEDSZ;
- if (( rc = dn_expand( answer, eom, p, buf, sizeof( buf ))) < 0 ) {
- h_errno = NO_RECOVERY;
- return( NULL );
- }
- p += ( rc + QFIXEDSZ );
-
- /*
- * pull out the answers we are interested in
- */
- err = dx_count = 0;
- while ( ancount > 0 && err == 0 && p < eom ) {
- if (( rc = dn_expand( answer, eom, p, buf, sizeof( buf ))) < 0 ) {
- err = NO_RECOVERY;
- continue;
- }
- p += rc; /* skip over name */
- type = _getshort( p );
- p += INT16SZ;
- class = _getshort( p );
- p += INT16SZ;
- p += INT32SZ; /* skip over TTL */
- rr_len = _getshort( p );
- p += INT16SZ;
- if ( class == C_IN && type == T_TXT ) {
- int i, n, pref, txt_len;
- char *q, *r;
-
- q = (char *)p;
- while ( q < (char *)p + rr_len && err == 0 ) {
- if ( *q >= 3 && strncasecmp( q + 1, "dx:", 3 ) == 0 ) {
- txt_len = *q - 3;
- r = q + 4;
- while ( isspace( *r )) {
- ++r;
- --txt_len;
- }
- pref = 0;
- while ( isdigit( *r )) {
- pref *= 10;
- pref += ( *r - '0' );
- ++r;
- --txt_len;
- }
- if ( dx_count < MAX_TO_SORT - 1 ) {
- dx_pref[ dx_count ] = pref;
- }
- while ( isspace( *r )) {
- ++r;
- --txt_len;
- }
- if ( dx_count == 0 ) {
- dxs = (char **)malloc( 2 * sizeof( char * ));
- } else {
- dxs = (char **)realloc( dxs,
- ( dx_count + 2 ) * sizeof( char * ));
- }
- if ( dxs == NULL || ( dxs[ dx_count ] =
- (char *)calloc( 1, txt_len + 1 )) == NULL ) {
- err = NO_RECOVERY;
- continue;
- }
- memcpy( dxs[ dx_count ], r, txt_len );
- dxs[ ++dx_count ] = NULL;
- }
- q += ( *q + 1 ); /* move past last TXT record */
- }
- }
- p += rr_len;
- }
-
- if ( err == 0 ) {
- if ( dx_count == 0 ) {
- err = NO_DATA;
- } else {
- /*
- * sort records based on associated preference value
- */
- int i, j, sort_count, tmp_pref;
- char *tmp_dx;
-
- sort_count = ( dx_count < MAX_TO_SORT ) ? dx_count : MAX_TO_SORT;
- for ( i = 0; i < sort_count; ++i ) {
- for ( j = i + 1; j < sort_count; ++j ) {
- if ( dx_pref[ i ] > dx_pref[ j ] ) {
- tmp_pref = dx_pref[ i ];
- dx_pref[ i ] = dx_pref[ j ];
- dx_pref[ j ] = tmp_pref;
- tmp_dx = dxs[ i ];
- dxs[ i ] = dxs[ j ];
- dxs[ j ] = tmp_dx;
- }
- }
- }
- }
- }
-
- h_errno = err;
- return( dxs );
-}
-
-#endif /* LDAP_DNS */
diff --git a/usr/src/lib/libldap4/common/getentry.c b/usr/src/lib/libldap4/common/getentry.c
deleted file mode 100644
index 346f23e9a8..0000000000
--- a/usr/src/lib/libldap4/common/getentry.c
+++ /dev/null
@@ -1,82 +0,0 @@
-/*
- * Portions Copyright 1998 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*
- * Copyright (c) 1990 Regents of the University of Michigan.
- * All rights reserved.
- *
- * getentry.c
- */
-
-#ifndef lint
-static char copyright[] = "@(#) Copyright (c) 1990 Regents of the University of Michigan.\nAll rights reserved.\n";
-#endif
-
-#include <stdio.h>
-#include <ctype.h>
-#include <string.h>
-#ifdef MACOS
-#include <stdlib.h>
-#include "macos.h"
-#else /* MACOS */
-#if defined( DOS ) || defined( _WIN32 )
-#include <malloc.h>
-#include "msdos.h"
-#else /* DOS */
-#include <sys/types.h>
-#include <sys/socket.h>
-#endif /* DOS */
-#endif /* MACOS */
-
-#include "lber.h"
-#include "ldap.h"
-#include "ldap-private.h"
-
-/* ARGSUSED */
-LDAPMessage *
-ldap_first_entry( LDAP *ld, LDAPMessage *res )
-{
- LDAPMessage *msg = res;
-
- while ( msg != NULLMSG) {
- if (msg->lm_msgtype == LDAP_RES_SEARCH_ENTRY)
- break;
- msg = msg->lm_chain;
- }
- return (msg);
-}
-
-/* ARGSUSED */
-LDAPMessage *ldap_next_entry( LDAP *ld, LDAPMessage *entry )
-{
- LDAPMessage *msg;
-
- if ( entry == NULLMSG)
- return( NULLMSG );
-
- msg = entry->lm_chain;
- while(msg != NULLMSG){
- if (msg->lm_msgtype == LDAP_RES_SEARCH_ENTRY)
- break;
- msg = msg->lm_chain;
- }
-
- return( msg );
-}
-
-/* ARGSUSED */
-int
-ldap_count_entries( LDAP *ld, LDAPMessage *res )
-{
- int i;
-
- for ( i = 0; res != NULL; res = res->lm_chain )
- if (res->lm_msgtype == LDAP_RES_SEARCH_ENTRY)
- i++;
-
- return( i );
-}
diff --git a/usr/src/lib/libldap4/common/getfilter.c b/usr/src/lib/libldap4/common/getfilter.c
deleted file mode 100644
index 57ae904801..0000000000
--- a/usr/src/lib/libldap4/common/getfilter.c
+++ /dev/null
@@ -1,447 +0,0 @@
-/*
- * Copyright 2000-2003 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*
- * Copyright (c) 1993 Regents of the University of Michigan.
- * All rights reserved.
- *
- * getfilter.c -- optional add-on to libldap
- */
-
-#ifndef lint
-static char copyright[] = "@(#) Copyright (c) 1993 Regents of the University of Michigan.\nAll rights reserved.\n";
-#endif
-
-#include <stdio.h>
-#include <string.h>
-#include <ctype.h>
-#if defined(NeXT)
-#include <regex.h>
-#endif
-#ifdef MACOS
-#include <stdlib.h>
-#include "macos.h"
-#else /* MACOS */
-#ifdef DOS
-#include <malloc.h>
-#include "msdos.h"
-#else /* DOS */
-#include <sys/types.h>
-#include <sys/file.h>
-#include <stdlib.h>
-#include <errno.h>
-#ifndef VMS
-#include <unistd.h>
-#endif /* VMS */
-#endif /* DOS */
-#endif /* MACOS */
-
-#include "lber.h"
-#include "ldap.h"
-#include "ldap-private.h"
-#include "ldap-int.h"
-#include "regex.h"
-
-#ifdef NEEDPROTOS
-static int break_into_words( char *str, char *delims, char ***wordsp );
-int next_line_tokens( char **bufp, ssize_t *blenp, char ***toksp );
-void free_strarray( char **sap );
-#else /* NEEDPROTOS */
-static int break_into_words();
-int next_line_tokens();
-void free_strarray();
-#endif /* NEEDPROTOS */
-
-#if !defined( MACOS ) && !defined( DOS )
-extern int errno;
-extern char *re_comp();
-#endif
-
-#define FILT_MAX_LINE_LEN 1024
-
-LDAPFiltDesc *
-ldap_init_getfilter( char *fname )
-{
- FILE *fp;
- char *buf;
- ssize_t rlen, len;
- int eof;
- LDAPFiltDesc *lfdp;
-
- if (( fp = fopen( fname, "r" )) == NULL ) {
- return( NULL );
- }
-
- if ( fseek( fp, 0L, SEEK_END ) != 0 ) { /* move to end to get len */
- fclose( fp );
- return( NULL );
- }
-
- len = ftell( fp );
-
- if ( fseek( fp, 0L, SEEK_SET ) != 0 ) { /* back to start of file */
- fclose( fp );
- return( NULL );
- }
-
- if (( buf = malloc( len )) == NULL ) {
- fclose( fp );
- return( NULL );
- }
-
- rlen = fread( buf, (size_t) 1, len, fp );
- eof = feof( fp );
- fclose( fp );
-
- if ( rlen != len && !eof ) { /* error: didn't get the whole file */
- free( buf );
- return( NULL );
- }
-
-
- lfdp = ldap_init_getfilter_buf( buf, rlen );
- free( buf );
-
- return( lfdp );
-}
-
-
-LDAPFiltDesc *
-ldap_init_getfilter_buf( char *buf, ssize_t buflen )
-{
- LDAPFiltDesc *lfdp;
- LDAPFiltList *flp, *nextflp;
- LDAPFiltInfo *fip, *nextfip;
- char *tag, **tok;
- int tokcnt, i;
-
- if (( lfdp = (LDAPFiltDesc *)calloc( (size_t) 1, sizeof( LDAPFiltDesc))) == NULL ) {
- return( NULL );
- }
-
- flp = nextflp = NULL;
- fip = NULL;
- tag = NULL;
-
- while ( buflen > 0 && ( tokcnt = next_line_tokens( &buf, &buflen, &tok ))
- > 0 ) {
-
- switch( tokcnt ) {
- case 1: /* tag line */
- if ( tag != NULL ) {
- free( tag );
- }
- tag = tok[ 0 ];
- free( tok );
- break;
- case 4:
- case 5: /* start of filter info. list */
- if (( nextflp = (LDAPFiltList *)calloc( (size_t) 1, sizeof( LDAPFiltList )))
- == NULL ) {
- ldap_getfilter_free( lfdp );
- return( NULL );
- }
- nextflp->lfl_tag = strdup( tag );
- nextflp->lfl_pattern = tok[ 0 ];
- if ( re_comp( nextflp->lfl_pattern ) != NULL ) {
-#ifndef NO_USERINTERFACE
- ldap_getfilter_free( lfdp );
- fprintf( stderr, "bad regular expresssion %s\n",
- nextflp->lfl_pattern );
-#if !defined( MACOS ) && !defined( DOS )
- errno = EINVAL;
-#endif
-#endif /* NO_USERINTERFACE */
- free_strarray( tok );
- return( NULL );
- }
-
- nextflp->lfl_delims = tok[ 1 ];
- nextflp->lfl_ilist = NULL;
- nextflp->lfl_next = NULL;
- if ( flp == NULL ) { /* first one */
- lfdp->lfd_filtlist = nextflp;
- } else {
- flp->lfl_next = nextflp;
- }
- flp = nextflp;
- fip = NULL;
- for ( i = 2; i < 5; ++i ) {
- tok[ i - 2 ] = tok[ i ];
- }
- /* fall through */
-
- case 2:
- case 3: /* filter, desc, and optional search scope */
- if ( nextflp != NULL ) { /* add to info list */
- if (( nextfip = (LDAPFiltInfo *)calloc( (size_t) 1,
- sizeof( LDAPFiltInfo ))) == NULL ) {
- ldap_getfilter_free( lfdp );
- free_strarray( tok );
- return( NULL );
- }
- if ( fip == NULL ) { /* first one */
- nextflp->lfl_ilist = nextfip;
- } else {
- fip->lfi_next = nextfip;
- }
- fip = nextfip;
- nextfip->lfi_next = NULL;
- nextfip->lfi_filter = tok[ 0 ];
- nextfip->lfi_desc = tok[ 1 ];
- if ( tok[ 2 ] != NULL ) {
- if ( strcasecmp( tok[ 2 ], "subtree" ) == 0 ) {
- nextfip->lfi_scope = LDAP_SCOPE_SUBTREE;
- } else if ( strcasecmp( tok[ 2 ], "onelevel" ) == 0 ) {
- nextfip->lfi_scope = LDAP_SCOPE_ONELEVEL;
- } else if ( strcasecmp( tok[ 2 ], "base" ) == 0 ) {
- nextfip->lfi_scope = LDAP_SCOPE_BASE;
- } else {
- free_strarray( tok );
- ldap_getfilter_free( lfdp );
-#if !defined( MACOS ) && !defined( DOS )
- errno = EINVAL;
-#endif
- return( NULL );
- }
- free( tok[ 2 ] );
- tok[ 2 ] = NULL;
- } else {
- nextfip->lfi_scope = LDAP_SCOPE_SUBTREE; /* default */
- }
- nextfip->lfi_isexact = ( strchr( tok[ 0 ], '*' ) == NULL &&
- strchr( tok[ 0 ], '~' ) == NULL );
- free( tok );
- }
- break;
-
- default:
- free_strarray( tok );
- ldap_getfilter_free( lfdp );
-#if !defined( MACOS ) && !defined( DOS )
- errno = EINVAL;
-#endif
- return( NULL );
- }
- }
-
- if ( tag != NULL ) {
- free( tag );
- }
-
- return( lfdp );
-}
-
-
-void
-ldap_setfilteraffixes( LDAPFiltDesc *lfdp, char *prefix, char *suffix )
-{
- if ( lfdp->lfd_filtprefix != NULL ) {
- free( lfdp->lfd_filtprefix );
- }
- lfdp->lfd_filtprefix = ( prefix == NULL ) ? NULL : strdup( prefix );
-
- if ( lfdp->lfd_filtsuffix != NULL ) {
- free( lfdp->lfd_filtsuffix );
- }
- lfdp->lfd_filtsuffix = ( suffix == NULL ) ? NULL : strdup( suffix );
-}
-
-
-LDAPFiltInfo *
-ldap_getfirstfilter( LDAPFiltDesc *lfdp, char *tagpat, char *value )
-{
- LDAPFiltList *flp;
-
- if ( lfdp->lfd_curvalcopy != NULL ) {
- free( lfdp->lfd_curvalcopy );
- free( lfdp->lfd_curvalwords );
- }
-
- lfdp->lfd_curval = value;
- lfdp->lfd_curfip = NULL;
-
- for ( flp = lfdp->lfd_filtlist; flp != NULL; flp = flp->lfl_next ) {
- if ( re_comp( tagpat ) == NULL && re_exec( flp->lfl_tag ) == 1
- && re_comp( flp->lfl_pattern ) == NULL
- && re_exec( lfdp->lfd_curval ) == 1 ) {
- lfdp->lfd_curfip = flp->lfl_ilist;
- break;
- }
- }
-
- if ( lfdp->lfd_curfip == NULL ) {
- return( NULL );
- }
-
- if (( lfdp->lfd_curvalcopy = strdup( value )) == NULL ) {
- return( NULL );
- }
-
- if ( break_into_words( lfdp->lfd_curvalcopy, flp->lfl_delims,
- &lfdp->lfd_curvalwords ) < 0 ) {
- free( lfdp->lfd_curvalcopy );
- lfdp->lfd_curvalcopy = NULL;
- return( NULL );
- }
-
- return( ldap_getnextfilter( lfdp ));
-}
-
-
-LDAPFiltInfo *
-ldap_getnextfilter( LDAPFiltDesc *lfdp )
-{
- LDAPFiltInfo *fip;
-
- fip = lfdp->lfd_curfip;
-
- if ( fip == NULL ) {
- return( NULL );
- }
-
- lfdp->lfd_curfip = fip->lfi_next;
-
- ldap_build_filter( lfdp->lfd_filter, (size_t) LDAP_FILT_MAXSIZ, fip->lfi_filter,
- lfdp->lfd_filtprefix, lfdp->lfd_filtsuffix, NULL,
- lfdp->lfd_curval, lfdp->lfd_curvalwords );
- lfdp->lfd_retfi.lfi_filter = lfdp->lfd_filter;
- lfdp->lfd_retfi.lfi_desc = fip->lfi_desc;
- lfdp->lfd_retfi.lfi_scope = fip->lfi_scope;
- lfdp->lfd_retfi.lfi_isexact = fip->lfi_isexact;
-
- return( &lfdp->lfd_retfi );
-}
-
-
-void
-ldap_build_filter( char *filtbuf, size_t buflen, char *pattern,
- char *prefix, char *suffix, char *attr, char *value, char **valwords )
-{
- char *p, *f;
- size_t slen;
- int i, wordcount, wordnum, endwordnum;
-
- if ( valwords == NULL ) {
- wordcount = 0;
- } else {
- for ( wordcount = 0; valwords[ wordcount ] != NULL; ++wordcount ) {
- ;
- }
- }
-
- f = filtbuf;
-
- if ( prefix != NULL ) {
- strcpy( f, prefix );
- f += strlen( prefix );
- }
-
- for ( p = pattern; *p != '\0'; ++p ) {
- if ( *p == '%' ) {
- ++p;
- if ( *p == 'v' ) {
- if ( isdigit( *(p+1))) {
- ++p;
- wordnum = *p - '1';
- if ( *(p+1) == '-' ) {
- ++p;
- if ( isdigit( *(p+1))) {
- ++p;
- endwordnum = *p - '1'; /* e.g., "%v2-4" */
-#ifndef SUN /* Patch from innosoft Craig.Watkins 08.Jul.97 */
- if ( endwordnum > wordcount - 1 ) {
- endwordnum = wordcount - 1;
- }
-#endif
- } else {
- endwordnum = wordcount - 1; /* e.g., "%v2-" */
- }
- } else {
- endwordnum = wordnum; /* e.g., "%v2" */
- }
-#ifdef SUN /* Patch from innosoft Craig.Watkins 08.Jul.97 */
- if ( endwordnum > wordcount - 1 ) {
- endwordnum = wordcount - 1;
- }
-#endif
- if ( wordcount > 0 ) {
- for ( i = wordnum; i <= endwordnum; ++i ) {
- if ( i > wordnum ) { /* add blank btw words */
- *f++ = ' ';
- }
- slen = strlen( valwords[ i ] );
- SAFEMEMCPY( f, valwords[ i ], slen );
- f += slen;
- }
- }
- } else if ( *(p+1) == '$' ) {
- ++p;
- if ( wordcount > 0 ) {
- wordnum = wordcount - 1;
- slen = strlen( valwords[ wordnum ] );
- SAFEMEMCPY( f, valwords[ wordnum ], slen );
- f += slen;
- }
- } else if ( value != NULL ) {
- slen = strlen( value );
- SAFEMEMCPY( f, value, slen );
- f += slen;
- }
- } else if ( *p == 'a' && attr != NULL ) {
- slen = strlen( attr );
- SAFEMEMCPY( f, attr, slen );
- f += slen;
- } else {
- *f++ = *p;
- }
- } else {
- *f++ = *p;
- }
-
- if ( f - filtbuf > buflen ) {
- /* sanity check */
- --f;
- break;
- }
- }
-
- if ( suffix != NULL && ( f - filtbuf ) < buflen ) {
- strcpy( f, suffix );
- } else {
- *f = '\0';
- }
-}
-
-
-static int
-break_into_words( char *str, char *delims, char ***wordsp )
-{
- char *word, **words;
- int count;
-
- if (( words = (char **)calloc( (size_t) 1, sizeof( char * ))) == NULL ) {
- return( -1 );
- }
- count = 0;
- words[ count ] = NULL;
-
- word = strtok( str, delims );
- while ( word != NULL ) {
- if (( words = (char **)realloc( words,
- ( count + 2 ) * sizeof( char * ))) == NULL ) {
- return( -1 );
- }
-
- words[ count ] = word;
- words[ ++count ] = NULL;
- word = strtok( NULL, delims );
- }
-
- *wordsp = words;
- return( count );
-}
diff --git a/usr/src/lib/libldap4/common/getmsg.c b/usr/src/lib/libldap4/common/getmsg.c
deleted file mode 100644
index abd8da6e47..0000000000
--- a/usr/src/lib/libldap4/common/getmsg.c
+++ /dev/null
@@ -1,40 +0,0 @@
-/*
- *
- * Copyright 1998 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- *
- *
- * Comments:
- *
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#include <stdio.h>
-#include <ctype.h>
-#include <string.h>
-#include "lber.h"
-#include "ldap.h"
-#include "ldap-private.h"
-
-LDAPMessage * ldap_first_message(LDAP *ld, LDAPMessage *res)
-{
- return (res == NULLMSG ? NULLMSG : res);
-}
-
-LDAPMessage * ldap_next_message(LDAP *ld, LDAPMessage *msg)
-{
- if (msg == NULLMSG || msg->lm_chain == NULLMSG)
- return (NULLMSG);
- return (msg->lm_chain);
-}
-
-int ldap_count_messages( LDAP *ld, LDAPMessage *res)
-{
- int i;
-
- for ( i =0; res != NULL; res = res->lm_chain)
- i++;
-
- return (i);
-}
diff --git a/usr/src/lib/libldap4/common/getref.c b/usr/src/lib/libldap4/common/getref.c
deleted file mode 100644
index ded453a038..0000000000
--- a/usr/src/lib/libldap4/common/getref.c
+++ /dev/null
@@ -1,79 +0,0 @@
-/*
- *
- * Copyright 1998 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- *
- *
- * Comments:
- *
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#include <stdio.h>
-#include <ctype.h>
-#include <string.h>
-#include "lber.h"
-#include "ldap.h"
-#include "ldap-private.h"
-#include "ldap-int.h"
-
-LDAPMessage * ldap_first_reference(LDAP *ld, LDAPMessage *res)
-{
- LDAPMessage *msg = res;
-
- while ( msg != NULLMSG) {
- if (msg->lm_msgtype == LDAP_RES_SEARCH_REFERENCE)
- break;
- msg = msg->lm_chain;
- }
- return (msg);
-}
-
-LDAPMessage * ldap_next_reference(LDAP *ld, LDAPMessage *entry)
-{
- LDAPMessage *msg;
-
- if ( entry == NULLMSG)
- return( NULLMSG );
-
- msg = entry->lm_chain;
- while(msg != NULLMSG){
- if (msg->lm_msgtype == LDAP_RES_SEARCH_REFERENCE)
- break;
- msg = msg->lm_chain;
- }
-
- return( msg );
-}
-
-int
-ldap_count_references( LDAP *ld, LDAPMessage *res )
-{
- int i;
-
- for ( i = 0; res != NULL; res = res->lm_chain )
- if (res->lm_msgtype == LDAP_RES_SEARCH_REFERENCE)
- i++;
-
- return( i );
-}
-
-char ** ldap_get_reference_urls(LDAP *ld, LDAPMessage *res)
-{
- BerElement tmp;
- char **urls = NULL;
-
- Debug( LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 1274, "ldap_get_reference_urls\n"), 0, 0, 0 );
-
- if (res == NULL){
- ld->ld_errno = LDAP_PARAM_ERROR;
- return (NULL);
- }
- tmp = *res->lm_ber; /* struct copy */
- if ( ber_scanf( &tmp, "{v}", &urls) == LBER_ERROR){
- ld->ld_errno = LDAP_DECODING_ERROR;
- return (NULL);
- }
- return (urls);
-}
diff --git a/usr/src/lib/libldap4/common/getvalues.c b/usr/src/lib/libldap4/common/getvalues.c
deleted file mode 100644
index b516af78fc..0000000000
--- a/usr/src/lib/libldap4/common/getvalues.c
+++ /dev/null
@@ -1,183 +0,0 @@
-/*
- *
- * Portions Copyright 1998 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- *
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*
- * Copyright (c) 1990 Regents of the University of Michigan.
- * All rights reserved.
- *
- * getvalues.c
- */
-
-#ifndef lint
-static char copyright[] = "@(#) Copyright (c) 1990 Regents of the University of Michigan.\nAll rights reserved.\n";
-#endif
-
-#include <stdio.h>
-#include <ctype.h>
-#include <string.h>
-#include <stdlib.h> /* free() for Solaris */
-#ifdef MACOS
-#include <stdlib.h>
-#include "macos.h"
-#else /* MACOS */
-#if defined( DOS ) || defined( _WIN32 )
-#include <malloc.h>
-#include "msdos.h"
-#else /* DOS */
-#include <sys/types.h>
-#include <sys/socket.h>
-#endif /* DOS */
-#endif /* MACOS */
-
-#include "lber.h"
-#include "ldap.h"
-#include "ldap-private.h"
-#include "ldap-int.h"
-
-char **
-ldap_get_values( LDAP *ld, LDAPMessage *entry, char *target )
-{
- BerElement ber;
- char attr[LDAP_MAX_ATTR_LEN];
- int found = 0;
- int len;
- char **vals;
-
- Debug( LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 184, "ldap_get_values\n"), 0, 0, 0 );
-
- ber = *entry->lm_ber;
-
- /* skip sequence, dn, sequence of, and snag the first attr */
- len = sizeof(attr);
- if ( ber_scanf( &ber, "{x{{s", attr, &len ) == LBER_ERROR ) {
- ld->ld_errno = LDAP_DECODING_ERROR;
- return( NULL );
- }
-
- if ( strcasecmp( target, attr ) == 0 )
- found = 1;
-
- /* break out on success, return out on error */
- while ( ! found ) {
- len = sizeof(attr);
- if ( ber_scanf( &ber, "x}{s", attr, &len ) == LBER_ERROR ) {
- ld->ld_errno = LDAP_DECODING_ERROR;
- return( NULL );
- }
-
- if ( strcasecmp( target, attr ) == 0 )
- break;
- }
-
- /*
- * if we get this far, we've found the attribute and are sitting
- * just before the set of values.
- */
-
- if ( ber_scanf( &ber, "[v]", &vals ) == LBER_ERROR ) {
- ld->ld_errno = LDAP_DECODING_ERROR;
- return( NULL );
- }
-
- return( vals );
-}
-
-struct berval **
-ldap_get_values_len( LDAP *ld, LDAPMessage *entry, char *target )
-{
- BerElement ber;
- char attr[LDAP_MAX_ATTR_LEN];
- int found = 0;
- int len;
- struct berval **vals;
-
- Debug( LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 185, "ldap_get_values_len\n"), 0, 0, 0 );
-
- ber = *entry->lm_ber;
-
- /* skip sequence, dn, sequence of, and snag the first attr */
- len = sizeof(attr);
- if ( ber_scanf( &ber, "{x{{s", attr, &len ) == LBER_ERROR ) {
- ld->ld_errno = LDAP_DECODING_ERROR;
- return( NULL );
- }
-
- if ( strcasecmp( target, attr ) == 0 )
- found = 1;
-
- /* break out on success, return out on error */
- while ( ! found ) {
- len = sizeof(attr);
- if ( ber_scanf( &ber, "x}{s", attr, &len ) == LBER_ERROR ) {
- ld->ld_errno = LDAP_DECODING_ERROR;
- return( NULL );
- }
-
- if ( strcasecmp( target, attr ) == 0 )
- break;
- }
-
- /*
- * if we get this far, we've found the attribute and are sitting
- * just before the set of values.
- */
-
- if ( ber_scanf( &ber, "[V]", &vals ) == LBER_ERROR ) {
- ld->ld_errno = LDAP_DECODING_ERROR;
- return( NULL );
- }
-
- return( vals );
-}
-
-int
-ldap_count_values( char **vals )
-{
- int i;
-
- if ( vals == NULL )
- return( 0 );
-
- for ( i = 0; vals[i] != NULL; i++ )
- ; /* NULL */
-
- return( i );
-}
-
-int
-ldap_count_values_len( struct berval **vals )
-{
- return( ldap_count_values( (char **) vals ) );
-}
-
-void
-ldap_value_free( char **vals )
-{
- int i;
-
- if ( vals == NULL )
- return;
- for ( i = 0; vals[i] != NULL; i++ )
- free( vals[i] );
- free( (char *) vals );
-}
-
-void
-ldap_value_free_len( struct berval **vals )
-{
- int i;
-
- if ( vals == NULL )
- return;
- for ( i = 0; vals[i] != NULL; i++ ) {
- free( vals[i]->bv_val );
- free( vals[i] );
- }
- free( (char *) vals );
-}
diff --git a/usr/src/lib/libldap4/common/kbind.c b/usr/src/lib/libldap4/common/kbind.c
deleted file mode 100644
index 5cc6928eca..0000000000
--- a/usr/src/lib/libldap4/common/kbind.c
+++ /dev/null
@@ -1,349 +0,0 @@
-/*
- * Portions Copyright 1998 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*
- * Copyright (c) 1993 Regents of the University of Michigan.
- * All rights reserved.
- *
- * kbind.c
- */
-
-#ifndef lint
-static char copyright[] = "@(#) Copyright (c) 1993 Regents of the University of Michigan.\nAll rights reserved.\n";
-#endif
-
-#ifdef KERBEROS
-
-#include <stdio.h>
-#include <string.h>
-
-#ifdef MACOS
-#include <stdlib.h>
-#include "macos.h"
-#else /* MACOS */
-#ifdef DOS
-#include "msdos.h"
-#endif /* DOS */
-#include <krb.h>
-#include <stdlib.h>
-#if !defined(DOS) && !defined( _WIN32 )
-#include <sys/types.h>
-#endif /* !DOS && !_WIN32 */
-#include <sys/time.h>
-#include <sys/socket.h>
-#endif /* MACOS */
-
-#include "lber.h"
-#include "ldap.h"
-#include "ldap-private.h"
-#include "ldap-int.h"
-
-
-
-/*
- * ldap_kerberos_bind1 - initiate a bind to the ldap server using
- * kerberos authentication. The dn is supplied. It is assumed the user
- * already has a valid ticket granting ticket. The msgid of the
- * request is returned on success (suitable for passing to ldap_result()),
- * -1 is returned if there's trouble.
- *
- * Example:
- * ldap_kerberos_bind1( ld, "cn=manager, o=university of michigan, c=us" )
- */
-int
-ldap_kerberos_bind1( LDAP *ld, char *dn )
-{
- BerElement *ber;
- char *cred;
- int rc, credlen;
- char *get_kerberosv4_credentials();
-#ifdef STR_TRANSLATION
- int str_translation_on;
-#endif /* STR_TRANSLATION */
-
- /*
- * The bind request looks like this:
- * BindRequest ::= SEQUENCE {
- * version INTEGER,
- * name DistinguishedName,
- * authentication CHOICE {
- * krbv42ldap [1] OCTET STRING
- * krbv42dsa [2] OCTET STRING
- * }
- * }
- * all wrapped up in an LDAPMessage sequence.
- */
-
-#if defined( SUN ) && defined( _REENTRANT )
- int rv;
-
- LOCK_LDAP(ld);
-#endif
- Debug( LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 186, "ldap_kerberos_bind1\n"), 0, 0, 0 );
-
- if ( dn == NULL )
- dn = "";
-
- if ( (cred = get_kerberosv4_credentials( ld, dn, "ldapserver",
- &credlen )) == NULL ) {
-#if defined( SUN ) && defined( _REENTRANT )
- UNLOCK_LDAP(ld);
-#endif
- return( -1 ); /* ld_errno should already be set */
- }
-
- /* create a message to send */
- if ( (ber = alloc_ber_with_options( ld )) == NULLBER ) {
- free( cred );
-#if defined( SUN ) && defined( _REENTRANT )
- UNLOCK_LDAP(ld);
-#endif
- return( -1 );
- }
-
-#ifdef STR_TRANSLATION
- if (( str_translation_on = (( ber->ber_options &
- LBER_TRANSLATE_STRINGS ) != 0 ))) { /* turn translation off */
- ber->ber_options &= ~LBER_TRANSLATE_STRINGS;
- }
-#endif /* STR_TRANSLATION */
-
- /* fill it in */
- rc = ber_printf( ber, "{it{isto}}", ++ld->ld_msgid, LDAP_REQ_BIND,
- ld->ld_version, dn, LDAP_AUTH_KRBV41, cred, credlen );
-
-#ifdef STR_TRANSLATION
- if ( str_translation_on ) { /* restore translation */
- ber->ber_options |= LBER_TRANSLATE_STRINGS;
- }
-#endif /* STR_TRANSLATION */
-
- if ( rc == -1 ) {
- free( cred );
- ber_free( ber, 1 );
- ld->ld_errno = LDAP_ENCODING_ERROR;
-#if defined( SUN ) && defined( _REENTRANT )
- UNLOCK_LDAP(ld);
-#endif
- return( -1 );
- }
-
- free( cred );
-
-#ifndef NO_CACHE
- if ( ld->ld_cache != NULL ) {
- ldap_flush_cache( ld );
- }
-#endif /* !NO_CACHE */
-
- /* send the message */
-#if defined( SUN ) && defined( _REENTRANT )
- rv = send_initial_request( ld, LDAP_REQ_BIND, dn, ber );
- UNLOCK_LDAP(ld);
- return ( rv );
-#else
- return ( send_initial_request( ld, LDAP_REQ_BIND, dn, ber ));
-#endif
-}
-
-int
-ldap_kerberos_bind1_s( LDAP *ld, char *dn )
-{
- int msgid;
- LDAPMessage *res;
-
- Debug( LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 187, "ldap_kerberos_bind1_s\n"), 0, 0, 0 );
-
- /* initiate the bind */
- if ( (msgid = ldap_kerberos_bind1( ld, dn )) == -1 )
- return( ld->ld_errno );
-
- /* wait for a result */
- if ( ldap_result( ld, ld->ld_msgid, 1, (struct timeval *) 0, &res )
- == -1 ) {
- return( ld->ld_errno ); /* ldap_result sets ld_errno */
- }
-
- return( ldap_result2error( ld, res, 1 ) );
-}
-
-/*
- * ldap_kerberos_bind2 - initiate a bind to the X.500 server using
- * kerberos authentication. The dn is supplied. It is assumed the user
- * already has a valid ticket granting ticket. The msgid of the
- * request is returned on success (suitable for passing to ldap_result()),
- * -1 is returned if there's trouble.
- *
- * Example:
- * ldap_kerberos_bind2( ld, "cn=manager, o=university of michigan, c=us" )
- */
-int
-ldap_kerberos_bind2( LDAP *ld, char *dn )
-{
- BerElement *ber;
- char *cred;
- int rc, credlen;
- char *get_kerberosv4_credentials();
-#ifdef STR_TRANSLATION
- int str_translation_on;
-#endif /* STR_TRANSLATION */
-
-#if defined( SUN ) && defined( _REENTRANT )
- int rv;
-
- LOCK_LDAP(ld);
-#endif
- Debug( LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 188, "ldap_kerberos_bind2\n"), 0, 0, 0 );
-
- if ( dn == NULL )
- dn = "";
-
- if ( (cred = get_kerberosv4_credentials( ld, dn, "x500dsa", &credlen ))
- == NULL ) {
-#if defined( SUN ) && defined( _REENTRANT )
- UNLOCK_LDAP(ld);
-#endif
- return( -1 ); /* ld_errno should already be set */
- }
-
- /* create a message to send */
- if ( (ber = alloc_ber_with_options( ld )) == NULLBER ) {
- free( cred );
-#if defined( SUN ) && defined( _REENTRANT )
- UNLOCK_LDAP(ld);
-#endif
- return( -1 );
- }
-
-#ifdef STR_TRANSLATION
- if (( str_translation_on = (( ber->ber_options &
- LBER_TRANSLATE_STRINGS ) != 0 ))) { /* turn translation off */
- ber->ber_options &= ~LBER_TRANSLATE_STRINGS;
- }
-#endif /* STR_TRANSLATION */
-
- /* fill it in */
- rc = ber_printf( ber, "{it{isto}}", ++ld->ld_msgid, LDAP_REQ_BIND,
- ld->ld_version, dn, LDAP_AUTH_KRBV42, cred, credlen );
-
-
-#ifdef STR_TRANSLATION
- if ( str_translation_on ) { /* restore translation */
- ber->ber_options |= LBER_TRANSLATE_STRINGS;
- }
-#endif /* STR_TRANSLATION */
-
- free( cred );
-
- if ( rc == -1 ) {
- ber_free( ber, 1 );
- ld->ld_errno = LDAP_ENCODING_ERROR;
-#if defined( SUN ) && defined( _REENTRANT )
- UNLOCK_LDAP(ld);
-#endif
- return( -1 );
- }
-
- /* send the message */
-#if defined( SUN ) && defined( _REENTRANT )
- rv = send_initial_request( ld, LDAP_REQ_BIND, dn, ber );
- UNLOCK_LDAP(ld);
- return ( rv );
-#endif
- return ( send_initial_request( ld, LDAP_REQ_BIND, dn, ber ));
-}
-
-/* synchronous bind to DSA using kerberos */
-int
-ldap_kerberos_bind2_s( LDAP *ld, char *dn )
-{
- int msgid;
- LDAPMessage *res;
-
- Debug( LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 189, "ldap_kerberos_bind2_s\n"), 0, 0, 0 );
-
- /* initiate the bind */
- if ( (msgid = ldap_kerberos_bind2( ld, dn )) == -1 )
- return( ld->ld_errno );
-
- /* wait for a result */
- if ( ldap_result( ld, ld->ld_msgid, 1, (struct timeval *) 0, &res )
- == -1 ) {
- return( ld->ld_errno ); /* ldap_result sets ld_errno */
- }
-
- return( ldap_result2error( ld, res, 1 ) );
-}
-
-/* synchronous bind to ldap and DSA using kerberos */
-int
-ldap_kerberos_bind_s( LDAP *ld, char *dn )
-{
- int err;
-
- Debug( LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 190, "ldap_kerberos_bind_s\n"), 0, 0, 0 );
-
- if ( (err = ldap_kerberos_bind1_s( ld, dn )) != LDAP_SUCCESS )
- return( err );
-
- return( ldap_kerberos_bind2_s( ld, dn ) );
-}
-
-
-#ifndef AUTHMAN
-/*
- * get_kerberosv4_credentials - obtain kerberos v4 credentials for ldap.
- * The dn of the entry to which to bind is supplied. It's assumed the
- * user already has a tgt.
- */
-
-char *
-get_kerberosv4_credentials( LDAP *ld, char *who, char *service, int *len )
-{
- KTEXT_ST ktxt;
- int err;
- char realm[REALM_SZ], *cred, *krbinstance;
-
- Debug( LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 191, "get_kerberosv4_credentials\n"), 0, 0, 0 );
-
- if ( (err = krb_get_tf_realm( tkt_string(), realm )) != KSUCCESS ) {
-#ifndef NO_USERINTERFACE
- fprintf( stderr, "krb_get_tf_realm failed (%s)\n",
- krb_err_txt[err] );
-#endif /* NO_USERINTERFACE */
- ld->ld_errno = LDAP_INVALID_CREDENTIALS;
- return( NULL );
- }
-
-#ifdef LDAP_REFERRALS
- krbinstance = ld->ld_defconn->lconn_krbinstance;
-#else /* LDAP_REFERRALS */
- krbinstance = ld->ld_host;
-#endif /* LDAP_REFERRALS */
-
- if ( (err = krb_mk_req( &ktxt, service, krbinstance, realm, 0 ))
- != KSUCCESS ) {
-#ifndef NO_USERINTERFACE
- fprintf( stderr, "krb_mk_req failed (%s)\n", krb_err_txt[err] );
-#endif /* NO_USERINTERFACE */
- ld->ld_errno = LDAP_INVALID_CREDENTIALS;
- return( NULL );
- }
-
- if ( ( cred = malloc( ktxt.length )) == NULL ) {
- ld->ld_errno = LDAP_NO_MEMORY;
- return( NULL );
- }
-
- *len = ktxt.length;
- memcpy( cred, ktxt.dat, ktxt.length );
-
- return( cred );
-}
-
-#endif /* !AUTHMAN */
-#endif /* KERBEROS */
diff --git a/usr/src/lib/libldap4/common/llib-lldap b/usr/src/lib/libldap4/common/llib-lldap
deleted file mode 100644
index 2d0b9e947c..0000000000
--- a/usr/src/lib/libldap4/common/llib-lldap
+++ /dev/null
@@ -1,317 +0,0 @@
-/* LINTLIBRARY */
-/* PROTOLIB1 */
-
-/*
- * Copyright (c) 1997 by Sun Microsystems, Inc.
- * All rights reserved.
- */
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#include <stdio.h>
-#include <sys/types.h>
-#include <lber.h>
-#include <ldap.h>
-
-/*
- * /usr/src/lib/libldap routines
- */
-
-
-/*
- * in abandon.c:
- */
-int ldap_abandon_ext(LDAP *ld, int msgid, LDAPControl **serverctrls, LDAPControl ** clientctrls);
-int ldap_abandon( LDAP *ld, int msgid );
-
-/*
- * in add.c:
- */
-int ldap_add_ext( LDAP *ld, char *dn, LDAPMod **attrs, LDAPControl ** serverctrls, LDAPControl **clientctrls, int *msgidp);
-int ldap_add_ext_s( LDAP *ld, char *dn, LDAPMod **attrs, LDAPControl ** serverctrls, LDAPControl **clientctrls);
-int ldap_add( LDAP *ld, char *dn, LDAPMod **attrs );
-int ldap_add_s( LDAP *ld, char *dn, LDAPMod **attrs );
-
-/*
- * in bind.c:
- */
-
-/*
- * in sbind.c:
- */
-int ldap_simple_bind( LDAP *ld, char *who, char *passwd );
-int ldap_simple_bind_s( LDAP *ld, char *who, char *passwd );
-
-/*
- * in saslbind.c:
- */
-int ldap_sasl_bind(LDAP *ld, char *dn, char *mechanism, struct berval *cred, LDAPControl **serverctrls, LDAPControl **clientctrls, int *msgidp);
-int ldap_sasl_bind_s(LDAP *ld, char *dn, char *mechanism, struct berval *cred, LDAPControl **serverctrls, LDAPControl **clientctrls, struct berval **servercredp);
-
-/*
- * in kbind.c:
- */
-
-#ifndef NO_CACHE
-/*
- * in cache.c
- */
-int ldap_enable_cache( LDAP *ld, time_t timeout, ssize_t maxmem );
-void ldap_disable_cache( LDAP *ld );
-void ldap_set_cache_options( LDAP *ld, unsigned int opts );
-void ldap_destroy_cache( LDAP *ld );
-void ldap_flush_cache( LDAP *ld );
-void ldap_uncache_entry( LDAP *ld, char *dn );
-void ldap_uncache_request( LDAP *ld, int msgid );
-#endif /* !NO_CACHE */
-
-/*
- * in compare.c:
- */
-int ldap_compare_ext(LDAP *ld, char *dn, char *attr, struct berval *bvalue, LDAPControl ** serverctrls, LDAPControl **clientctrls, int *msgidp);
-int ldap_compare_ext_s(LDAP *ld, char *dn, char *attr, struct berval *bvalue, LDAPControl ** serverctrls, LDAPControl **clientctrls) ;
-int ldap_compare( LDAP *ld, char *dn, char *attr, char *value );
-int ldap_compare_s( LDAP *ld, char *dn, char *attr, char *value );
-
-/*
- * in delete.c:
- */
-int ldap_delete_ext(LDAP *ld, char *dn, LDAPControl **serverctrls, LDAPControl **clientctrls, int *msgidp);
-int ldap_delete_ext_s(LDAP *ld, char *dn, LDAPControl **serverctrls, LDAPControl **clientctrls);
-int ldap_delete( LDAP *ld, char *dn );
-int ldap_delete_s( LDAP *ld, char *dn );
-
-/*
- * in error.c:
- */
-char *ldap_err2string( int err );
-
-
-/*
- * in modify.c:
- */
-int ldap_modify_ext(LDAP *ld, char *dn, LDAPMod **mods, LDAPControl **serverctrls, LDAPControl **clientctrls, int *msgidp);
-int ldap_modify_ext_s(LDAP *ld, char *dn, LDAPMod **mods, LDAPControl **serverctrls, LDAPControl **clientctrls) ;
-int ldap_modify( LDAP *ld, char *dn, LDAPMod **mods );
-int ldap_modify_s( LDAP *ld, char *dn, LDAPMod **mods );
-
-/*
- * in modrdn.c:
- */
-
-/*
- * in rename.c:
- */
-int ldap_rename(LDAP *ld, char *dn, char *newrdn, char *newparent, int deleteoldrdn, LDAPControl ** serverctrls, LDAPControl **clientctrls, int *msgidp);
-int ldap_rename_s(LDAP *ld, char *dn, char *newrdn, char *newparent, int deleteoldrdn, LDAPControl ** serverctrls, LDAPControl **clientctrls);
-
-/*
- * in open.c:
- */
-LDAP *ldap_init( char *defhost, int defport );
-
-
-#ifdef LDAP_SSL
-LDAP *ldap_ssl_init(char *defhost, int defport, char *keyname );
-#endif
-
-/*
- * in getentry.c:
- */
-LDAPMessage *ldap_first_entry( LDAP *ld, LDAPMessage *res );
-LDAPMessage *ldap_next_entry( LDAP *ld, LDAPMessage *entry );
-int ldap_count_entries( LDAP *ld, LDAPMessage *res );
-
-/*
- * in getmsg.c:
- */
-LDAPMessage *ldap_first_message( LDAP *ld, LDAPMessage *res );
-LDAPMessage *ldap_next_message( LDAP *ld, LDAPMessage *msg );
-int ldap_count_messages( LDAP *ld, LDAPMessage *res );
-
-/*
- * in getref.c:
- */
-LDAPMessage *ldap_first_reference( LDAP *ld, LDAPMessage *res );
-LDAPMessage *ldap_next_reference( LDAP *ld, LDAPMessage *msg );
-int ldap_count_references( LDAP *ld, LDAPMessage *res );
-char ** ldap_get_reference_urls( LDAP *ld, LDAPMessage *res );
-
-/*
- * in addentry.c
- */
-LDAPMessage *ldap_delete_result_entry( LDAPMessage **list,
- LDAPMessage *e );
-void ldap_add_result_entry( LDAPMessage **list, LDAPMessage *e );
-
-/*
- * in getdn.c
- */
-char *ldap_get_dn( LDAP *ld, LDAPMessage *entry );
-char **ldap_explode_dn( char *dn, int notypes );
-char ** ldap_explode_rdn( char *rdn, int notypes );
-char *ldap_dn2ufn( char *dn );
-
-char **ldap_explode_dns( char *dn );
-int ldap_is_dns_dn( char *dn );
-char *ldap_dns_to_dn(char *dns_name, int *nameparts);
-
-/*
- * in getattr.c
- */
-char *ldap_first_attribute( LDAP *ld, LDAPMessage *entry,
- BerElement **ber );
-char *ldap_next_attribute( LDAP *ld, LDAPMessage *entry,
- BerElement *ber );
-void ldap_memfree(char *mem);
-
-/*
- * in getvalues.c
- */
-char **ldap_get_values( LDAP *ld, LDAPMessage *entry, char *target );
-struct berval **ldap_get_values_len( LDAP *ld, LDAPMessage *entry,
- char *target );
-int ldap_count_values( char **vals );
-int ldap_count_values_len( struct berval **vals );
-void ldap_value_free( char **vals );
-void ldap_value_free_len( struct berval **vals );
-
-/*
- * in result.c:
- */
-int ldap_result( LDAP *ld, int msgid, int all,
- struct timeval *timeout, LDAPMessage **result );
-int ldap_msgdelete( LDAP *ld, int msgid );
-int ldap_msgfree( LDAPMessage *lm );
-int ldap_msgtype( LDAPMessage *res );
-int ldap_msgid( LDAPMessage *res );
-int ldap_parse_result(LDAP *ld, LDAPMessage *res, int *errcodep, char **matcheddnp, char **errmsgp, char ***referralsp, LDAPControl ***serverctrlsp, int freeit) ;
-int ldap_parse_sasl_bind_result(LDAP *ld, LDAPMessage *res, struct berval **servercredp, int freeit);
-int ldap_parse_extended_result(LDAP *ld, LDAPMessage *res, char **resultoidp, struct berval **resultdata, int freeit);
-
-/*
- * in search.c:
- */
-int ldap_search_ext(LDAP *ld, char *base, int scope, char *filter, char **attrs, int attrsonly, LDAPControl **serverctrls, LDAPControl **clientctrls, struct timeval *timeoutp, int sizelimit, int *msgidp);
-int ldap_search_ext_s(LDAP *ld, char *base, int scope, char *filter, char **attrs, int attrsonly, LDAPControl **serverctrls, LDAPControl **clientctrls, struct timeval *timeoutp, int sizelimit, LDAPMessage **res);
-
-int ldap_search( LDAP *ld, char *base, int scope, char *filter,
- char **attrs, int attrsonly );
-int ldap_search_s( LDAP *ld, char *base, int scope, char *filter,
- char **attrs, int attrsonly, LDAPMessage **res );
-int ldap_search_st( LDAP *ld, char *base, int scope, char *filter,
- char **attrs, int attrsonly, struct timeval *timeout, LDAPMessage **res );
-
-/*
- * in ufn.c
- */
-int ldap_ufn_search_c( LDAP *ld, char *ufn, char **attrs,
- int attrsonly, LDAPMessage **res, int (*cancelproc)( void *cl ),
- void *cancelparm );
-int ldap_ufn_search_ct( LDAP *ld, char *ufn, char **attrs,
- int attrsonly, LDAPMessage **res, int (*cancelproc)( void *cl ),
- void *cancelparm, char *tag1, char *tag2, char *tag3 );
-int ldap_ufn_search_s( LDAP *ld, char *ufn, char **attrs,
- int attrsonly, LDAPMessage **res );
-LDAPFiltDesc *ldap_ufn_setfilter( LDAP *ld, char *fname );
-void ldap_ufn_setprefix( LDAP *ld, char *prefix );
-int ldap_ufn_timeout( void *tvparam );
-
-
-/*
- * in unbind.c
- */
-int ldap_unbind( LDAP *ld );
-int ldap_unbind_s( LDAP *ld );
-
-
-/*
- * in getfilter.c
- */
-LDAPFiltDesc *ldap_init_getfilter( char *fname );
-LDAPFiltDesc *ldap_init_getfilter_buf( char *buf, ssize_t buflen );
-LDAPFiltInfo *ldap_getfirstfilter( LDAPFiltDesc *lfdp, char *tagpat,
- char *value );
-LDAPFiltInfo *ldap_getnextfilter( LDAPFiltDesc *lfdp );
-void ldap_setfilteraffixes( LDAPFiltDesc *lfdp, char *prefix, char *suffix );
-void ldap_build_filter( char *buf, size_t buflen,
- char *pattern, char *prefix, char *suffix, char *attr,
- char *value, char **valwords );
-
-/*
- * in free.c
- */
-void ldap_getfilter_free( LDAPFiltDesc *lfdp );
-void ldap_mods_free( LDAPMod **mods, int freemods );
-
-/*
- * in friendly.c
- */
-char *ldap_friendly_name( char *filename, char *uname,
- FriendlyMap **map );
-void ldap_free_friendlymap( FriendlyMap **map );
-
-
-/*
- * in cldap.c
- */
-LDAP *cldap_open( char *host, int port );
-void cldap_close( LDAP *ld );
-int cldap_search_s( LDAP *ld, char *base, int scope, char *filter,
- char **attrs, int attrsonly, LDAPMessage **res, char *logdn );
-void cldap_setretryinfo( LDAP *ld, int tries, time_t timeout );
-
-
-/*
- * in sort.c
- */
-int ldap_sort_entries( LDAP *ld, LDAPMessage **chain, char *attr,
- int (*cmp)() );
-int ldap_sort_values( LDAP *ld, char **vals, int (*cmp)() );
-int ldap_sort_strcasecmp( char **a, char **b );
-
-
-/*
- * in url.c
- */
-int ldap_is_ldap_url( char *url );
-int ldap_url_parse( char *url, LDAPURLDesc **ludpp );
-void ldap_free_urlexts( LDAPURLExt **lues );
-void ldap_free_urldesc( LDAPURLDesc *ludp );
-int ldap_url_search( LDAP *ld, char *url, int attrsonly );
-int ldap_url_search_s( LDAP *ld, char *url, int attrsonly,
- LDAPMessage **res );
-int ldap_url_search_st( LDAP *ld, char *url, int attrsonly,
- struct timeval *timeout, LDAPMessage **res );
-char *ldap_dns_to_url(LDAP *ld, char *dns_name, char *attrs,
-char *scope, char *filter);
-char *ldap_dn_to_url(LDAP *ld, char *dn, int nameparts);
-
-
-/*
- * in charset.c
- */
-#ifdef STR_TRANSLATION
-void ldap_set_string_translators( LDAP *ld,
- BERTranslateProc encode_proc, BERTranslateProc decode_proc );
-int ldap_translate_from_t61( LDAP *ld, char **bufp,
- unsigned int *lenp, int free_input );
-int ldap_translate_to_t61( LDAP *ld, char **bufp,
- unsigned int *lenp, int free_input );
-void ldap_enable_translation( LDAP *ld, LDAPMessage *entry,
- int enable );
-
-#ifdef LDAP_CHARSET_8859
-int ldap_t61_to_8859( char **bufp, unsigned int *buflenp,
- int free_input );
-int ldap_8859_to_t61( char **bufp, unsigned int *buflenp,
- int free_input );
-#endif /* LDAP_CHARSET_8859 */
-#endif /* STR_TRANSLATION */
-
-
-#ifdef WINSOCK
-/*
- * in msdos/winsock/wsa.c
- */
-void ldap_memfree( void *p );
-#endif /* WINSOCK */
diff --git a/usr/src/lib/libldap4/common/mapfile-vers b/usr/src/lib/libldap4/common/mapfile-vers
deleted file mode 100644
index 66b2a61087..0000000000
--- a/usr/src/lib/libldap4/common/mapfile-vers
+++ /dev/null
@@ -1,229 +0,0 @@
-#
-# CDDL HEADER START
-#
-# The contents of this file are subject to the terms of the
-# Common Development and Distribution License (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) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
-#
-
-#
-# MAPFILE HEADER START
-#
-# WARNING: STOP NOW. DO NOT MODIFY THIS FILE.
-# Object versioning must comply with the rules detailed in
-#
-# usr/src/lib/README.mapfiles
-#
-# You should not be making modifications here until you've read the most current
-# copy of that file. If you need help, contact a gatekeeper for guidance.
-#
-# MAPFILE HEADER END
-#
-
-$mapfile_version 2
-
-SYMBOL_VERSION SUNW_1.2 {
- global:
- ber_alloc;
- ber_get_int;
-} SUNW_1.1;
-
-SYMBOL_VERSION SUNW_1.1 {
- global:
- ber_alloc_t;
- ber_bvdup;
- ber_bvecfree;
- ber_bvfree;
- ber_first_element;
- ber_flatten;
- ber_free;
- ber_init;
- ber_next_element;
- ber_peek_tag;
- ber_printf;
- ber_scanf;
- ber_skip_tag;
- cldap_close;
- cldap_open;
- cldap_search_s;
- cldap_setretryinfo;
- ldap_abandon;
- ldap_abandon_ext;
- ldap_add;
- ldap_add_ext;
- ldap_add_ext_s;
- ldap_add_s;
- ldap_bind;
- ldap_bind_s;
- ldap_build_filter;
- ldap_compare;
- ldap_compare_ext;
- ldap_compare_ext_s;
- ldap_compare_s;
- ldap_control_free;
- ldap_controls_free;
- ldap_count_entries;
- ldap_count_messages;
- ldap_count_references;
- ldap_count_values;
- ldap_count_values_len;
- ldap_create_sort_control;
- ldap_create_sort_keylist;
- ldap_create_virtuallist_control;
- ldap_delete;
- ldap_delete_ext;
- ldap_delete_ext_s;
- ldap_delete_s;
- ldap_destroy_cache;
- ldap_disable_cache;
- ldap_dn2ufn;
- ldap_dns_to_dn;
- ldap_dns_to_url;
- ldap_dn_to_url;
- ldap_enable_cache;
- ldap_enable_translation;
- ldap_entry2html;
- ldap_entry2html_search;
- ldap_entry2text;
- ldap_entry2text_search;
- ldap_err2string;
- ldap_explode_dn;
- ldap_explode_dns;
- ldap_explode_rdn;
- ldap_extended_operation;
- ldap_extended_operation_s;
- ldap_first_attribute;
- ldap_first_disptmpl;
- ldap_first_entry;
- ldap_first_message;
- ldap_first_reference;
- ldap_first_searchobj;
- ldap_first_tmplcol;
- ldap_first_tmplrow;
- ldap_flush_cache;
- ldap_free_friendlymap;
- ldap_free_searchprefs;
- ldap_free_sort_keylist;
- ldap_free_templates;
- ldap_free_urldesc;
- ldap_friendly_name;
- ldap_get_dn;
- ldap_getfilter_free;
- ldap_getfirstfilter;
- ldap_getnextfilter;
- ldap_get_option;
- ldap_get_values;
- ldap_get_values_len;
- ldap_init;
- ldap_init_getfilter;
- ldap_init_getfilter_buf;
- ldap_init_searchprefs;
- ldap_init_searchprefs_buf;
- ldap_init_templates;
- ldap_init_templates_buf;
- ldap_is_dns_dn;
- ldap_is_ldap_url;
- ldap_memfree;
- ldap_modify;
- ldap_modify_ext;
- ldap_modify_ext_s;
- ldap_modify_s;
- ldap_modrdn;
- ldap_modrdn_s;
- ldap_mods_free;
- ldap_msgfree;
- ldap_msgid;
- ldap_msgtype;
- ldap_next_attribute;
- ldap_next_disptmpl;
- ldap_next_entry;
- ldap_next_message;
- ldap_next_reference;
- ldap_next_searchobj;
- ldap_next_tmplcol;
- ldap_next_tmplrow;
- ldap_oc2template;
- ldap_open;
- ldap_parse_extended_result;
- ldap_parse_result;
- ldap_parse_sasl_bind_result;
- ldap_parse_sort_control;
- ldap_parse_virtuallist_control;
- ldap_perror;
- ldap_rename;
- ldap_rename_s;
- ldap_result;
- ldap_result2error;
- ldap_sasl_bind;
- ldap_sasl_bind_s;
- ldap_sasl_cram_md5_bind_s;
- ldap_search;
- ldap_search_ext;
- ldap_search_ext_s;
- ldap_search_s;
- ldap_search_st;
- ldap_set_cache_options;
- ldap_setfilteraffixes;
- ldap_set_option;
- ldap_set_rebind_proc;
- ldap_set_string_translators;
- ldap_simple_bind;
- ldap_simple_bind_s;
- ldap_sort_entries;
- ldap_sort_strcasecmp;
- ldap_sort_values;
- ldap_tmplattrs;
- ldap_translate_from_t61;
- ldap_translate_to_t61;
- ldap_ufn_search_c;
- ldap_ufn_search_ct;
- ldap_ufn_search_s;
- ldap_ufn_setfilter;
- ldap_ufn_setprefix;
- ldap_ufn_timeout;
- ldap_unbind;
- ldap_unbind_s;
- ldap_uncache_entry;
- ldap_uncache_request;
- ldap_url_parse;
- ldap_url_search;
- ldap_url_search_s;
- ldap_url_search_st;
- ldap_vals2html;
- ldap_vals2text;
- ldap_value_free;
- ldap_value_free_len;
- open_default_ldap_connection;
- set_ber_options;
-};
-
-SYMBOL_VERSION SUNWprivate_1.1 {
- global:
- i18n_catopen;
- ldap_create_page_control;
- ldap_get_reference_urls;
- ldaplogconfigf;
- ldap_parse_page_control;
- ldif_type_and_value;
- slapdcat;
- str_getline;
- str_parse_line;
- local:
- *;
-};
diff --git a/usr/src/lib/libldap4/common/modify.c b/usr/src/lib/libldap4/common/modify.c
deleted file mode 100644
index 4fb1d6c775..0000000000
--- a/usr/src/lib/libldap4/common/modify.c
+++ /dev/null
@@ -1,246 +0,0 @@
-/*
- * Portions Copyright 1998 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*
- * Copyright (c) 1990 Regents of the University of Michigan.
- * All rights reserved.
- *
- * modify.c
- */
-
-#ifndef lint
-static char copyright[] = "@(#) Copyright (c) 1990 Regents of the University of Michigan.\nAll rights reserved.\n";
-#endif
-
-#include <stdio.h>
-#include <string.h>
-
-#ifdef MACOS
-#include "macos.h"
-#endif /* MACOS */
-
-#if !defined( MACOS ) && !defined( DOS )
-#include <sys/types.h>
-#include <sys/socket.h>
-#endif
-
-#include "lber.h"
-#include "ldap.h"
-#include "ldap-private.h"
-#include "ldap-int.h"
-
-BerElement * ldap_build_modify_req(LDAP *ld, char *dn, LDAPMod ** mods, LDAPControl **serverctrls)
-{
- BerElement *ber;
- int i, rc;
-
- /*
- * A modify request looks like this:
- * ModifyRequest ::= SEQUENCE {
- * object DistinguishedName,
- * modifications SEQUENCE OF SEQUENCE {
- * operation ENUMERATED {
- * add (0),
- * delete (1),
- * replace (2)
- * },
- * modification SEQUENCE {
- * type AttributeType,
- * values SET OF AttributeValue
- * }
- * }
- * }
- */
- /* create a message to send */
- if ( (ber = alloc_ber_with_options( ld )) == NULLBER ) {
- return( NULLBER );
- }
- if ( ber_printf( ber, "{it{s{", ++ld->ld_msgid, LDAP_REQ_MODIFY, dn )
- == -1 ) {
- ld->ld_errno = LDAP_ENCODING_ERROR;
- ber_free( ber, 1 );
- return( NULLBER );
- }
-
- /* for each modification to be performed... */
- for ( i = 0; mods[i] != NULL; i++ ) {
- if (( mods[i]->mod_op & LDAP_MOD_BVALUES) != 0 ) {
- rc = ber_printf( ber, "{e{s[V]}}",
- mods[i]->mod_op & ~LDAP_MOD_BVALUES,
- mods[i]->mod_type, mods[i]->mod_bvalues );
- } else {
- rc = ber_printf( ber, "{e{s[v]}}", mods[i]->mod_op,
- mods[i]->mod_type, mods[i]->mod_values );
- }
-
- if ( rc == -1 ) {
- ld->ld_errno = LDAP_ENCODING_ERROR;
- ber_free( ber, 1 );
- return( NULLBER );
- }
- }
-
- if ( ber_printf( ber, "}}" ) == -1 ) {
- ld->ld_errno = LDAP_ENCODING_ERROR;
- ber_free( ber, 1 );
- return( NULLBER );
- }
-
- /* LDAPv3 */
- /* Code controls if any */
- if (serverctrls && serverctrls[0]) {
- if (ldap_controls_code(ber, serverctrls) != LDAP_SUCCESS){
- ld->ld_errno = LDAP_ENCODING_ERROR;
- ber_free( ber, 1 );
- return( NULLBER );
- }
- } else if (ld->ld_srvctrls && ld->ld_srvctrls[0]) {
- /* Otherwise, is there any global server ctrls ? */
- if (ldap_controls_code(ber, ld->ld_srvctrls) != LDAP_SUCCESS){
- ld->ld_errno = LDAP_ENCODING_ERROR;
- ber_free( ber, 1 );
- return( NULLBER );
- }
- }
-
- if ( ber_printf( ber, "}" ) == -1 ) {
- ld->ld_errno = LDAP_ENCODING_ERROR;
- ber_free( ber, 1 );
- return( NULLBER );
- }
- return (ber);
-}
-
-/*
- * ldap_modify - initiate an ldap (and X.500) modify operation. Parameters:
- *
- * ld LDAP descriptor
- * dn DN of the object to modify
- * mods List of modifications to make. This is null-terminated
- * array of struct ldapmod's, specifying the modifications
- * to perform.
- *
- * Example:
- * LDAPMod *mods[] = {
- * { LDAP_MOD_ADD, "cn", { "babs jensen", "babs", 0 } },
- * { LDAP_MOD_REPLACE, "sn", { "jensen", 0 } },
- * 0
- * }
- * msgid = ldap_modify( ld, dn, mods );
- */
-int
-ldap_modify( LDAP *ld, char *dn, LDAPMod **mods )
-{
- BerElement *ber;
- int rv;
-
-#ifdef _REENTRANT
- LOCK_LDAP(ld);
-#endif
-
- Debug( LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 192, "ldap_modify\n"), 0, 0, 0 );
-
- if ((ber = ldap_build_modify_req(ld, dn, mods, NULL)) == NULLBER){
-#ifdef _REENTRANT
- UNLOCK_LDAP(ld);
-#endif
- return (-1);
- }
-
- /* send the message */
- rv = send_initial_request( ld, LDAP_REQ_MODIFY, dn, ber );
-#ifdef _REENTRANT
- UNLOCK_LDAP(ld);
-#endif
- return ( rv );
-}
-
-int
-ldap_modify_s( LDAP *ld, char *dn, LDAPMod **mods )
-{
- int msgid;
- LDAPMessage *res;
-
- if ( (msgid = ldap_modify( ld, dn, mods )) == -1 )
- return( ld->ld_errno );
-
- if ( ldap_result( ld, msgid, 1, (struct timeval *) NULL, &res ) == -1 )
- return( ld->ld_errno );
-
- return( ldap_result2error( ld, res, 1 ) );
-}
-
-/* ldapv3 API extensions */
-
-int ldap_modify_ext(LDAP *ld, char *dn, LDAPMod **mods,
- LDAPControl **serverctrls, LDAPControl **clientctrls, int *msgidp)
-{
- BerElement *ber;
- int i, rc;
- int rv;
-
-#ifdef _REENTRANT
- LOCK_LDAP(ld);
-#endif
-
- Debug( LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 192, "ldap_modify\n"), 0, 0, 0 );
-
- if ((ber = ldap_build_modify_req(ld, dn, mods, serverctrls)) == NULLBER){
- rv = ld->ld_errno;
- if (rv == LDAP_SUCCESS)
- rv = LDAP_OTHER;
-#ifdef _REENTRANT
- UNLOCK_LDAP(ld);
-#endif
- return (rv);
- }
-
- /* send the message */
- rv = send_initial_request( ld, LDAP_REQ_MODIFY, dn, ber );
- if (rv == -1){
- rv = ld->ld_errno;
- if (rv == LDAP_SUCCESS){
- rv = LDAP_OTHER;
- }
-#ifdef _REENTRANT
- UNLOCK_LDAP(ld);
-#endif
- return (rv);
- }
- *msgidp = rv;
-#ifdef _REENTRANT
- UNLOCK_LDAP(ld);
-#endif
- return ( LDAP_SUCCESS );
-}
-
-
-int ldap_modify_ext_s(LDAP *ld, char *dn, LDAPMod **mods,
- LDAPControl **serverctrls, LDAPControl **clientctrls)
-{
- int msgid;
- int retcode = LDAP_SUCCESS;
- LDAPMessage *res;
-
- if ((retcode = ldap_modify_ext(ld, dn, mods, serverctrls, clientctrls, &msgid)) != LDAP_SUCCESS)
- return (retcode);
- if (ldap_result(ld, msgid, 1, (struct timeval *)NULL, &res ) == -1)
- return (ld->ld_errno );
-
-#ifdef _REENTRANT
- LOCK_LDAP(ld);
-#endif
- retcode = ldap_parse_result(ld, res, &ld->ld_errno, &ld->ld_matched, &ld->ld_error,
- &ld->ld_referrals, &ld->ld_ret_ctrls, 1);
- if (retcode == LDAP_SUCCESS)
- retcode = ld->ld_errno;
-#ifdef _REENTRANT
- UNLOCK_LDAP(ld);
-#endif
- return (retcode);
-}
-
diff --git a/usr/src/lib/libldap4/common/modrdn.c b/usr/src/lib/libldap4/common/modrdn.c
deleted file mode 100644
index 3a7e1593f1..0000000000
--- a/usr/src/lib/libldap4/common/modrdn.c
+++ /dev/null
@@ -1,118 +0,0 @@
-/*
- * Portions Copyright 1998 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*
- * Copyright (c) 1990 Regents of the University of Michigan.
- * All rights reserved.
- *
- * modrdn.c
- */
-
-#ifndef lint
-static char copyright[] = "@(#) Copyright (c) 1990 Regents of the University of Michigan.\nAll rights reserved.\n";
-#endif
-
-#include <stdio.h>
-#include <string.h>
-
-#ifdef MACOS
-#include "macos.h"
-#endif /* MACOS */
-
-#if !defined( MACOS ) && !defined( DOS )
-#include <sys/types.h>
-#include <sys/socket.h>
-#endif
-
-#include "lber.h"
-#include "ldap.h"
-#include "ldap-private.h"
-#include "ldap-int.h"
-
-/*
- * ldap_modrdn - initiate an ldap (and X.500) modifyRDN operation. Parameters:
- *
- * ld LDAP descriptor
- * dn DN of the object to modify
- * newrdn RDN to give the object
- * deleteoldrdn nonzero means to delete old rdn values from the entry
- *
- * Example:
- * msgid = ldap_modrdn( ld, dn, newrdn );
- */
-int
-ldap_modrdn( LDAP *ld, char *dn, char *newrdn, int deleteoldrdn )
-{
- BerElement *ber;
- int rv;
-
- /*
- * A modify rdn request looks like this:
- * ModifyRDNRequest ::= SEQUENCE {
- * entry DistinguishedName,
- * newrdn RelativeDistinguishedName,
- * deleteoldrdn BOOLEAN
- * }
- */
-
-#ifdef _REENTRANT
- LOCK_LDAP(ld);
-#endif
- Debug( LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 193, "ldap_modrdn\n"), 0, 0, 0 );
-
- /* create a message to send */
- if ( (ber = alloc_ber_with_options( ld )) == NULLBER ) {
-#ifdef _REENTRANT
- UNLOCK_LDAP(ld);
-#endif
- return( -1 );
- }
-
- if ( ber_printf( ber, "{it{ssb}}", ++ld->ld_msgid, LDAP_REQ_MODRDN, dn,
- newrdn, deleteoldrdn ) == -1 ) {
- ld->ld_errno = LDAP_ENCODING_ERROR;
- ber_free( ber, 1 );
-#ifdef _REENTRANT
- UNLOCK_LDAP(ld);
-#endif
- return( -1 );
- }
-
- /* send the message */
- rv = send_initial_request( ld, LDAP_REQ_MODRDN, dn, ber );
-#ifdef _REENTRANT
- UNLOCK_LDAP(ld);
-#endif
- return ( rv );
-}
-
-int
-ldap_modrdn0( LDAP *ld, char *dn, char *newrdn )
-{
- return( ldap_modrdn( ld, dn, newrdn, 1 ) );
-}
-
-int
-ldap_modrdn_s( LDAP *ld, char *dn, char *newrdn, int deleteoldrdn )
-{
- int msgid;
- LDAPMessage *res;
-
- if ( (msgid = ldap_modrdn( ld, dn, newrdn, deleteoldrdn )) == -1 )
- return( ld->ld_errno );
-
- if ( ldap_result( ld, msgid, 1, (struct timeval *) NULL, &res ) == -1 )
- return( ld->ld_errno );
-
- return( ldap_result2error( ld, res, 1 ) );
-}
-
-int
-ldap_modrdn0_s( LDAP *ld, char *dn, char *newrdn )
-{
- return( ldap_modrdn_s( ld, dn, newrdn, 1 ) );
-}
diff --git a/usr/src/lib/libldap4/common/notif.c b/usr/src/lib/libldap4/common/notif.c
deleted file mode 100644
index f52cd56734..0000000000
--- a/usr/src/lib/libldap4/common/notif.c
+++ /dev/null
@@ -1,106 +0,0 @@
-/*
- *
- * Copyright 13/01/98 Sun Microsystems, Inc. All Rights Reserved
- * Comments:
- *
- */
-#pragma ident "%Z%%M% %I% %E% SMI"
-#include <stdio.h>
-#include <ctype.h>
-#include <string.h>
-#include "lber.h"
-#include "ldap.h"
-#include "ldap-private.h"
-#include "ldap-int.h"
-
-LDAPMessage *ldap_first_notif(LDAP *ld)
-{
- return ld->ld_notifs;
-}
-
-LDAPMessage *ldap_next_notif(LDAP *ld, LDAPMessage *current)
-{
- if ( current == NULLMSG )
- return NULLMSG;
- else
- return current->lm_next;
-}
-
-int ldap_reset_notif(LDAP *ld, int freeit)
-{
- LDAPMessage *L_n=NULLMSG;
- LDAPMessage *L_q=NULLMSG;
-
- if ( freeit )
- {
- for (L_n=ld->ld_notifs; L_n!=NULLMSG; L_n=L_n->lm_next)
- {
- if ( L_n->lm_next != NULLMSG )
- {
- L_q = L_n->lm_next;
- ldap_msgfree(L_n);
- L_n = L_q;
- }
- else
- {
- ldap_msgfree(L_n);
- break;
- }
- }
- }
- ld->ld_notifs = NULLMSG;
-
- return (LDAP_SUCCESS);
-}
-
-int ldap_remove_notif(LDAP *ld, LDAPMessage *notif, int freeit)
-{
- LDAPMessage *L_n=NULLMSG, *L_q=NULLMSG;
-
- for ( L_n=ld->ld_notifs; L_n!=NULLMSG; L_n=L_n->lm_next)
- {
- if ( L_n == notif)
- {
- if ( L_q == NULLMSG )
- ld->ld_notifs = L_n->lm_next;
- else
- L_q->lm_next = L_n->lm_next;
-
- L_n->lm_next = NULLMSG;
- if ( freeit )
- ldap_msgfree(L_n);
-
- break;
- }
- L_q = L_n;
- }
- return (LDAP_SUCCESS);
-}
-
-/* Add in tail */
-int ldap_add_notif(LDAP *ld, LDAPMessage *notif)
-{
- LDAPMessage *L_n=NULLMSG, *L_q=NULLMSG;
-
- for ( L_n=ld->ld_notifs; L_n!=NULLMSG; L_n=L_n->lm_next)
- L_q = L_n;
-
- notif->lm_next = NULLMSG;
- if ( L_q == NULLMSG )
- ld->ld_notifs = notif;
- else
- L_q->lm_next = notif;
-
- return (LDAP_SUCCESS);
-}
-
-/* Add in head */
-int ldap_insert_notif(LDAP *ld, LDAPMessage *notif)
-{
-
- notif->lm_next = ld->ld_notifs;
- ld->ld_notifs = notif;
-
- return (LDAP_SUCCESS);
-}
-
diff --git a/usr/src/lib/libldap4/common/open.c b/usr/src/lib/libldap4/common/open.c
deleted file mode 100644
index 78211659f2..0000000000
--- a/usr/src/lib/libldap4/common/open.c
+++ /dev/null
@@ -1,433 +0,0 @@
-/*
- * Copyright (c) 1995-2001 by Sun Microsystems, Inc.
- * All rights reserved.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*
- * Copyright (c) 1995 Regents of the University of Michigan.
- * All rights reserved.
- *
- * open.c
- */
-
-#ifndef lint
-static char copyright[] = "@(#) Copyright (c) 1995 Regents of the "
- "University of Michigan.\nAll rights reserved.\n";
-#endif
-
-#include <stdio.h>
-#include <string.h>
-#include <stdlib.h> /* calloc(), free(), atoi() for Solaris */
-#include <locale.h>
-#include <thread.h>
-
-#ifdef MACOS
-#include <stdlib.h>
-#include "macos.h"
-#endif /* MACOS */
-
-#if defined(DOS) || defined(_WIN32)
-#include "msdos.h"
-#include <stdlib.h>
-#endif /* DOS */
-
-#if !defined(MACOS) && !defined(DOS) && !defined(_WIN32)
-#include <sys/time.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#ifndef VMS
-#include <sys/param.h>
-#endif
-#include <netinet/in.h>
-#endif
-#include "lber.h"
-#include "ldap.h"
-#include "ldap-private.h"
-#include "ldap-int.h"
-
-#ifdef LDAP_DEBUG
-int ldap_debug;
-#endif
-
-#ifndef INADDR_LOOPBACK
-#define INADDR_LOOPBACK ((unsigned int) 0x7f000001)
-#endif
-
-#ifndef MAXHOSTNAMELEN
-#define MAXHOSTNAMELEN 64
-#endif
-
-extern int thr_kill(thread_t, int);
-
-/*
- * ldap_open - initialize and connect to an ldap server. A magic cookie to
- * be used for future communication is returned on success, NULL on failure.
- * "host" may be a space-separated list of hosts or IP addresses
- *
- * Example:
- * LDAP *ld;
- * ld = ldap_open( hostname, port );
- */
-
-LDAP *
-ldap_open(char *host, int port)
-{
- LDAP *ld;
- int err;
-
- if ((ld = ldap_init(host, port)) == NULL) {
- return (NULL);
- }
-
- Debug(LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 113,
- "ldap_open (after ldap_init)\n"), 0, 0, 0);
-
-#ifdef _REENTRANT
- LOCK_LDAP(ld);
-#endif
- if ((err = open_default_ldap_connection(ld)) != LDAP_SUCCESS) {
-#ifdef _REENTRANT
- UNLOCK_LDAP(ld);
-#endif
- ldap_ld_free(ld, 0);
- Debug(LDAP_DEBUG_ANY, catgets(slapdcat, 1, 1275,
- "ldap_open failed, %s\n"),
- ldap_err2string(err), 0, 0);
- return (NULL);
- }
-
- Debug(LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 194,
- "ldap_open successful, ld_host is %s\n"),
- (ld->ld_host == NULL) ? "(null)" : ld->ld_host, 0, 0);
-#ifdef _REENTRANT
- UNLOCK_LDAP(ld);
-#endif
- return (ld);
-
-}
-
-/*
- * Open the default connection
- * ld->ld_defconn MUST be null when calling this function,
- * ie the connection was never established
- * ld should be LOCKed before calling this function
- */
-int
-open_default_ldap_connection(LDAP *ld)
-{
- LDAPServer *srv;
- int err;
-
- if ((srv = (LDAPServer *)calloc(1, sizeof (LDAPServer))) ==
- NULL || (ld->ld_defhost != NULL && (srv->lsrv_host =
- strdup(ld->ld_defhost)) == NULL)) {
- return (LDAP_NO_MEMORY);
- }
- srv->lsrv_port = ld->ld_defport;
-
- if ((ld->ld_defconn = new_connection(ld, &srv, 1, 1, 0)) ==
- NULL) {
- err = ld->ld_errno;
- Debug(LDAP_DEBUG_ANY, catgets(slapdcat, 1, 1276,
- "Default connection to ldap server %s couldn't be "
- "opened (%d)\n"), ld->ld_defhost, err, 0);
-
- if (ld->ld_defhost != NULL)
- free(srv->lsrv_host);
- free((char *)srv);
- return (err);
- }
-
- /* so it never gets closed/freed */
- ++ld->ld_defconn->lconn_refcnt;
-
- return (LDAP_SUCCESS);
-}
-
-static pthread_mutex_t ldap_thr_index_mutex = {0};
-static pthread_t ldap_thr_table[MAX_THREAD_ID] = {0};
-
-int
-ldap_thr_index()
-{
- int i = 0;
- int free = 0;
- pthread_t cur = thr_self();
- for (i = 1; i < MAX_THREAD_ID; ++i) {
- if (ldap_thr_table[i] == cur) {
- return (i);
- } /* end if */
- } /* end for */
- /*
- * not in the table, allocate a new entry
- */
- pthread_mutex_lock(&ldap_thr_index_mutex);
- for (i = 1; i < MAX_THREAD_ID; ++i) {
- if (ldap_thr_table[i] == 0 ||
- thr_kill(ldap_thr_table[i], 0) != 0) {
- ldap_thr_table[i] = cur;
- pthread_mutex_unlock(&ldap_thr_index_mutex);
- return (i);
- } /* end if */
- } /* end for */
- pthread_mutex_unlock(&ldap_thr_index_mutex);
- /* if table is full, return the first entry, so that it */
- /* doesn't core dump */
- return (0);
-}
-
-/*
- * ldap_init - initialize the LDAP library. A magic cookie to be used for
- * future communication is returned on success, NULL on failure.
- * "defhost" may be a space-separated list of hosts or IP addresses
- *
- * Example:
- * LDAP *ld;
- * ld = ldap_init( default_hostname, default_port );
- */
-LDAP *
-ldap_init(char *defhost, int defport)
-{
- LDAP *ld;
- char *locale;
-
- locale = setlocale(LC_ALL, "");
- i18n_catopen("sdserver");
-
- Debug(LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 195,
- "ldap_init\n"), 0, 0, 0);
-
-
- if ((ld = (LDAP *) calloc(1, sizeof (LDAP))) == NULL) {
- return (NULL);
- }
-
-#ifdef _REENTRANT
- pthread_mutex_init(&ld->ld_ldap_mutex, DEFAULT_TYPE);
- pthread_mutex_init(&ld->ld_response_mutex, DEFAULT_TYPE);
- pthread_mutex_init(&ld->ld_poll_mutex, DEFAULT_TYPE);
- ld->ld_lockthread = 0;
-#endif
-
- if ((ld->ld_selectinfo = new_select_info()) == NULL) {
- free((char *)ld);
- return (NULL);
- }
- ld->ld_follow_referral = 1;
-
- /*
- * default to localhost when hostname is not specified
- * or if null string is passed as hostname
- */
-
- if ((defhost != NULL) && (*defhost != NULL) &&
- (ld->ld_defhost = strdup(defhost)) == NULL) {
- free_select_info(ld->ld_selectinfo);
- free((char *)ld);
- return (NULL);
- }
-
- ld->ld_defport = (defport == 0) ? LDAP_PORT : defport;
- ld->ld_version = LDAP_VERSION;
- ld->ld_lberoptions = LBER_USE_DER;
- ld->ld_refhoplimit = LDAP_DEFAULT_REFHOPLIMIT;
- ld->ld_connect_timeout = LDAP_X_IO_TIMEOUT_NO_TIMEOUT;
-
-#if defined(STR_TRANSLATION) && defined(LDAP_DEFAULT_CHARSET)
- ld->ld_lberoptions |= LBER_TRANSLATE_STRINGS;
-#if LDAP_CHARSET_8859 == LDAP_DEFAULT_CHARSET
- ldap_set_string_translators(ld, ldap_8859_to_t61,
- ldap_t61_to_8859);
-#endif /* LDAP_CHARSET_8859 == LDAP_DEFAULT_CHARSET */
-#endif /* STR_TRANSLATION && LDAP_DEFAULT_CHARSET */
-
- return (ld);
-}
-
-
-/* ARGSUSED */
-int
-open_ldap_connection(LDAP *ld, Sockbuf *sb, char *host, int defport,
- char **krbinstancep, int async)
-{
- int rc, port;
- char *p, *q, *r;
- char *curhost, hostname[ 2*MAXHOSTNAMELEN ];
- int bindTimeout;
-
- Debug(LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 196,
- "open_ldap_connection\n"), 0, 0, 0);
-
- defport = htons(defport);
- bindTimeout = ld->ld_connect_timeout;
-
- if (host != NULL) {
- for (p = host; p != NULL && *p != '\0'; p = q) {
- if ((q = strchr(p, ' ')) != NULL) {
- (void) strncpy(hostname, p, q - p);
- hostname[ q - p ] = '\0';
- curhost = hostname;
- while (*q == ' ') {
- ++q;
- }
- } else {
- /* avoid copy if possible */
- curhost = p;
- q = NULL;
- }
-
- if ((r = strchr(curhost, ':')) != NULL) {
- if (curhost != hostname) {
- /* now copy */
- (void) strcpy(hostname, curhost);
- r = hostname + (r - curhost);
- curhost = hostname;
- }
- *r++ = '\0';
- port = htons((short)atoi(r));
- } else {
- port = defport;
- }
-
- if ((rc = connect_to_host(sb, curhost, 0,
- port, async, bindTimeout)) != -1) {
- break;
- }
- }
- } else {
- rc = connect_to_host(sb, NULL, htonl(INADDR_LOOPBACK),
- defport, async, bindTimeout);
- }
-
- if (rc == -1) {
- return (rc);
- }
-
- if (krbinstancep != NULL) {
-#ifdef KERBEROS
- if ((*krbinstancep = host_connected_to(sb)) != NULL &&
- (p = strchr(*krbinstancep, '.')) != NULL) {
- *p = '\0';
- }
-#else /* KERBEROS */
- krbinstancep = NULL;
-#endif /* KERBEROS */
- }
-
- return (0);
-}
-
-/*
- * ldap_ssl_open - initialize and connect to an ssl secured ldap
- * server. First ldap_open() is called and then ssl is layered on top
- * of the socket. A magic cookie to be used for future communication
- * is returned on success, NULL on failure. "host" may be a
- * space-separated list of hosts or IP addresses. CAfile and CApath
- * are used first time through, subsequent calls are ignored and can
- * be NULL.
- *
- * Example:
- * LDAP *ld;
- * ld = ldap_ssl_open( hostname, port, key );
- */
-
-#ifdef LDAP_SSL
-
-#include "security/ssl.h"
-
-int
-establish_ssl_connection(LDAP *ld)
-{
- SSL *ssl = NULL; /* The Client's SSL connection */
-
- /*
- * Creates a new SSL connection. This holds information
- * pertinent to this
- * connection.
- */
- if ((ssl = SSL_new()) == NULL) {
- Debug(LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 198,
- "SSL_new() failed: %s\n"),
- SSL_strerr(SSL_errno(ssl)), 0, 0);
- return (-1);
- }
-
- /* if keyname is non-null, set ssl keypackage name from it */
- if (ld->ld_ssl_key != NULL) {
- if (SSL_set_userid(ssl, ld->ld_ssl_key, 0) == NULL) {
- Debug(LDAP_DEBUG_TRACE, catgets(slapdcat, 1,
- 199, "SSL_set_userid() failed: %s\n"),
- SSL_strerr(SSL_errno(ssl)), 0, 0);
- return (-1);
- }
- }
-
- /* Start the SSL connection */
- if (SSL_connect(ssl, ld->ld_sb.sb_sd) < 1) {
- Debug(LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 200,
- "SSL_connect() failed: %s\n"),
- SSL_strerr(SSL_errno(ssl)), 0, 0);
- return (-1);
- }
-
- ld->ld_sb.sb_ssl = ssl;
- return (0);
-}
-
-
-LDAP *
-ldap_ssl_open(char *host, int port, char *keyname)
-{
- LDAP *ld;
- int rval;
-
-
- if (port == 0)
- port = SSL_LDAP_PORT;
-
- ld = ldap_open(host, port);
-
- Debug(LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 197,
- "ldap_ssl_open (after ldap_open)\n"), 0, 0, 0);
-
- if (ld == NULL)
- return (NULL);
-
- ld->ld_use_ssl = 1;
- if (keyname)
- ld->ld_ssl_key = strdup(keyname);
-
- if (establish_ssl_connection(ld) != 0) {
- ldap_ld_free(ld, 1);
- return (NULL);
- }
-
- return (ld);
-}
-
-LDAP *
-ldap_ssl_init(char *defhost, int defport, char *keyname)
-{
- LDAP *ld;
- int rval;
-
-
- if (defport == 0)
- defport = SSL_LDAP_PORT;
-
- ld = ldap_init(defhost, defport);
-
- Debug(LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 197,
- "ldap_ssl_open (after ldap_open)\n"), 0, 0, 0);
-
- if (ld == NULL)
- return (NULL);
- ld->ld_use_ssl = 1;
- ld->ld_ssl_key = strdup(keyname);
-
- return (ld);
-}
-
-#endif /* LDAP_SSL */
diff --git a/usr/src/lib/libldap4/common/option.c b/usr/src/lib/libldap4/common/option.c
deleted file mode 100644
index b80d6a609c..0000000000
--- a/usr/src/lib/libldap4/common/option.c
+++ /dev/null
@@ -1,243 +0,0 @@
-/*
- * Copyright (c) 1995-2001 by Sun Microsystems, Inc.
- * All rights reserved.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#include <stdio.h>
-#include <string.h>
-#include "lber.h"
-#include "ldap.h"
-#include "ldap-private.h"
-#include "ldap-int.h"
-
-extern LDAPControl ** ldap_controls_dup(LDAPControl **ctrls);
-
-/*
- * ldap_get_option()
- */
-int
-ldap_get_option(LDAP *ld, int option, void *outvalue)
-{
- if (ld == NULL)
- return (-1);
-#ifdef _REENTRANT
- LOCK_LDAP(ld);
-#endif
- switch (option) {
- case LDAP_OPT_API_INFO:
- ((LDAPAPIInfo *)outvalue)->ldapai_api_version =
- LDAP_API_VERSION;
- if (((LDAPAPIInfo *)outvalue)->ldapai_info_version !=
- LDAP_API_INFO_VERSION) {
- ((LDAPAPIInfo *)outvalue)->ldapai_info_version =
- LDAP_API_INFO_VERSION;
-#ifdef _REENTRANT
- UNLOCK_LDAP(ld);
-#endif
- return (-1);
- }
- ((LDAPAPIInfo *)outvalue)->ldapai_protocol_version =
- LDAP_VERSION_MAX;
- /* No extensions are currently supported */
- ((LDAPAPIInfo *)outvalue)->ldapai_extensions = NULL;
- ((LDAPAPIInfo *)outvalue)->ldapai_vendor_name =
- strdup(LDAP_VENDOR_NAME);
- ((LDAPAPIInfo *)outvalue)->ldapai_vendor_version =
- LDAP_VENDOR_VERSION;
- break;
- case LDAP_OPT_DESC: /* depricated option */
- *(int *)outvalue = ld->ld_sb.sb_sd;
- break;
- case LDAP_OPT_DEREF:
- *(int *)outvalue = ld->ld_deref;
- break;
- case LDAP_OPT_SIZELIMIT:
- *(int *)outvalue = ld->ld_sizelimit;
- break;
- case LDAP_OPT_TIMELIMIT:
- *(int *)outvalue = ld->ld_timelimit;
- break;
- case LDAP_OPT_REBIND_FN: /* depricated option */
- outvalue = (void *)ld->ld_rebindproc;
- break;
- case LDAP_OPT_REBIND_ARG: /* depricated option */
- outvalue = ld->ld_rebind_extra_arg;
- break;
- case LDAP_OPT_REFERRALS:
- *(int *)outvalue = ld->ld_follow_referral;
- break;
- case LDAP_OPT_RESTART:
- *(int *)outvalue = ld->ld_restart;
- break;
- case LDAP_OPT_PROTOCOL_VERSION:
- *(int *)outvalue = ld->ld_version;
- break;
- case LDAP_OPT_SERVER_CONTROLS:
- outvalue = ld->ld_srvctrls;
- break;
- case LDAP_OPT_CLIENT_CONTROLS:
- outvalue = ld->ld_cltctrls;
- break;
- case LDAP_OPT_API_FEATURE_INFO:
- if ((((LDAPAPIFeatureInfo *)outvalue)->ldapaif_info_version !=
- LDAP_FEATURE_INFO_VERSION) ||
- (((LDAPAPIFeatureInfo *)outvalue)->ldapaif_name ==
- NULL)) {
- ((LDAPAPIFeatureInfo *)outvalue)->ldapaif_info_version =
- LDAP_FEATURE_INFO_VERSION;
-#ifdef _REENTRANT
- UNLOCK_LDAP(ld);
-#endif
- return (-1);
- }
- /*
- * This option must be completed when optional api's (or
- * (extensions) are supported by this library. Right now
- * there are none, and therefore this section can not be
- * completed.
- */
- break;
- case LDAP_OPT_HOST_NAME:
- *(char **)outvalue = ld->ld_host;
- break;
- case LDAP_OPT_ERROR_NUMBER:
- *(int *)outvalue = ld->ld_errno;
- break;
- case LDAP_OPT_ERROR_STRING:
- *(char **)outvalue = ld->ld_error;
- break;
- case LDAP_OPT_MATCHED_DN:
-/* case LDAP_OPT_ERROR_MATCHED: depricated option */
- *(char **)outvalue = ld->ld_matched;
- break;
- case LDAP_X_OPT_CONNECT_TIMEOUT:
- *((int *)outvalue) = ld->ld_connect_timeout;
- break;
- default:
-#ifdef _REENTRANT
- UNLOCK_LDAP(ld);
-#endif
- return (-1);
- }
-
-#ifdef _REENTRANT
- UNLOCK_LDAP(ld);
-#endif
- return (0);
-}
-
-int
-ldap_set_option(LDAP *ld, int option, void *invalue)
-{
- if (ld == NULL)
- return (-1);
-#ifdef _REENTRANT
- LOCK_LDAP(ld);
-#endif
- switch (option) {
- case LDAP_OPT_DESC:
- break;
- case LDAP_OPT_DEREF:
- if (*(int *)invalue != LDAP_DEREF_NEVER &&
- *(int *)invalue != LDAP_DEREF_SEARCHING &&
- *(int *)invalue != LDAP_DEREF_FINDING &&
- *(int *)invalue != LDAP_DEREF_ALWAYS) {
-#ifdef _REENTRANT
- UNLOCK_LDAP(ld);
-#endif
- return (-1);
- }
- ld->ld_deref = *(int *)invalue;
- break;
- case LDAP_OPT_SIZELIMIT:
- ld->ld_sizelimit = *(int *)invalue;
- break;
- case LDAP_OPT_TIMELIMIT:
- ld->ld_timelimit = *(int *)invalue;
- break;
- case LDAP_OPT_REBIND_FN:
- /* cast needs to be updated when ldap.h gets updated */
- ld->ld_rebindproc = (LDAP_REBIND_FUNCTION *)invalue;
- break;
- case LDAP_OPT_REBIND_ARG:
- ld->ld_rebind_extra_arg = invalue;
- break;
- case LDAP_OPT_REFERRALS:
- if (invalue != LDAP_OPT_ON && invalue != LDAP_OPT_OFF) {
-#ifdef _REENTRANT
- UNLOCK_LDAP(ld);
-#endif
- return (-1);
- }
- ld->ld_follow_referral = invalue ? 1 : 0;
- break;
- case LDAP_OPT_RESTART:
- if (invalue != LDAP_OPT_ON && invalue != LDAP_OPT_OFF) {
-#ifdef _REENTRANT
- UNLOCK_LDAP(ld);
-#endif
- return (-1);
- }
- ld->ld_restart = invalue ? 1 : 0;
- break;
- case LDAP_OPT_PROTOCOL_VERSION:
- if (*(int *)invalue < LDAP_VERSION1 ||
- *(int *)invalue > LDAP_VERSION3) {
-#ifdef _REENTRANT
- UNLOCK_LDAP(ld);
-#endif
- return (-1);
- }
- ld->ld_version = *(int *)invalue;
- break;
- case LDAP_OPT_SERVER_CONTROLS:
- if (ld->ld_srvctrls != NULL) {
- ldap_controls_free(ld->ld_srvctrls);
- }
- ld->ld_srvctrls = NULL;
- if (invalue != NULL)
- ld->ld_srvctrls = ldap_controls_dup(invalue);
- break;
- case LDAP_OPT_CLIENT_CONTROLS:
- if (ld->ld_cltctrls != NULL) {
- ldap_controls_free(ld->ld_cltctrls);
- }
- ld->ld_cltctrls = NULL;
- if (invalue != NULL)
- ld->ld_cltctrls = ldap_controls_dup(invalue);
- break;
- case LDAP_OPT_HOST_NAME:
- if (ld->ld_host != NULL) {
- free(ld->ld_host);
- }
- ld->ld_host = NULL;
- if ((char *)invalue != NULL)
- ld->ld_host = strdup((char *)invalue);
- break;
- case LDAP_OPT_ERROR_NUMBER:
- break;
- case LDAP_OPT_ERROR_STRING:
- break;
- case LDAP_OPT_MATCHED_DN:
- if (ld->ld_matched)
- free(ld->ld_matched);
- ld->ld_matched = NULL;
- if ((char *)invalue != NULL)
- ld->ld_matched = strdup((char *)invalue);
- break;
- case LDAP_X_OPT_CONNECT_TIMEOUT:
- ld->ld_connect_timeout = *((int *)invalue);
- break;
- default:
-#ifdef _REENTRANT
- UNLOCK_LDAP(ld);
-#endif
- return (-1);
- }
-#ifdef _REENTRANT
- UNLOCK_LDAP(ld);
-#endif
- return (0);
-}
diff --git a/usr/src/lib/libldap4/common/os-ip.c b/usr/src/lib/libldap4/common/os-ip.c
deleted file mode 100644
index 5f025ee548..0000000000
--- a/usr/src/lib/libldap4/common/os-ip.c
+++ /dev/null
@@ -1,614 +0,0 @@
-/*
- * Copyright (c) 1995-2001 by Sun Microsystems, Inc.
- * All rights reserved.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*
- * Copyright (c) 1995 Regents of the University of Michigan.
- * All rights reserved.
- *
- * os-ip.c -- platform-specific TCP & UDP related code
- */
-
-#ifndef lint
-static char copyright[] = "@(#) Copyright (c) 1995 Regents of the University of Michigan.\nAll rights reserved.\n";
-#endif
-
-#include <stdio.h>
-#include <string.h>
-#include <errno.h>
-#include <arpa/inet.h>
-
-#ifdef _WIN32
-#include <io.h>
-#include "msdos.h"
-#else /* _WIN32 */
-#include <sys/time.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <netinet/in.h>
-#include <netdb.h>
-#endif /* _WIN32 */
-#ifdef _AIX
-#include <sys/select.h>
-#endif /* _AIX */
-#ifdef VMS
-#include "ucx_select.h"
-#endif /* VMS */
-#include "portable.h"
-#include "lber.h"
-#include "ldap.h"
-#include "ldap-private.h"
-#include "ldap-int.h"
-
-#ifdef LDAP_REFERRALS
-#ifdef USE_SYSCONF
-#include <unistd.h>
-#endif /* USE_SYSCONF */
-#ifdef notyet
-#ifdef NEED_FILIO
-#include <sys/filio.h>
-#else /* NEED_FILIO */
-#include <sys/ioctl.h>
-#endif /* NEED_FILIO */
-#endif /* notyet */
-#endif /* LDAP_REFERRALS */
-
-#ifdef MACOS
-#define tcp_close(s) tcpclose(s)
-#else /* MACOS */
-#ifdef DOS
-#ifdef PCNFS
-#define tcp_close(s) close(s)
-#endif /* PCNFS */
-#ifdef NCSA
-#define tcp_close(s) netclose(s); netshut()
-#endif /* NCSA */
-#ifdef WINSOCK
-#define tcp_close(s) closesocket(s); WSACleanup();
-#endif /* WINSOCK */
-#else /* DOS */
-#define tcp_close(s) close(s)
-#endif /* DOS */
-#endif /* MACOS */
-#ifdef SUN
-#include <nss_dbdefs.h>
-#endif
-
-#include <fcntl.h>
-#include <sys/poll.h>
-
-
-/*
- * Do an async connect or blocking connect depending on the timeout
- * value. LDAP_X_IO_TIMEOUT_NO_TIMEOUT means do a blocking connect.
- * Otherwise wait for timeout milliseconds for the connection.
- * Returns 0 on success and -1 on failure.
- */
-static int
-do_connect(int s, struct sockaddr *sin, int timeout)
-{
- int flags, connected = 0;
- int retval, error, n;
- fd_set wfds;
- struct timeval waittime, *sel_timeout;
-
- /* set the socket to do non-blocking i/o */
- flags = fcntl(s, F_GETFL, 0);
- fcntl(s, F_SETFL, flags | O_NONBLOCK);
-
- if (connect(s, sin, sizeof (struct sockaddr_in)) == 0) {
- connected = 1;
- } else if (errno == EINPROGRESS) {
- /* if NO_TIMEOUT is specified do a blocking connect */
- if (timeout <= LDAP_X_IO_TIMEOUT_NO_TIMEOUT) {
- sel_timeout = NULL;
- } else {
- /* set the timeout to the specified value */
- waittime.tv_sec = timeout / MILLISEC;
- waittime.tv_usec = (timeout % MILLISEC) * 1000;
- sel_timeout = &waittime;
- }
-
- FD_ZERO(&wfds);
- FD_SET(s, &wfds);
- n = sizeof (error);
- if (select(s+1, NULL, &wfds, NULL, sel_timeout) > 0 &&
- FD_ISSET(s, &wfds) &&
- getsockopt(s, SOL_SOCKET, SO_ERROR, &error, &n) == 0 &&
- error == 0) {
- connected = 1;
- }
- }
-
- /* if we are connected restore the flags for the socket */
- if (connected) {
- fcntl(s, F_SETFL, flags);
- }
-
- return (connected ? 0 : -1);
-}
-
-
-int
-connect_to_host(Sockbuf *sb, char *host, in_addr_t address,
- int port, int async, int timeout)
-/*
- * if host == NULL, connect using address
- * "address" and "port" must be in network byte order
- * zero is returned upon success, -1 if fatal error, -2 EINPROGRESS
- * async is only used ifdef LDAP_REFERRALS (non-0 means don't wait for connect)
- * XXX async is not used yet!
- */
-{
- int rc, i, s, connected, use_hp;
- struct sockaddr_in sin;
- struct hostent *hp;
-#ifdef notyet
-#ifdef LDAP_REFERRALS
- int status; /* for ioctl call */
-#endif /* LDAP_REFERRALS */
-#endif /* notyet */
-#ifdef SUN
- struct hostent hpret;
- char hpbuf[NSS_BUFLEN_HOSTS];
- int hperrno;
-#endif
-
- Debug(LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 201, "connect_to_host: "
- "%1$s:%2$d\n"), (host == NULL) ? catgets(slapdcat, 1, 202,
- "(by address)") : host, ntohs(port), 0);
-
- connected = use_hp = 0;
-
- if (host != NULL && (address = inet_addr(host)) == -1) {
-#ifdef SUN
- if ((hp = gethostbyname_r(host, &hpret, hpbuf,
- NSS_BUFLEN_HOSTS, &hperrno)) == NULL) {
-#else
- if ((hp = gethostbyname(host)) == NULL) {
-#endif
- errno = EHOSTUNREACH; /* not exactly right, but... */
- return (-1);
- }
- use_hp = 1;
- }
-
- rc = -1;
- for (i = 0; !use_hp || (hp->h_addr_list[i] != 0); i++) {
- if ((s = socket(AF_INET, SOCK_STREAM, 0)) < 0) {
- return (-1);
- }
-#ifdef notyet
-#ifdef LDAP_REFERRALS
- status = 1;
- if (async && ioctl(s, FIONBIO, (caddr_t)&status) == -1) {
- Debug(LDAP_DEBUG_ANY, catgets(slapdcat, 1, 203,
- "FIONBIO ioctl failed on %d\n"), s, 0, 0);
- }
-#endif /* LDAP_REFERRALS */
-#endif /* notyet */
- (void) memset((char *)&sin, 0, sizeof (struct sockaddr_in));
- sin.sin_family = AF_INET;
- sin.sin_port = port;
- SAFEMEMCPY((char *) &sin.sin_addr.s_addr,
- (use_hp ? (char *) hp->h_addr_list[i] :
- (char *)&address), sizeof (sin.sin_addr.s_addr));
-
- if (do_connect(s, (struct sockaddr *)&sin, timeout) == 0) {
- connected = 1;
- break;
- }
-
-#ifdef notyet
-#ifdef LDAP_REFERRALS
-#ifdef EAGAIN
- if (errno == EINPROGRESS || errno == EAGAIN) {
-#else /* EAGAIN */
- if (errno == EINPROGRESS) {
-#endif /* EAGAIN */
- Debug(LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 204,
- "connect would block...\n"), 0, 0, 0);
- rc = -2;
- break;
- }
-#endif /* LDAP_REFERRALS */
-#endif /* notyet */
-
-#ifdef LDAP_DEBUG
- if (ldap_debug & LDAP_DEBUG_TRACE) {
- perror((char *)inet_ntoa(sin.sin_addr));
- }
-#endif
- close(s);
- if (!use_hp) {
- break;
- }
- }
-
- if (connected) {
- rc = 0;
- sb->sb_sd = s;
-#ifdef notyet
-#ifdef LDAP_REFERRALS
- status = 0;
- if (!async && ioctl(s, FIONBIO, (caddr_t)&on) == -1) {
- Debug(LDAP_DEBUG_ANY, catgets(slapdcat, 1, 203,
- "FIONBIO ioctl failed on %d\n"), s, 0, 0);
- }
-#endif /* LDAP_REFERRALS */
-#endif /* notyet */
-
- Debug(LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 205,
- "sd %1$d connected to: %2$s\n"), s,
- inet_ntoa(sin.sin_addr), 0);
- }
-
- return (rc);
-}
-
-
-void
-close_ldap_connection( Sockbuf *sb )
-{
-#ifdef LDAP_SSL
- if (sb->sb_ssl){
- SSL_close(sb->sb_ssl);
- SSL_delete(sb->sb_ssl);
- }
- sb->sb_ssl = NULL;
- sb->sb_ssl_tls = 0;
-#endif
- tcp_close( sb->sb_sd );
-}
-
-
-#ifdef KERBEROS
-char *
-host_connected_to( Sockbuf *sb )
-{
- struct hostent *hp;
- char *p;
- int len;
- struct sockaddr_in sin;
-#ifdef SUN
- struct hostent hpret;
- char hpbuf[NSS_BUFLEN_HOSTS];
- int hperrno;
-#endif
-
- (void)memset( (char *)&sin, 0, sizeof( struct sockaddr_in ));
- len = sizeof( sin );
- if ( getpeername( sb->sb_sd, (struct sockaddr *)&sin, &len ) == -1 ) {
- return( NULL );
- }
-
- /*
- * do a reverse lookup on the addr to get the official hostname.
- * this is necessary for kerberos to work right, since the official
- * hostname is used as the kerberos instance.
- */
-#ifdef SUN
- if (( hp = gethostbyaddr_r((char *) &sin.sin_addr,
- sizeof( sin.sin_addr ), AF_INET,
- &hpret, hpbuf, NSS_BUFLEN_HOSTS, &hperrno)) != NULL ) {
-#else
- if (( hp = gethostbyaddr( (char *) &sin.sin_addr,
- sizeof( sin.sin_addr ), AF_INET )) != NULL ) {
-#endif
- if ( hp->h_name != NULL ) {
- return( strdup( hp->h_name ));
- }
- }
-
- return( NULL );
-}
-#endif /* KERBEROS */
-
-
-#ifdef LDAP_REFERRALS
-#ifdef SUN
-/* for UNIX */
-#include <stropts.h>
-#include <poll.h>
-
-struct selectinfo {
- struct pollfd fds[LDAP_DEFAULT_REFHOPLIMIT];
- int nbfds;
-};
-
-
-void
-mark_select_write( LDAP *ld, Sockbuf *sb )
-{
- struct selectinfo *sip;
- int i;
-
- sip = (struct selectinfo *)ld->ld_selectinfo;
-
- /* find if sb is in fds */
- for (i=0; i< sip->nbfds; i++) {
- if (sip->fds[i].fd == sb->sb_sd){
- sip->fds[i].events |= POLLOUT;
- return;
- }
- }
- if (sip->nbfds < LDAP_DEFAULT_REFHOPLIMIT) {
- sip->fds[sip->nbfds].fd = sb->sb_sd;
- sip->fds[sip->nbfds].events |= POLLOUT;
- sip->nbfds++;
- }
- else {
- /* Should not happen */
- Debug( LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 206, "Mark for poll : Too many descriptors\n"), 0, 0, 0 );
- }
-}
-
-
-void
-mark_select_read( LDAP *ld, Sockbuf *sb )
-{
- struct selectinfo *sip;
- int i;
-
- sip = (struct selectinfo *)ld->ld_selectinfo;
-
- /* find if sb is in fds */
- for (i=0; i< sip->nbfds; i++) {
- if (sip->fds[i].fd == sb->sb_sd) {
- sip->fds[i].events |= POLLIN;
- return;
- }
- }
-
- if (sip->nbfds < LDAP_DEFAULT_REFHOPLIMIT) {
- sip->fds[sip->nbfds].fd = sb->sb_sd;
- sip->fds[sip->nbfds].events |= POLLIN;
- sip->nbfds++;
- }
- else {
- /* Should not happen */
- Debug( LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 206, "Mark for poll : Too many descriptors\n"), 0, 0, 0 );
- }
-}
-
-
-void
-mark_select_clear( LDAP *ld, Sockbuf *sb )
-{
- struct selectinfo *sip;
- int i;
-
- sip = (struct selectinfo *)ld->ld_selectinfo;
-
- for (i = 0; i< sip->nbfds; i++) {
- if (sip->fds[i].fd == sb->sb_sd){
- i++;
- for (; i < sip->nbfds; i ++) {
- sip->fds[ i - 1] = sip->fds[i];
- }
- sip->fds[i].fd = -1;
- sip->fds[i].events = -1;
- sip->nbfds--;
- return;
- }
- }
- /* If we reach here, there's a pb. */
- Debug( LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 207, "Clear poll : descriptor not found\n"), 0, 0, 0 );
-}
-
-
-long
-is_write_ready( LDAP *ld, Sockbuf *sb )
-{
- struct selectinfo *sip;
- int i;
-
- sip = (struct selectinfo *)ld->ld_selectinfo;
-
- for (i=0; i< sip->nbfds; i++) {
- if (sip->fds[i].fd == sb->sb_sd) {
- if ( sip->fds[i].revents & (POLLERR | POLLHUP | POLLNVAL)) {
- return (-1);
- }
- return( sip->fds[i].revents & POLLOUT );
- }
- }
- return(0);
-}
-
-
-long
-is_read_ready( LDAP *ld, Sockbuf *sb )
-{
- struct selectinfo *sip;
- int i;
-
- sip = (struct selectinfo *)ld->ld_selectinfo;
-
- for (i=0; i< sip->nbfds; i++) {
- if (sip->fds[i].fd == sb->sb_sd) {
- if (sip->fds[i].revents & (POLLERR | POLLHUP | POLLNVAL)) {
- return (-1);
- }
- return( sip->fds[i].revents & POLLIN );
- }
- }
- return(0);
-}
-
-void *
-new_select_info()
-{
- struct selectinfo *sip;
-
- sip = (struct selectinfo *)calloc( 1, sizeof( struct selectinfo ));
-
- return( (void *)sip );
-}
-
-
-void
-free_select_info( void *sip )
-{
- free( sip );
-}
-
-
-int
-do_ldap_select( LDAP *ld, struct timeval *timeout )
-{
- struct selectinfo *sip;
- int tim;
-#if defined( SUN ) && defined( _REENTRANT )
- int rv;
-#endif
-
- Debug( LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 208, "do_ldap_select\n"), 0, 0, 0 );
-
- sip = (struct selectinfo *)ld->ld_selectinfo;
-
-/* sip->fds[0].revents = 0; */
-
- if ( timeout ) {
- tim = (timeout->tv_sec*1000)+(timeout->tv_usec/1000);
- } else {
- tim = INFTIM;
- } /* end if */
- errno=0;
-#if defined( SUN ) && defined( _REENTRANT )
-/* UNLOCK_LDAP(ld); */
- LOCK_POLL(ld);
- rv = poll(sip->fds,sip->nbfds,tim);
-/* LOCK_LDAP(ld); */
- UNLOCK_POLL(ld);
- return(rv);
-#else
- return( poll(sip->fds,sip->nbfds,tim) );
-#endif
-}
-#else
-/* for UNIX */
-struct selectinfo {
- fd_set si_readfds;
- fd_set si_writefds;
- fd_set si_use_readfds;
- fd_set si_use_writefds;
-};
-
-
-void
-mark_select_write( LDAP *ld, Sockbuf *sb )
-{
- struct selectinfo *sip;
-
- sip = (struct selectinfo *)ld->ld_selectinfo;
-
- if ( !FD_ISSET( sb->sb_sd, &sip->si_writefds )) {
- FD_SET( sb->sb_sd, &sip->si_writefds );
- }
-}
-
-
-void
-mark_select_read( LDAP *ld, Sockbuf *sb )
-{
- struct selectinfo *sip;
-
- sip = (struct selectinfo *)ld->ld_selectinfo;
-
- if ( !FD_ISSET( sb->sb_sd, &sip->si_readfds )) {
- FD_SET( sb->sb_sd, &sip->si_readfds );
- }
-}
-
-
-void
-mark_select_clear( LDAP *ld, Sockbuf *sb )
-{
- struct selectinfo *sip;
-
- sip = (struct selectinfo *)ld->ld_selectinfo;
-
- FD_CLR( sb->sb_sd, &sip->si_writefds );
- FD_CLR( sb->sb_sd, &sip->si_readfds );
-}
-
-
-long
-is_write_ready( LDAP *ld, Sockbuf *sb )
-{
- struct selectinfo *sip;
-
- sip = (struct selectinfo *)ld->ld_selectinfo;
-
- return( FD_ISSET( sb->sb_sd, &sip->si_use_writefds ));
-}
-
-
-long
-is_read_ready( LDAP *ld, Sockbuf *sb )
-{
- struct selectinfo *sip;
-
- sip = (struct selectinfo *)ld->ld_selectinfo;
-
- return( FD_ISSET( sb->sb_sd, &sip->si_use_readfds ));
-}
-
-
-void *
-new_select_info()
-{
- struct selectinfo *sip;
-
- if (( sip = (struct selectinfo *)calloc( 1,
- sizeof( struct selectinfo ))) != NULL ) {
- FD_ZERO( &sip->si_readfds );
- FD_ZERO( &sip->si_writefds );
- }
-
- return( (void *)sip );
-}
-
-
-void
-free_select_info( void *sip )
-{
- free( sip );
-}
-
-
-int
-do_ldap_select( LDAP *ld, struct timeval *timeout )
-{
- struct selectinfo *sip;
- static int tblsize;
-
- Debug( LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 208, "do_ldap_select\n"), 0, 0, 0 );
-
-#if defined( SUN ) && defined( _REENTRANT )
- LOCK_LDAP(ld);
-#endif
- if ( tblsize == 0 ) {
-#ifdef USE_SYSCONF
- tblsize = (int)sysconf( _SC_OPEN_MAX );
-#else /* USE_SYSCONF */
- tblsize = getdtablesize();
-#endif /* USE_SYSCONF */
- }
-
- sip = (struct selectinfo *)ld->ld_selectinfo;
- sip->si_use_readfds = sip->si_readfds;
- sip->si_use_writefds = sip->si_writefds;
-
-#if defined( SUN ) && defined( _REENTRANT )
- UNLOCK_LDAP(ld);
-#endif
- return( select( tblsize, &sip->si_use_readfds, &sip->si_use_writefds,
- NULL, timeout ));
-}
-#endif /* SUN */
-#endif /* LDAP_REFERRALS */
diff --git a/usr/src/lib/libldap4/common/referral.c b/usr/src/lib/libldap4/common/referral.c
deleted file mode 100644
index 173ee2cfe6..0000000000
--- a/usr/src/lib/libldap4/common/referral.c
+++ /dev/null
@@ -1,511 +0,0 @@
-/*
- *
- * Copyright 1999 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- *
- *
- * Comments:
- *
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#include <stdio.h>
-#include <string.h>
-#include <sys/time.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <sys/errno.h>
-#include "portable.h"
-#include "lber.h"
-#include "ldap.h"
-#include "ldap-private.h"
-#include "ldap-int.h"
-
-static BerElement *
-re_encode_request( LDAP *ld, BerElement *origber, int msgid, LDAPURLDesc *urldesc );
-static void addFollowedRef(LDAPRequest *lr, char *ref);
-static void addToFollowRef(LDAPRequest *lr, char *ref);
-static int addUnFollowedRef(LDAP *ld, LDAPRequest *lr, char *ref);
-
-char ** ldap_errormsg2referrals(char *errmsg) {
- char ** refs;
- int count;
- size_t len;
- char *p, *ref;
-
- if (errmsg == NULL){
- return (NULL);
- }
- len = strlen( errmsg );
- for ( p = errmsg; len >= LDAP_REF_STR_LEN; ++p, --len ) {
- if (( *p == 'R' || *p == 'r' ) && strncasecmp( p,
- LDAP_REF_STR, LDAP_REF_STR_LEN ) == 0 ) {
- *p = '\0';
- p += LDAP_REF_STR_LEN;
- break;
- }
- }
-
- if ( len < LDAP_REF_STR_LEN ) {
- return( NULL);
- }
- count = 1;
- ref = p;
- while ((ref = strchr(ref, '\n')) != NULL)
- count++;
-
- if ((refs = (char **)calloc(count + 1, sizeof(char *))) == NULL){
- return (NULL);
- }
-
- count = 0;
- for (ref = p; ref != NULL; ref= p){
- if ((p = strchr(ref, '\n')) != NULL){
- *p = '\0';
- }
- refs[count++] = strdup(ref);
- if (p != NULL)
- *p++ = '\n';
- }
- return (refs);
-}
-
-char *ldap_referral2error_msg(char ** refs)
-{
- int i;
- size_t len = 0;
- char *msg = NULL;
-
- if (refs == NULL)
- return (msg);
-
- for (i = 0; refs[i] != NULL; i++){
- len += strlen (refs[i]) + 1;
- }
-
- if ((len > 0) && ((msg = (char *)malloc(len + LDAP_REF_STR_LEN + 2)) != NULL)) {
- strncpy(msg, LDAP_REF_STR, LDAP_REF_STR_LEN);
- for (i = 0; refs[i] != NULL; i++) {
- strcat(msg, refs[i]);
- strcat(msg, "\n");
- }
- }
- return (msg);
-}
-
-
-int
-chase_referrals( LDAP *ld, LDAPRequest *lr, char **refs, int *count, int samerequest )
-{
- int rc, len, newdn, i, j, refcnt, errCode;
- char *p, *ports, *ref, *tmpref, *refdn;
- LDAPRequest *origreq;
- LDAPServer *srv;
- BerElement *ber;
- LDAPURLDesc *ludp;
-
-
- Debug( LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 215, "=> chase_referrals\n"), 0, 0, 0 );
-
- ld->ld_errno = LDAP_SUCCESS; /* optimistic */
- *count = 0;
- if ( refs == NULL ) {
- return( LDAP_SUCCESS );
- }
-
-#ifdef _REENTRANT
- LOCK_LDAP(ld);
-#endif
-
- if ( lr->lr_parentcnt >= ld->ld_refhoplimit ) {
- Debug( LDAP_DEBUG_ANY,
- catgets(slapdcat, 1, 216, "more than %d referral hops (dropping)\n"),
- ld->ld_refhoplimit, 0, 0 );
- /* XXX report as error in ld->ld_errno? */
- rc = ld->ld_errno = (ld->ld_version >= LDAP_VERSION3) ? LDAP_REFERRAL_LIMIT_EXCEEDED : LDAP_OTHER;
-#ifdef _REENTRANT
- UNLOCK_LDAP(ld);
-#endif
- return( rc );
- }
-
- /* find original request */
- for ( origreq = lr; origreq->lr_parent != NULL;
- origreq = origreq->lr_parent ) {
- ;
- }
-
- for (refcnt = 0; refs[refcnt] != NULL; refcnt++)
- ; /* Count number of referrals */
- Debug(LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 1277, "%d possible referrals to chase\n"), refcnt, 0,0);
-
- rc = 0;
- /* parse out & follow referrals */
- for (i = 0; rc == 0 && refs[i] != NULL; i++) {
- Debug(LDAP_DEBUG_TRACE, catgets(slapdcat, 1, -1, "Try to chase %s\n"), refs[i], 0,0);
-
- /* Parse URL */
- if (ldap_url_parse(refs[i], &ludp) != 0){
- Debug(LDAP_DEBUG_TRACE, catgets(slapdcat, 1, -1, "Bad URL for referral %s\n"), refs[i], 0,0);
- errCode = LDAP_PARAM_ERROR;
- addUnFollowedRef(ld, lr, refs[i]);
- /* try next URL */
- continue;
- }
-
- /* Encode previous request with new URL */
- if (( ber = re_encode_request( ld, origreq->lr_ber, ++ld->ld_msgid, ludp )) == NULL ) {
- Debug(LDAP_DEBUG_TRACE, catgets(slapdcat, 1, -1, "Error while encoding request for referral\n"), 0, 0,0);
- ldap_free_urldesc(ludp);
- errCode = ld->ld_errno;
- addUnFollowedRef(ld, lr, refs[i]);
- /* try next URL */
- continue;
- }
-
- if (( srv = (LDAPServer *)calloc( 1, sizeof( LDAPServer ))) == NULL ) {
- ldap_free_urldesc(ludp);
- ber_free( ber, 1 );
- rc = ld->ld_errno = LDAP_NO_MEMORY;
-#ifdef _REENTRANT
- UNLOCK_LDAP(ld);
-#endif
- return( rc );
- }
-
- if (( srv->lsrv_host = strdup( ludp->lud_host ? ludp->lud_host : ld->ld_defhost)) == NULL ) {
- ldap_free_urldesc(ludp);
- free( (char *)srv );
- ber_free( ber, 1 );
- rc = ld->ld_errno = LDAP_NO_MEMORY;
-#ifdef _REENTRANT
- UNLOCK_LDAP(ld);
-#endif
- return( rc );
- }
-
- srv->lsrv_port = ludp->lud_port ? ludp->lud_port : LDAP_PORT;
-
- if ( srv != NULL && send_server_request( ld, ber, ld->ld_msgid,
- lr, srv, NULL, 1 ) >= 0 ) {
- ++*count;
- Debug(LDAP_DEBUG_TRACE, catgets(slapdcat, 1, -1, "Request has been forwarded to %s\n"), refs[i], 0,0);
- addFollowedRef(lr, refs[i]);
- for (j = i+1; refs[j] != NULL; j++){
- addToFollowRef(lr, refs[j]);
- }
- ldap_free_urldesc(ludp);
- break;
- } else {
- Debug( LDAP_DEBUG_ANY,
- catgets(slapdcat, 1, 220, "Unable to chase referral (%s)\n"),
- ldap_err2string( ld->ld_errno ), 0, 0 );
- addUnFollowedRef(ld, lr, refs[i]);
- errCode = ld->ld_errno;
- }
- ldap_free_urldesc(ludp); /* So far spawn all requests */
- }
-
-#ifdef _REENTRANT
- UNLOCK_LDAP(ld);
-#endif
- if (refs[i] != NULL) {
- rc = LDAP_SUCCESS;
- } else {
- Debug(LDAP_DEBUG_TRACE, catgets(slapdcat, 1, -1, "No referral was successfully chased (last error %d)\n"), errCode, 0, 0);
- rc = errCode;
- }
- Debug ( LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 1278, "<= chase_referrals --- \n"), 0,0,0);
-
- return( rc );
-}
-
-static void addFollowedRef(LDAPRequest *lr, char *ref)
-{
- int i;
-
- if (lr->lr_ref_followed == NULL){
- if ((lr->lr_ref_followed = (char **)calloc(2, sizeof(char*))) == NULL)
- return;
- i = 0;
- } else {
- for (i = 0; lr->lr_ref_followed[i] != NULL; i++);
- if ((lr->lr_ref_followed = (char **)realloc((char *)lr->lr_ref_followed, (i+2) * sizeof(char *))) == NULL){
- return;
- }
- }
- lr->lr_ref_followed[i++] = strdup(ref);
- lr->lr_ref_followed[i] = NULL;
- return;
-}
-
-static void addToFollowRef(LDAPRequest *lr, char *ref)
-{
- int i;
-
- if (lr->lr_ref_tofollow == NULL){
- if ((lr->lr_ref_tofollow = (char **)calloc(2, sizeof(char*))) == NULL)
- return;
- i = 0;
- } else {
- for (i = 0; lr->lr_ref_tofollow[i] != NULL; i++);
- if ((lr->lr_ref_tofollow = (char **)realloc((char *)lr->lr_ref_tofollow, (i+2) * sizeof(char *))) == NULL){
- return;
- }
- }
- lr->lr_ref_tofollow[i++] = strdup(ref);
- lr->lr_ref_tofollow[i] = NULL;
- return;
-}
-
-static int addUnFollowedRef(LDAP *ld, LDAPRequest *lr, char *ref)
-{
- int i;
-
- if (lr->lr_ref_unfollowed == NULL){
- if ((lr->lr_ref_unfollowed = (char **)calloc(2, sizeof(char*))) == NULL){
- ld->ld_errno = LDAP_NO_MEMORY;
- return (-1);
- }
- i = 0;
- } else {
- for (i = 0; lr->lr_ref_unfollowed[i] != NULL; i++);
- if ((lr->lr_ref_unfollowed = (char **)realloc((char *)lr->lr_ref_unfollowed, (i+2) * sizeof(char *))) == NULL){
- ld->ld_errno = LDAP_NO_MEMORY;
- return (-1);
- }
- }
- lr->lr_ref_unfollowed[i++] = strdup(ref);
- lr->lr_ref_unfollowed[i] = NULL;
- return (0);
-}
-
-
-int
-append_referral( LDAP *ld, char **referralsp, char *s )
-{
- int first;
-
- if ( *referralsp == NULL ) {
- first = 1;
- *referralsp = (char *)malloc( strlen( s ) + LDAP_REF_STR_LEN
- + 1 );
- } else {
- first = 0;
- *referralsp = (char *)realloc( *referralsp,
- strlen( *referralsp ) + strlen( s ) + 2 );
- }
-
- if ( *referralsp == NULL ) {
- ld->ld_errno = LDAP_NO_MEMORY;
- return( -1 );
- }
-
- if ( first ) {
- strcpy( *referralsp, LDAP_REF_STR );
- } else {
- strcat( *referralsp, "\n" );
- }
- strcat( *referralsp, s );
-
- return( 0 );
-}
-
-
-
-static BerElement *
-re_encode_request( LDAP *ld, BerElement *origber, int msgid, LDAPURLDesc *urldesc )
-{
-/*
- * XXX this routine knows way too much about how the lber library works!
- */
- unsigned int along, tag, len;
- int ver, scope, deref, sizelimit, timelimit, attrsonly;
- int rc, hasCtrls;
- BerElement tmpber, *ber;
- char *dn, *seqstart;
-
- Debug( LDAP_DEBUG_TRACE,
- catgets(slapdcat, 1, 221, "re_encode_request: new msgid %1$d, new dn <%2$s>\n"),
- msgid, ( urldesc->lud_dn == NULL ) ? "NONE" : urldesc->lud_dn, 0 );
-
- tmpber = *origber;
-
- /*
- * all LDAP requests are sequences that start with a message id,
- * followed by a sequence that is tagged with the operation code
- */
- /* Bad assumption : delete op is not a sequence.
- * So we have a special processing for it : it's much simpler
- */
- if ( ber_scanf( &tmpber, "{i", &along ) != LDAP_TAG_MSGID ||
- ( tag = ber_peek_tag( &tmpber, &along )) == LBER_DEFAULT ) {
- ld->ld_errno = LDAP_DECODING_ERROR;
- return( NULL );
- }
-
- /* Special case : delete request is not a sequence of... */
- if (tag == LDAP_REQ_EXTENDED){
- /* return error, I don't know how to do it automatically */
- ld->ld_errno = LDAP_NOT_SUPPORTED;
- return (NULL);
- }
-
- if ( (ber = alloc_ber_with_options( ld )) == NULLBER ) {
- return (NULL);
- }
-
- if (tag == LDAP_REQ_DELETE) {
- if ( ber_get_stringa( &tmpber, &dn ) == LBER_DEFAULT ) {
- ld->ld_errno = LDAP_DECODING_ERROR;
- Debug(LDAP_DEBUG_TRACE,
- catgets(slapdcat, 1, 1279,"Error in decoding delete DN"),0,0,0);
- ber_free( ber, 1);
- return( NULL );
- }
- /* Check if controls */
- hasCtrls = 0;
- if (ber_peek_tag(&tmpber, &len) == LDAP_TAG_CONTROL_LIST){
- hasCtrls = 1;
- }
-
- if ( urldesc->lud_dn && *urldesc->lud_dn ) {
- free( dn );
- dn = urldesc->lud_dn;
- }
- if ( ber_printf( ber, "{its", msgid, tag, dn ) == -1 ) {
- Debug(LDAP_DEBUG_TRACE, "Error in re_encoding delete request",0,0,0);
- ld->ld_errno = LDAP_ENCODING_ERROR;
- ber_free( ber, 1 );
- return (NULL);
- }
- /* Now add controls if any */
- if (hasCtrls && ber_write( ber, tmpber.ber_ptr, len, 0 ) != len ) {
- ld->ld_errno = LDAP_ENCODING_ERROR;
- ber_free( ber, 1 );
- return( NULL );
- }
- if (ber_printf( ber, "}" ) == -1 ) {
- ld->ld_errno = LDAP_ENCODING_ERROR;
- ber_free( ber, 1 );
- return( NULL );
- }
-
-#ifdef LDAP_DEBUG
- if ( ldap_debug & LDAP_DEBUG_PACKETS ) {
- Debug( LDAP_DEBUG_ANY, catgets(slapdcat, 1, 222, "re_encode_request new request is:\n"),
- 0, 0, 0 );
- ber_dump( ber, 0 );
- }
-#endif /* LDAP_DEBUG */
- return (ber);
- }
-
- if (( tag = ber_skip_tag( &tmpber, &along )) == LBER_DEFAULT ) {
- ld->ld_errno = LDAP_DECODING_ERROR;
- return( NULL );
- }
- /* Keep length and pointer */
- seqstart = tmpber.ber_ptr;
-
- /* bind requests have a version number before the DN & other stuff */
- if ( tag == LDAP_REQ_BIND && ber_get_int( &tmpber, &ver ) ==
- LBER_DEFAULT ) {
- ld->ld_errno = LDAP_DECODING_ERROR;
- ber_free( ber, 1 );
- return( NULL );
- }
-
- /* the rest of the request is the DN followed by other stuff */
- if ( ber_get_stringa( &tmpber, &dn ) == LBER_DEFAULT ) {
- ber_free( ber, 1 );
- return( NULL );
- }
- if ( urldesc->lud_dn != NULL ) {
- free( dn );
- dn = urldesc->lud_dn;
- }
-
- /* see what to do with CONTROLS */
-
- if ( tag == LDAP_REQ_BIND ) {
- rc = ber_printf( ber, "{it{is", msgid, tag, ver, dn );
- } else {
- rc = ber_printf( ber, "{it{s", msgid, tag, dn );
- }
-
- if ( rc == -1 ) {
- ber_free( ber, 1 );
- return( NULL );
- }
-
- if (tag == LDAP_REQ_SEARCH) {
- /* Now for SEARCH, decode more of the request */
- if (ber_scanf(&tmpber, "iiiib", &scope, &deref, &sizelimit, &timelimit, &attrsonly) == LBER_DEFAULT){
- ld->ld_errno = LDAP_DECODING_ERROR;
- ber_free( ber, 1 );
- return( NULL );
- }
- if (ber_printf(ber, "iiiib", urldesc->lud_scope == LDAP_SCOPE_UNKNOWN ? scope : urldesc->lud_scope,
- deref, sizelimit, timelimit, attrsonly) == -1) {
- ld->ld_errno = LDAP_ENCODING_ERROR;
- ber_free( ber, 1 );
- return( NULL );
- }
- /* We should then decode and check the filter as opposed to ludp->lud_filter */
- /* Same for attributes */
- /* Later */
- }
- /* The rest is the same for all requests */
-
- /* Copy Buffer from tmpber.ber_ptr for along - (tmpber.ber_ptr - seqstart) */
- /* It's the rest of the request */
- len = along - ( tmpber.ber_ptr - seqstart);
- if ( ber_write( ber, tmpber.ber_ptr, len, 0) != len ||
- ber_printf( ber, "}" ) == -1 ) {
- ld->ld_errno = LDAP_ENCODING_ERROR;
- ber_free( ber, 1 );
- return( NULL );
- }
-
- if (seqstart + along < tmpber.ber_end){ /* there's probably some controls, copy them also */
- len = tmpber.ber_end - seqstart - along;
- if ( ber_write( ber, seqstart + along, len, 0) != len ){
- ld->ld_errno = LDAP_ENCODING_ERROR;
- ber_free( ber, 1 );
- return( NULL );
- }
- }
-
- if ( ber_printf(ber, "}") == -1) {
- ld->ld_errno = LDAP_ENCODING_ERROR;
- ber_free( ber, 1 );
- return( NULL );
- }
-
-#ifdef LDAP_DEBUG
- if ( ldap_debug & LDAP_DEBUG_PACKETS ) {
- Debug( LDAP_DEBUG_ANY, catgets(slapdcat, 1, 222, "re_encode_request new request is:\n"),
- 0, 0, 0 );
- ber_dump( ber, 0 );
- }
-#endif /* LDAP_DEBUG */
-
- return( ber );
-}
-
-
-LDAPRequest *
-find_request_by_msgid( LDAP *ld, int msgid )
-{
- LDAPRequest *lr;
-
- for ( lr = ld->ld_requests; lr != NULL; lr = lr->lr_next ) {
- if ( msgid == lr->lr_msgid ) {
- break;
- }
- }
-
- return( lr );
-}
diff --git a/usr/src/lib/libldap4/common/regex.c b/usr/src/lib/libldap4/common/regex.c
deleted file mode 100644
index 1e2a00bbb9..0000000000
--- a/usr/src/lib/libldap4/common/regex.c
+++ /dev/null
@@ -1,923 +0,0 @@
-/*
- *
- * Portions Copyright 1998 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- *
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#include "portable.h"
-#include "stdio.h"
-#include "stdlib.h"
-
-#if defined( MACOS ) || defined( DOS ) || defined( _WIN32 ) || defined( NEED_BSDREGEX )
-#include "regex.h"
-
-/*
- * regex - Regular expression pattern matching and replacement
- *
- * By: Ozan S. Yigit (oz)
- * Dept. of Computer Science
- * York University
- *
- * These routines are the PUBLIC DOMAIN equivalents of regex
- * routines as found in 4.nBSD UN*X, with minor extensions.
- *
- * These routines are derived from various implementations found
- * in software tools books, and Conroy's grep. They are NOT derived
- * from licensed/restricted software.
- * For more interesting/academic/complicated implementations,
- * see Henry Spencer's regexp routines, or GNU Emacs pattern
- * matching module.
- *
- * Modification history:
- *
- * $Log: regex.c,v $
- * Revision 1.12 1996/04/25 16:20:59 mcs
- * make re_exec() match "" with ".*" and similar patterns
- * hopefully this change doesn't break anything else!
- *
- * Revision 1.11 1994/12/14 21:33:45 mcs
- * use new NEED_BSDREGEX
- * fix pmatch() prototype
- *
- * Revision 1.10 1994/12/12 18:16:39 mcs
- * use on NetBSD
- *
- * Revision 1.9 1994/11/15 19:16:35 mcs
- * add (CHAR) cast to make VisualC++ happy
- *
- * Revision 1.8 1994/11/08 21:14:32 mcs
- * WIN32 changes
- *
- * Revision 1.7 1994/07/23 19:51:24 mcs
- * use ANSI-style inline function parameters
- *
- * Revision 1.6 1993/10/18 01:52:32 tim
- * include for VMS
- *
- * Revision 1.5 1993/09/28 21:37:54 mcs
- * HP/UX needs the regex we include (not in its libc)
- *
- * Revision 1.4 1993/08/27 15:59:52 mcs
- * use CHAR for deftab
- *
- * Revision 1.3 1993/08/27 15:49:47 mcs
- * added missing 0 to octal constants
- * use unsigned char for CHAR under DOS
- *
- * Revision 1.2 1993/08/27 14:57:48 mcs
- * add proto. for pmatch
- *
- * Revision 1.1 1993/08/18 21:20:02 mcs
- * Initial revision
- *
- * Revision 1.4 1991/10/17 03:56:42 oz
- * miscellaneous changes, small cleanups etc.
- *
- * Revision 1.3 1989/04/01 14:18:09 oz
- * Change all references to a dfa: this is actually an nfa.
- *
- * Revision 1.2 88/08/28 15:36:04 oz
- * Use a complement bitmap to represent NCL.
- * This removes the need to have seperate
- * code in the pmatch case block - it is
- * just CCL code now.
- *
- * Use the actual CCL code in the CLO
- * section of pmatch. No need for a recursive
- * pmatch call.
- *
- * Use a bitmap table to set char bits in an
- * 8-bit chunk.
- *
- * Interfaces:
- * re_comp: compile a regular expression into a NFA.
- *
- * char *re_comp(s)
- * char *s;
- *
- * re_exec: execute the NFA to match a pattern.
- *
- * int re_exec(s)
- * char *s;
- *
- * re_modw change re_exec's understanding of what a "word"
- * looks like (for \< and \>) by adding into the
- * hidden word-syntax table.
- *
- * void re_modw(s)
- * char *s;
- *
- * re_subs: substitute the matched portions in a new string.
- *
- * int re_subs(src, dst)
- * char *src;
- * char *dst;
- *
- * re_fail: failure routine for re_exec.
- *
- * void re_fail(msg, op)
- * char *msg;
- * char op;
- *
- * Regular Expressions:
- *
- * [1] char matches itself, unless it is a special
- * character (metachar): . \ [ ] * + ^ $
- *
- * [2] . matches any character.
- *
- * [3] \ matches the character following it, except
- * when followed by a left or right round bracket,
- * a digit 1 to 9 or a left or right angle bracket.
- * (see [7], [8] and [9])
- * It is used as an escape character for all
- * other meta-characters, and itself. When used
- * in a set ([4]), it is treated as an ordinary
- * character.
- *
- * [4] [set] matches one of the characters in the set.
- * If the first character in the set is "^",
- * it matches a character NOT in the set, i.e.
- * complements the set. A shorthand S-E is
- * used to specify a set of characters S upto
- * E, inclusive. The special characters "]" and
- * "-" have no special meaning if they appear
- * as the first chars in the set.
- * examples: match:
- *
- * [a-z] any lowercase alpha
- *
- * [^]-] any char except ] and -
- *
- * [^A-Z] any char except uppercase
- * alpha
- *
- * [a-zA-Z] any alpha
- *
- * [5] * any regular expression form [1] to [4], followed by
- * closure char (*) matches zero or more matches of
- * that form.
- *
- * [6] + same as [5], except it matches one or more.
- *
- * [7] a regular expression in the form [1] to [10], enclosed
- * as \(form\) matches what form matches. The enclosure
- * creates a set of tags, used for [8] and for
- * pattern substution. The tagged forms are numbered
- * starting from 1.
- *
- * [8] a \ followed by a digit 1 to 9 matches whatever a
- * previously tagged regular expression ([7]) matched.
- *
- * [9] \< a regular expression starting with a \< construct
- * \> and/or ending with a \> construct, restricts the
- * pattern matching to the beginning of a word, and/or
- * the end of a word. A word is defined to be a character
- * string beginning and/or ending with the characters
- * A-Z a-z 0-9 and _. It must also be preceded and/or
- * followed by any character outside those mentioned.
- *
- * [10] a composite regular expression xy where x and y
- * are in the form [1] to [10] matches the longest
- * match of x followed by a match for y.
- *
- * [11] ^ a regular expression starting with a ^ character
- * $ and/or ending with a $ character, restricts the
- * pattern matching to the beginning of the line,
- * or the end of line. [anchors] Elsewhere in the
- * pattern, ^ and $ are treated as ordinary characters.
- *
- *
- * Acknowledgements:
- *
- * HCR's Hugh Redelmeier has been most helpful in various
- * stages of development. He convinced me to include BOW
- * and EOW constructs, originally invented by Rob Pike at
- * the University of Toronto.
- *
- * References:
- * Software tools Kernighan & Plauger
- * Software tools in Pascal Kernighan & Plauger
- * Grep [rsx-11 C dist] David Conroy
- * ed - text editor Un*x Programmer's Manual
- * Advanced editing on Un*x B. W. Kernighan
- * RegExp routines Henry Spencer
- *
- * Notes:
- *
- * This implementation uses a bit-set representation for character
- * classes for speed and compactness. Each character is represented
- * by one bit in a 128-bit block. Thus, CCL always takes a
- * constant 16 bytes in the internal nfa, and re_exec does a single
- * bit comparison to locate the character in the set.
- *
- * Examples:
- *
- * pattern: foo*.*
- * compile: CHR f CHR o CLO CHR o END CLO ANY END END
- * matches: fo foo fooo foobar fobar foxx ...
- *
- * pattern: fo[ob]a[rz]
- * compile: CHR f CHR o CCL bitset CHR a CCL bitset END
- * matches: fobar fooar fobaz fooaz
- *
- * pattern: foo\\+
- * compile: CHR f CHR o CHR o CHR \ CLO CHR \ END END
- * matches: foo\ foo\\ foo\\\ ...
- *
- * pattern: \(foo\)[1-3]\1 (same as foo[1-3]foo)
- * compile: BOT 1 CHR f CHR o CHR o EOT 1 CCL bitset REF 1 END
- * matches: foo1foo foo2foo foo3foo
- *
- * pattern: \(fo.*\)-\1
- * compile: BOT 1 CHR f CHR o CLO ANY END EOT 1 CHR - REF 1 END
- * matches: foo-foo fo-fo fob-fob foobar-foobar ...
- */
-
-#define MAXNFA 1024
-#define MAXTAG 10
-
-#define OKP 1
-#define NOP 0
-
-#define CHR 1
-#define ANY 2
-#define CCL 3
-#define BOL 4
-#define EOL 5
-#define BOT 6
-#define EOT 7
-#define BOW 8
-#define EOW 9
-#define REF 10
-#define CLO 11
-
-#define END 0
-
-/*
- * The following defines are not meant to be changeable.
- * They are for readability only.
- */
-#define MAXCHR 128
-#define CHRBIT 8
-#define BITBLK MAXCHR/CHRBIT
-#define BLKIND 0170
-#define BITIND 07
-
-#define ASCIIB 0177
-
-#if defined( DOS ) || defined( _WIN32 ) || defined(SUN)
-typedef unsigned char CHAR;
-#else /* DOS */
-typedef /*unsigned*/ char CHAR;
-#endif /* DOS */
-
-static int tagstk[MAXTAG]; /* subpat tag stack..*/
-static CHAR nfa[MAXNFA]; /* automaton.. */
-static int sta = NOP; /* status of lastpat */
-
-static CHAR bittab[BITBLK]; /* bit table for CCL */
- /* pre-set bits... */
-static CHAR bitarr[] = {1,2,4,8,16,32,64,128};
-
-#ifdef DEBUG
-static void nfadump(CHAR *);
-void symbolic(char *);
-#endif
-
-static void
-chset(CHAR c)
-{
- bittab[((c) & BLKIND) >> 3] |= bitarr[(c) & BITIND];
-}
-
-#define badpat(x) (*nfa = END, x)
-#define store(x) *mp++ = x
-
-char *
-re_comp( char *pat )
-{
- register char *p; /* pattern pointer */
- register CHAR *mp=nfa; /* nfa pointer */
- register CHAR *lp; /* saved pointer.. */
- register CHAR *sp=nfa; /* another one.. */
-
- register int tagi = 0; /* tag stack index */
- register int tagc = 1; /* actual tag count */
-
- register int n;
- register CHAR mask; /* xor mask -CCL/NCL */
- int c1, c2;
-
- if (!pat || !*pat)
- if (sta)
- return 0;
- else
- return badpat("No previous regular expression");
- sta = NOP;
-
- for (p = pat; *p; p++) {
- lp = mp;
- switch(*p) {
-
- case '.': /* match any char.. */
- store(ANY);
- break;
-
- case '^': /* match beginning.. */
- if (p == pat)
- store(BOL);
- else {
- store(CHR);
- store(*p);
- }
- break;
-
- case '$': /* match endofline.. */
- if (!*(p+1))
- store(EOL);
- else {
- store(CHR);
- store(*p);
- }
- break;
-
- case '[': /* match char class..*/
- store(CCL);
-
- if (*++p == '^') {
- mask = 0377;
- p++;
- }
- else
- mask = 0;
-
- if (*p == '-') /* real dash */
- chset(*p++);
- if (*p == ']') /* real brac */
- chset(*p++);
- while (*p && *p != ']') {
- if (*p == '-' && *(p+1) && *(p+1) != ']') {
- p++;
- c1 = *(p-2) + 1;
- c2 = *p++;
- while (c1 <= c2)
- chset((CHAR)c1++);
- }
-#ifdef EXTEND
- else if (*p == '\\' && *(p+1)) {
- p++;
- chset(*p++);
- }
-#endif
- else
- chset(*p++);
- }
- if (!*p)
- return badpat("Missing ]");
-
- for (n = 0; n < BITBLK; bittab[n++] = (char) 0)
- store(mask ^ bittab[n]);
-
- break;
-
- case '*': /* match 0 or more.. */
- case '+': /* match 1 or more.. */
- if (p == pat)
- return badpat("Empty closure");
- lp = sp; /* previous opcode */
- if (*lp == CLO) /* equivalence.. */
- break;
- switch(*lp) {
-
- case BOL:
- case BOT:
- case EOT:
- case BOW:
- case EOW:
- case REF:
- return badpat("Illegal closure");
- default:
- break;
- }
-
- if (*p == '+')
- for (sp = mp; lp < sp; lp++)
- store(*lp);
-
- store(END);
- store(END);
- sp = mp;
- while (--mp > lp)
- *mp = mp[-1];
- store(CLO);
- mp = sp;
- break;
-
- case '\\': /* tags, backrefs .. */
- switch(*++p) {
-
- case '(':
- if (tagc < MAXTAG) {
- tagstk[++tagi] = tagc;
- store(BOT);
- store(tagc++);
- }
- else
- return badpat("Too many \\(\\) pairs");
- break;
- case ')':
- if (*sp == BOT)
- return badpat("Null pattern inside \\(\\)");
- if (tagi > 0) {
- store(EOT);
- store(tagstk[tagi--]);
- }
- else
- return badpat("Unmatched \\)");
- break;
- case '<':
- store(BOW);
- break;
- case '>':
- if (*sp == BOW)
- return badpat("Null pattern inside \\<\\>");
- store(EOW);
- break;
- case '1':
- case '2':
- case '3':
- case '4':
- case '5':
- case '6':
- case '7':
- case '8':
- case '9':
- n = *p-'0';
- if (tagi > 0 && tagstk[tagi] == n)
- return badpat("Cyclical reference");
- if (tagc > n) {
- store(REF);
- store(n);
- }
- else
- return badpat("Undetermined reference");
- break;
-#ifdef EXTEND
- case 'b':
- store(CHR);
- store('\b');
- break;
- case 'n':
- store(CHR);
- store('\n');
- break;
- case 'f':
- store(CHR);
- store('\f');
- break;
- case 'r':
- store(CHR);
- store('\r');
- break;
- case 't':
- store(CHR);
- store('\t');
- break;
-#endif
- default:
- store(CHR);
- store(*p);
- }
- break;
-
- default : /* an ordinary char */
- store(CHR);
- store(*p);
- break;
- }
- sp = lp;
- }
- if (tagi > 0)
- return badpat("Unmatched \\(");
- store(END);
- sta = OKP;
- return 0;
-}
-
-
-static char *bol;
-char *bopat[MAXTAG];
-char *eopat[MAXTAG];
-#ifdef NEEDPROTOS
-static char *pmatch( char *lp, CHAR *ap );
-#else /* NEEDPROTOS */
-static char *pmatch();
-#endif /* NEEDPROTOS */
-
-/*
- * re_exec:
- * execute nfa to find a match.
- *
- * special cases: (nfa[0])
- * BOL
- * Match only once, starting from the
- * beginning.
- * CHR
- * First locate the character without
- * calling pmatch, and if found, call
- * pmatch for the remaining string.
- * END
- * re_comp failed, poor luser did not
- * check for it. Fail fast.
- *
- * If a match is found, bopat[0] and eopat[0] are set
- * to the beginning and the end of the matched fragment,
- * respectively.
- *
- */
-
-int
-re_exec( char *lp )
-{
- register char c;
- register char *ep = 0;
- register CHAR *ap = nfa;
-
- bol = lp;
-
- bopat[0] = 0;
- bopat[1] = 0;
- bopat[2] = 0;
- bopat[3] = 0;
- bopat[4] = 0;
- bopat[5] = 0;
- bopat[6] = 0;
- bopat[7] = 0;
- bopat[8] = 0;
- bopat[9] = 0;
-
- switch(*ap) {
-
- case BOL: /* anchored: match from BOL only */
- ep = pmatch(lp,ap);
- break;
- case CHR: /* ordinary char: locate it fast */
- c = *(ap+1);
- while (*lp && *lp != c)
- lp++;
- if (!*lp) /* if EOS, fail, else fall thru. */
- return 0;
- default: /* regular matching all the way. */
- do {
- if ((ep = pmatch(lp,ap)))
- break;
- lp++;
- } while (*lp);
-
- break;
- case END: /* munged automaton. fail always */
- return 0;
- }
- if (!ep)
- return 0;
-
- bopat[0] = lp;
- eopat[0] = ep;
- return 1;
-}
-
-/*
- * pmatch: internal routine for the hard part
- *
- * This code is partly snarfed from an early grep written by
- * David Conroy. The backref and tag stuff, and various other
- * innovations are by oz.
- *
- * special case optimizations: (nfa[n], nfa[n+1])
- * CLO ANY
- * We KNOW .* will match everything upto the
- * end of line. Thus, directly go to the end of
- * line, without recursive pmatch calls. As in
- * the other closure cases, the remaining pattern
- * must be matched by moving backwards on the
- * string recursively, to find a match for xy
- * (x is ".*" and y is the remaining pattern)
- * where the match satisfies the LONGEST match for
- * x followed by a match for y.
- * CLO CHR
- * We can again scan the string forward for the
- * single char and at the point of failure, we
- * execute the remaining nfa recursively, same as
- * above.
- *
- * At the end of a successful match, bopat[n] and eopat[n]
- * are set to the beginning and end of subpatterns matched
- * by tagged expressions (n = 1 to 9).
- *
- */
-
-#ifndef re_fail
-extern void re_fail();
-#endif /* re_fail */
-
-/*
- * character classification table for word boundary operators BOW
- * and EOW. the reason for not using ctype macros is that we can
- * let the user add into our own table. see re_modw. This table
- * is not in the bitset form, since we may wish to extend it in the
- * future for other character classifications.
- *
- * TRUE for 0-9 A-Z a-z _
- */
-static char chrtyp[MAXCHR] = {
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 0, 0,
- 0, 0, 0, 0, 0, 0, 0, 0, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 0, 0,
- 0, 0, 0, 0, 0, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 0, 0, 0, 0, 1, 0, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
- 1, 1, 1, 0, 0, 0, 0, 0
- };
-
-#define inascii(x) (0177&(x))
-#define iswordc(x) chrtyp[inascii(x)]
-#define isinset(x,y) ((x)[((y)&BLKIND)>>3] & bitarr[(y)&BITIND])
-
-/*
- * skip values for CLO XXX to skip past the closure
- */
-
-#define ANYSKIP 2 /* [CLO] ANY END ... */
-#define CHRSKIP 3 /* [CLO] CHR chr END ... */
-#define CCLSKIP 18 /* [CLO] CCL 16bytes END ... */
-
-static char *
-pmatch( char *lp, CHAR *ap)
-{
- register int op, c, n;
- register char *e; /* extra pointer for CLO */
- register char *bp; /* beginning of subpat.. */
- register char *ep; /* ending of subpat.. */
- char *are; /* to save the line ptr. */
-
- while ((op = *ap++) != END)
- switch(op) {
-
- case CHR:
- if (*lp++ != *ap++)
- return 0;
- break;
- case ANY:
- if (!*lp++)
- return 0;
- break;
- case CCL:
- c = *lp++;
- if (!isinset(ap,c))
- return 0;
- ap += BITBLK;
- break;
- case BOL:
- if (lp != bol)
- return 0;
- break;
- case EOL:
- if (*lp)
- return 0;
- break;
- case BOT:
- bopat[*ap++] = lp;
- break;
- case EOT:
- eopat[*ap++] = lp;
- break;
- case BOW:
- if (lp!=bol && iswordc(lp[-1]) || !iswordc(*lp))
- return 0;
- break;
- case EOW:
- if (lp==bol || !iswordc(lp[-1]) || iswordc(*lp))
- return 0;
- break;
- case REF:
- n = *ap++;
- bp = bopat[n];
- ep = eopat[n];
- while (bp < ep)
- if (*bp++ != *lp++)
- return 0;
- break;
- case CLO:
- are = lp;
- switch(*ap) {
-
- case ANY:
- while (*lp)
- lp++;
- n = ANYSKIP;
- break;
- case CHR:
- c = *(ap+1);
- while (*lp && c == *lp)
- lp++;
- n = CHRSKIP;
- break;
- case CCL:
- while ((c = *lp) && isinset(ap+1,c))
- lp++;
- n = CCLSKIP;
- break;
- default:
- re_fail("closure: bad nfa.", *ap);
- return 0;
- }
-
- ap += n;
-
- while (lp >= are) {
- if (e = pmatch(lp, ap))
- return e;
- --lp;
- }
- return 0;
- default:
- re_fail("re_exec: bad nfa.", op);
- return 0;
- }
- return lp;
-}
-
-/*
- * re_modw:
- * add new characters into the word table to change re_exec's
- * understanding of what a word should look like. Note that we
- * only accept additions into the word definition.
- *
- * If the string parameter is 0 or null string, the table is
- * reset back to the default containing A-Z a-z 0-9 _. [We use
- * the compact bitset representation for the default table]
- */
-
-static CHAR deftab[16] = {
- 0, 0, 0, 0, 0, 0, 0377, 003, 0376, 0377, 0377, 0207,
- 0376, 0377, 0377, 007
-};
-
-void
-re_modw( char *s )
-{
- register int i;
-
- if (!s || !*s) {
- for (i = 0; i < MAXCHR; i++)
- if (!isinset(deftab,i))
- iswordc(i) = 0;
- }
- else
- while(*s)
- iswordc(*s++) = 1;
-}
-
-/*
- * re_subs:
- * substitute the matched portions of the src in dst.
- *
- * & substitute the entire matched pattern.
- *
- * \digit substitute a subpattern, with the given tag number.
- * Tags are numbered from 1 to 9. If the particular
- * tagged subpattern does not exist, null is substituted.
- */
-int
-re_subs( char *src, char *dst)
-{
- register char c;
- register int pin;
- register char *bp;
- register char *ep;
-
- if (!*src || !bopat[0])
- return 0;
-
- while (c = *src++) {
- switch(c) {
-
- case '&':
- pin = 0;
- break;
-
- case '\\':
- c = *src++;
- if (c >= '0' && c <= '9') {
- pin = c - '0';
- break;
- }
-
- default:
- *dst++ = c;
- continue;
- }
-
- if ((bp = bopat[pin]) && (ep = eopat[pin])) {
- while (*bp && bp < ep)
- *dst++ = *bp++;
- if (bp < ep)
- return 0;
- }
- }
- *dst = (char) 0;
- return 1;
-}
-
-#ifdef DEBUG
-/*
- * symbolic - produce a symbolic dump of the nfa
- */
-void
-symbolic( char *s )
-{
- (void) printf("pattern: %s\n", s);
- (void) printf("nfacode:\n");
- nfadump(nfa);
-}
-
-static void
-nfadump( CHAR *ap)
-{
- register int n;
-
- while (*ap != END)
- switch(*ap++) {
- case CLO:
- (void) printf("CLOSURE");
- nfadump(ap);
- switch(*ap) {
- case CHR:
- n = CHRSKIP;
- break;
- case ANY:
- n = ANYSKIP;
- break;
- case CCL:
- n = CCLSKIP;
- break;
- }
- ap += n;
- break;
- case CHR:
- (void) printf("\tCHR %c\n",*ap++);
- break;
- case ANY:
- (void) printf("\tANY .\n");
- break;
- case BOL:
- (void) printf("\tBOL -\n");
- break;
- case EOL:
- (void) printf("\tEOL -\n");
- break;
- case BOT:
- (void) printf("BOT: %d\n",*ap++);
- break;
- case EOT:
- (void) printf("EOT: %d\n",*ap++);
- break;
- case BOW:
- (void) printf("BOW\n");
- break;
- case EOW:
- (void) printf("EOW\n");
- break;
- case REF:
- (void) printf("REF: %d\n",*ap++);
- break;
- case CCL:
- (void) printf("\tCCL [");
- for (n = 0; n < MAXCHR; n++)
- if (isinset(ap,(CHAR)n)) {
- if (n < ' ')
- (void) printf("^%c", n ^ 0x040);
- else
- (void) printf("%c", n);
- }
- (void) printf("]\n");
- ap += BITBLK;
- break;
- default:
- (void) printf("bad nfa. opcode %o\n", ap[-1]);
- exit(1);
- break;
- }
-}
-#endif
-#endif /* MACOS or DOS or NEED_BSDREGEX */
diff --git a/usr/src/lib/libldap4/common/rename.c b/usr/src/lib/libldap4/common/rename.c
deleted file mode 100644
index 3a754df30d..0000000000
--- a/usr/src/lib/libldap4/common/rename.c
+++ /dev/null
@@ -1,176 +0,0 @@
-/*
- *
- * Copyright 1998 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- *
- *
- * Comments:
- *
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#include <stdio.h>
-#include <string.h>
-
-#ifdef MACOS
-#include "macos.h"
-#endif /* MACOS */
-
-#if !defined( MACOS ) && !defined( DOS )
-#include <sys/types.h>
-#include <sys/socket.h>
-#endif
-
-#include "lber.h"
-#include "ldap.h"
-#include "ldap-private.h"
-#include "ldap-int.h"
-
-BerElement * ldap_build_rename_req ( LDAP *ld, char *dn, char *newrdn, char *newparent,
- int deleteoldrdn, LDAPControl **serverctrls)
-{
- BerElement *ber;
- int rc;
-
- /*
- * A modify rdn request looks like this:
- * ModifyRDNRequest ::= SEQUENCE {
- * entry LDAPDN,
- * newrdn RelativeLDAPDN,
- * deleteoldrdn BOOLEAN
- * newSuperior [0] LDAPDN OPTIONAL
- * }
- */
-
- /* create a message to send */
- if ( (ber = alloc_ber_with_options( ld )) == NULLBER ) {
- return( NULLBER );
- }
-
- if ( ber_printf( ber, "{it{ssb", ++ld->ld_msgid, LDAP_REQ_MODRDN, dn,
- newrdn, deleteoldrdn ) == -1 ) {
- ld->ld_errno = LDAP_ENCODING_ERROR;
- ber_free( ber, 1 );
- return( NULLBER );
- }
-
- if (newparent) {
- if ( ber_printf( ber, "ts}", LDAP_TAG_NEWPARENT, newparent) == -1){
- ld->ld_errno = LDAP_ENCODING_ERROR;
- ber_free( ber, 1 );
- return( NULLBER );
- }
-
- } else if ( ber_printf( ber, "}" ) == -1 ) {
- ld->ld_errno = LDAP_ENCODING_ERROR;
- ber_free( ber, 1 );
- return( NULLBER );
- }
- /* LDAPv3 */
- /* Code controls if any */
- if (serverctrls && serverctrls[0]) {
- if (ldap_controls_code(ber, serverctrls) != LDAP_SUCCESS){
- ld->ld_errno = LDAP_ENCODING_ERROR;
- ber_free( ber, 1 );
- return( NULLBER );
- }
- } else if (ld->ld_srvctrls && ld->ld_srvctrls[0]) {
- /* Otherwise, is there any global server ctrls ? */
- if (ldap_controls_code(ber, ld->ld_srvctrls) != LDAP_SUCCESS){
- ld->ld_errno = LDAP_ENCODING_ERROR;
- ber_free( ber, 1 );
- return( NULLBER );
- }
- }
-
- if ( ber_printf( ber, "}" ) == -1 ) {
- ld->ld_errno = LDAP_ENCODING_ERROR;
- ber_free( ber, 1 );
- return( NULLBER );
- }
-
- return (ber);
-}
-
-/* ldap_rename - Modify the name of an entry.
- * Parameters :
- * ld : LDAP descriptor.
- * dn : DN of the object to rename.
- * newrdn : New RDN to give to the entry.
- * newparent : the parent or superior entry. If NULL only RDN is changed.
- * "" means the root DN.
- * deleteoldrdn : Boolean to indicate wether or not to remove the old RDN value.
- * serverctrls : List of Server controls.
- * clientctrls : List of client controls.
- * msgidp : the msg id return if renamed succeded.
- */
-
-int ldap_rename(LDAP *ld, char *dn, char *newrdn, char *newparent, int deleteoldrdn,
- LDAPControl ** serverctrls, LDAPControl **clientctrls, int *msgidp)
-{
- BerElement *ber;
- int rv;
-
-#ifdef _REENTRANT
- LOCK_LDAP(ld);
-#endif
- Debug( LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 87, "ldap_rename\n"), 0, 0, 0 );
-
- if ((ber = ldap_build_rename_req(ld, dn, newrdn, newparent, deleteoldrdn, serverctrls)) == NULLBER){
- rv = ld->ld_errno;
- if (rv == LDAP_SUCCESS)
- rv = LDAP_OTHER;
-#ifdef _REENTRANT
- UNLOCK_LDAP(ld);
-#endif
- return (rv);
- }
-
- /* send the message */
- rv = send_initial_request( ld, LDAP_REQ_MODRDN, dn, ber );
- if (rv == -1) {
- rv = ld->ld_errno;
- if (rv == LDAP_SUCCESS){
- rv = LDAP_OTHER;
- }
-
-#ifdef _REENTRANT
- UNLOCK_LDAP(ld);
-#endif
- return (rv);
- }
-
- *msgidp = rv;
-#ifdef _REENTRANT
- UNLOCK_LDAP(ld);
-#endif
- return (LDAP_SUCCESS);
-
-}
-
-
-int ldap_rename_s(LDAP *ld, char *dn, char *newrdn, char *newparent, int deleteoldrdn,
- LDAPControl ** serverctrls, LDAPControl **clientctrls)
-{
- int msgid;
- int retcode = LDAP_SUCCESS;
- LDAPMessage *res;
-
- if ((retcode = ldap_rename(ld, dn, newrdn, newparent, deleteoldrdn, serverctrls, clientctrls, &msgid)) != LDAP_SUCCESS)
- return (retcode);
- if (ldap_result(ld, msgid, 1, (struct timeval *)NULL, &res ) == -1)
- return (ld->ld_errno );
-
-#ifdef _REENTRANT
- LOCK_LDAP(ld);
-#endif
- retcode = ldap_parse_result( ld, res, &ld->ld_errno, &ld->ld_matched, &ld->ld_error,
- &ld->ld_referrals, &ld->ld_ret_ctrls, 1);
- if (retcode == LDAP_SUCCESS)
- retcode = ld->ld_errno;
-#ifdef _REENTRANT
- UNLOCK_LDAP(ld);
-#endif
- return (retcode);
-}
diff --git a/usr/src/lib/libldap4/common/request.c b/usr/src/lib/libldap4/common/request.c
deleted file mode 100644
index 7b0af4c0f7..0000000000
--- a/usr/src/lib/libldap4/common/request.c
+++ /dev/null
@@ -1,779 +0,0 @@
-/*
- * Copyright 1998-2002 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*
- * Copyright (c) 1995 Regents of the University of Michigan.
- * All rights reserved.
- *
- * request.c - sending of ldap requests; handling of referrals
- */
-
-#ifndef lint
-static char copyright[] = "@(#) Copyright (c) 1995 Regents of the University of Michigan.\nAll rights reserved.\n";
-#endif
-
-#include <stdio.h>
-#include <string.h>
-#ifdef MACOS
-#include <stdlib.h>
-#include <time.h>
-#include "macos.h"
-#else /* MACOS */
-#if defined( DOS ) || defined( _WIN32 )
-#include "msdos.h"
-#include <time.h>
-#include <stdlib.h>
-#ifdef PCNFS
-#include <tklib.h>
-#include <tk_errno.h>
-#include <bios.h>
-#endif /* PCNFS */
-#ifdef NCSA
-#include "externs.h"
-#endif /* NCSA */
-#else /* DOS */
-#include <sys/time.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <errno.h>
-#ifdef _AIX
-#include <sys/select.h>
-#endif /* _AIX */
-#include "portable.h"
-#endif /* DOS */
-#endif /* MACOS */
-#ifdef VMS
-#include "ucx_select.h"
-#endif
-#include "lber.h"
-#include "ldap.h"
-#include "ldap-private.h"
-#include "ldap-int.h"
-
-#ifdef USE_SYSCONF
-#include <unistd.h>
-#endif /* USE_SYSCONF */
-
-#ifdef NEEDPROTOS
-static LDAPConn *find_connection( LDAP *ld, LDAPServer *srv, int any );
-static void use_connection( LDAP *ld, LDAPConn *lc );
-static void free_servers( LDAPServer *srvlist );
-#else /* NEEDPROTOS */
-static LDAPConn *find_connection();
-static void use_connection();
-static void free_servers();
-#endif /* NEEDPROTOS */
-
-
-#ifdef LDAP_DNS
-#ifdef NEEDPROTOS
-static LDAPServer *dn2servers( LDAP *ld, char *dn );
-#else /* NEEDPROTOS */
-static LDAPServer *dn2servers();
-#endif /* NEEDPROTOS */
-#endif /* LDAP_DNS */
-
-
-BerElement *
-alloc_ber_with_options( LDAP *ld )
-{
- BerElement *ber;
-
- if (( ber = ber_alloc_t( ld->ld_lberoptions )) == NULLBER ) {
- ld->ld_errno = LDAP_NO_MEMORY;
-#ifdef STR_TRANSLATION
- } else {
- set_ber_options( ld, ber );
-#endif /* STR_TRANSLATION */
- }
-
- return( ber );
-}
-
-
-void
-set_ber_options( LDAP *ld, BerElement *ber )
-{
- ber->ber_options = ld->ld_lberoptions;
-#ifdef STR_TRANSLATION
- if (( ld->ld_lberoptions & LBER_TRANSLATE_STRINGS ) != 0 ) {
- ber_set_string_translators( ber,
- ld->ld_lber_encode_translate_proc,
- ld->ld_lber_decode_translate_proc );
- }
-#endif /* STR_TRANSLATION */
-}
-
-
-int
-send_initial_request( LDAP *ld, unsigned int msgtype, char *dn,
- BerElement *ber )
-{
- LDAPServer *servers;
- int rv;
-
-#ifdef _REENTRANT
- LOCK_LDAP(ld);
-#endif
- Debug( LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 209, "send_initial_request\n"), 0, 0, 0 );
-
-#ifdef LDAP_DNS
- if (( ld->ld_options & LDAP_OPT_DNS ) != 0 && ldap_is_dns_dn( dn )) {
- if (( servers = dn2servers( ld, dn )) == NULL ) {
- ber_free( ber, 1 );
-#ifdef _REENTRANT
- UNLOCK_LDAP(ld);
-#endif
- return( -1 );
- }
-
-#ifdef LDAP_DEBUG
- if ( ldap_debug & LDAP_DEBUG_TRACE ) {
- LDAPServer *srv;
-
- for ( srv = servers; srv != NULL;
- srv = srv->lsrv_next ) {
- fprintf( stderr,
- "LDAP server %s: dn %s, port %d\n",
- srv->lsrv_host, ( srv->lsrv_dn == NULL ) ?
- "(default)" : srv->lsrv_dn,
- srv->lsrv_port );
- }
- }
-#endif /* LDAP_DEBUG */
- } else {
-#endif /* LDAP_DNS */
- /*
- * use of DNS is turned off or this is an X.500 DN...
- * use our default connection
- */
- servers = NULL;
-#ifdef LDAP_DNS
- }
-#endif /* LDAP_DNS */
-
-#ifdef _REENTRANT
- UNLOCK_LDAP(ld);
-#endif
- rv = send_server_request( ld, ber, ld->ld_msgid, NULL, servers,
- NULL, 0 );
- return ( rv );
-}
-
-int
-send_server_request( LDAP *ld, BerElement *ber, int msgid, LDAPRequest
- *parentreq, LDAPServer *srvlist, LDAPConn *lc, int bind )
-{
- LDAPRequest *lr;
- int err;
-
-#ifdef _REENTRANT
- LOCK_LDAP(ld);
-#endif
- Debug( LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 210, "send_server_request\n"), 0, 0, 0 );
-
- ld->ld_errno = LDAP_SUCCESS; /* optimistic */
- /* Be optimistic : increment parentreq initially.
- If it fails we must decrement it */
- if (parentreq != NULL){
- parentreq->lr_outrefcnt++;
- }
-
- if ( lc == NULL ) {
- if ( srvlist == NULL ) {
- if (ld->ld_defconn == NULL){ /* Not connected yet on the default connection, ie init was called not open */
- if ((err = open_default_ldap_connection(ld)) != LDAP_SUCCESS){
- ld->ld_errno = err;
- ber_free(ber, 1);
- if (parentreq != NULL){
- parentreq->lr_outrefcnt--;
- }
-#ifdef _REENTRANT
- UNLOCK_LDAP(ld);
-#endif
- return( -1 );
- }
- }
-
- lc = ld->ld_defconn;
- } else {
- if (( lc = find_connection( ld, srvlist, 1 )) ==
- NULL ) {
- lc = new_connection( ld, &srvlist, 0, 1, bind );
- }
- free_servers( srvlist );
- }
- }
-
- if ( lc == NULL || lc->lconn_status != LDAP_CONNST_CONNECTED ) {
- ber_free( ber, 1 );
- if ( ld->ld_errno == LDAP_SUCCESS ) {
- ld->ld_errno = LDAP_SERVER_DOWN;
- }
- if (parentreq != NULL){
- parentreq->lr_outrefcnt--;
- }
-#ifdef _REENTRANT
- UNLOCK_LDAP(ld);
-#endif
- return( -1 );
- }
-
- use_connection( ld, lc );
- if (( lr = (LDAPRequest *)calloc( 1, sizeof( LDAPRequest ))) ==
- NULL ) {
- ld->ld_errno = LDAP_NO_MEMORY;
- free_connection( ld, lc, 0, 0 );
- ber_free( ber, 1 );
-#ifdef _REENTRANT
- UNLOCK_LDAP(ld);
-#endif
- return( -1 );
- }
- lr->lr_msgid = msgid;
- lr->lr_status = LDAP_REQST_INPROGRESS;
- lr->lr_res_errno = LDAP_SUCCESS; /* optimistic */
- lr->lr_ber = ber;
- lr->lr_conn = lc;
- if ( parentreq != NULL ) { /* sub-request */
-/* ++parentreq->lr_outrefcnt; */
- lr->lr_origid = parentreq->lr_origid;
- lr->lr_parentcnt = parentreq->lr_parentcnt + 1;
- lr->lr_parent = parentreq;
- lr->lr_refnext = parentreq->lr_refnext;
- parentreq->lr_refnext = lr;
- } else { /* original request */
- lr->lr_origid = lr->lr_msgid;
- }
-
- if (( lr->lr_next = ld->ld_requests ) != NULL ) {
- lr->lr_next->lr_prev = lr;
- }
- ld->ld_requests = lr;
- lr->lr_prev = NULL;
-
- if ( ber_flush( lc->lconn_sb, ber, 0 ) != 0 ) {
-#ifdef notyet
- extern int errno;
-
- if ( errno == EWOULDBLOCK ) {
- /* need to continue write later */
- lr->lr_status = LDAP_REQST_WRITING;
- mark_select_write( ld, lc->lconn_sb );
- } else {
-#else /* notyet */
- ld->ld_errno = LDAP_SERVER_DOWN;
- free_request( ld, lr );
- free_connection( ld, lc, 0, 0 );
-#ifdef _REENTRANT
- UNLOCK_LDAP(ld);
-#endif
- return( -1 );
-#endif /* notyet */
-#ifdef notyet
- }
-#endif /* notyet */
- } else {
- if ( parentreq == NULL ) {
- ber->ber_end = ber->ber_ptr;
- ber->ber_ptr = ber->ber_buf;
- }
-
- /* sent -- waiting for a response */
- mark_select_read( ld, lc->lconn_sb );
- }
-
- ld->ld_errno = LDAP_SUCCESS;
-#ifdef _REENTRANT
- UNLOCK_LDAP(ld);
-#endif
- return( msgid );
-}
-
-
-LDAPConn *
-new_connection( LDAP *ld, LDAPServer **srvlistp, int use_ldsb,
- int connect, int bind )
-{
- LDAPConn *lc;
- LDAPServer *prevsrv, *srv;
- Sockbuf *sb;
-
- /*
- * make a new LDAP server connection
- * XXX open connection synchronously for now
- */
- if (( lc = (LDAPConn *)calloc( 1, sizeof( LDAPConn ))) == NULL ||
- ( !use_ldsb && ( sb = (Sockbuf *)calloc( 1, sizeof( Sockbuf )))
- == NULL )) {
- if ( lc != NULL ) {
- free( (char *)lc );
- }
- ld->ld_errno = LDAP_NO_MEMORY;
- return( NULL );
- }
-
-#ifdef _REENTRANT
- LOCK_LDAP(ld);
-#endif
- lc->lconn_sb = ( use_ldsb ) ? &ld->ld_sb : sb;
-
- if ( connect ) {
- prevsrv = NULL;
-
- for ( srv = *srvlistp; srv != NULL; srv = srv->lsrv_next ) {
- if ( open_ldap_connection( ld, lc->lconn_sb,
- srv->lsrv_host, srv->lsrv_port,
- &lc->lconn_krbinstance, 0 ) != -1 ) {
- break;
- }
- prevsrv = srv;
- }
-
- if ( srv == NULL ) {
- if ( !use_ldsb ) {
- free( (char *)lc->lconn_sb );
- }
- free( (char *)lc );
- ld->ld_errno = LDAP_SERVER_DOWN;
-#ifdef _REENTRANT
- UNLOCK_LDAP(ld);
-#endif
- return( NULL );
- }
-
- if ( prevsrv == NULL ) {
- *srvlistp = srv->lsrv_next;
- } else {
- prevsrv->lsrv_next = srv->lsrv_next;
- }
- lc->lconn_server = srv;
- }
-
- lc->lconn_status = LDAP_CONNST_CONNECTED;
- lc->lconn_next = ld->ld_conns;
- ld->ld_conns = lc;
-
- /*
- * XXX for now, we always do a synchronous bind. This will have
- * to change in the long run...
- */
- if ( bind ) {
- int err, freepasswd, authmethod;
- char *binddn, *passwd;
- LDAPConn *savedefconn;
-
- freepasswd = err = 0;
-
- if ( ld->ld_version == LDAP_VERSION3 && ld->ld_rebindproc == NULL){
- /* Nothing to do */
- Debug(LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 1280, "new_connection: bind no needed with ldapv3\n"), 0,0,0);
- } else {
- if ( ld->ld_rebindproc == NULL ) {
- binddn = passwd = "";
- authmethod = LDAP_AUTH_SIMPLE;
- } else {
- if (( err = (*ld->ld_rebindproc)( ld, &binddn, &passwd,
- &authmethod, 0, ld->ld_rebind_extra_arg )) == LDAP_SUCCESS ) {
- freepasswd = 1;
- } else {
- ld->ld_errno = err;
- err = -1;
- }
- }
-
- if ( err == 0 ) {
- savedefconn = ld->ld_defconn;
- ld->ld_defconn = lc;
- ++lc->lconn_refcnt; /* avoid premature free */
-
- if ( ldap_bind_s( ld, binddn, passwd, authmethod ) !=
- LDAP_SUCCESS ) {
- err = -1;
- }
- --lc->lconn_refcnt;
- ld->ld_defconn = savedefconn;
- }
-
- if ( freepasswd ) {
- (*ld->ld_rebindproc)( ld, &binddn, &passwd,
- &authmethod, 1, ld->ld_rebind_extra_arg );
- }
-
- if ( err != 0 ) {
- free_connection( ld, lc, 1, 0 );
- lc = NULL;
- }
- }
- }
-
-#ifdef _REENTRANT
- UNLOCK_LDAP(ld);
-#endif
- return( lc );
-}
-
-
-static LDAPConn *
-find_connection( LDAP *ld, LDAPServer *srv, int any )
-/*
- * return an existing connection (if any) to the server srv
- * if "any" is non-zero, check for any server in the "srv" chain
- */
-{
- LDAPConn *lc;
- LDAPServer *ls;
-
-#ifdef _REENTRANT
- LOCK_LDAP(ld);
-#endif
- for ( lc = ld->ld_conns; lc != NULL; lc = lc->lconn_next ) {
- for ( ls = srv; ls != NULL; ls = ls->lsrv_next ) {
- if ( lc->lconn_server->lsrv_host != NULL &&
- ls->lsrv_host != NULL && strcasecmp(
- ls->lsrv_host, lc->lconn_server->lsrv_host ) == 0
- && ls->lsrv_port == lc->lconn_server->lsrv_port ) {
-#ifdef _REENTRANT
- UNLOCK_LDAP(ld);
-#endif
- return( lc );
- }
- if ( !any ) {
- break;
- }
- }
- }
-
-#ifdef _REENTRANT
- UNLOCK_LDAP(ld);
-#endif
- return( NULL );
-}
-
-
-
-static void
-use_connection( LDAP *ld, LDAPConn *lc )
-{
- ++lc->lconn_refcnt;
- lc->lconn_lastused = time( 0 );
-}
-
-
-void
-free_connection( LDAP *ld, LDAPConn *lc, int force, int unbind )
-{
- LDAPConn *tmplc, *prevlc;
-
- Debug( LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 211, "free_connection\n"), 0, 0, 0 );
-
- if ( force || --lc->lconn_refcnt <= 0 ) {
- if ( lc->lconn_status == LDAP_CONNST_CONNECTED ) {
- mark_select_clear( ld, lc->lconn_sb );
- if ( unbind ) {
- send_unbind( ld, lc->lconn_sb );
- }
- close_ldap_connection( lc->lconn_sb );
- if ( lc->lconn_sb->sb_ber.ber_buf != NULL ) {
- free( lc->lconn_sb->sb_ber.ber_buf );
- lc->lconn_sb->sb_ber.ber_buf = NULL;
- }
- }
- prevlc = NULL;
- for ( tmplc = ld->ld_conns; tmplc != NULL;
- tmplc = tmplc->lconn_next ) {
- if ( tmplc == lc ) {
- if ( prevlc == NULL ) {
- ld->ld_conns = tmplc->lconn_next;
- } else {
- prevlc->lconn_next = tmplc->lconn_next;
- }
- break;
- }
- }
- free_servers( lc->lconn_server );
- if ( lc->lconn_krbinstance != NULL ) {
- free( lc->lconn_krbinstance );
- }
- if ( lc->lconn_sb != &ld->ld_sb ) {
- free( (char *)lc->lconn_sb );
- }
- free( lc );
- Debug( LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 212, "free_connection: actually freed\n"),
- 0, 0, 0 );
- } else {
- lc->lconn_lastused = time( 0 );
- Debug( LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 213, "free_connection: refcnt %d\n"),
- lc->lconn_refcnt, 0, 0 );
- }
-}
-
-
-#ifdef LDAP_DEBUG
-void
-dump_connection( LDAP *ld, LDAPConn *lconns, int all )
-{
- LDAPConn *lc;
-
- fprintf( stderr, "** Connection%s:\n", all ? "s" : "" );
- for ( lc = lconns; lc != NULL; lc = lc->lconn_next ) {
- if ( lc->lconn_server != NULL ) {
- fprintf( stderr, "* host: %s port: %d%s\n",
- ( lc->lconn_server->lsrv_host == NULL ) ? "(null)"
- : lc->lconn_server->lsrv_host,
- lc->lconn_server->lsrv_port, ( lc->lconn_sb ==
- &ld->ld_sb ) ? " (default)" : "" );
- }
- fprintf( stderr, " refcnt: %d status: %s\n", lc->lconn_refcnt,
- ( lc->lconn_status == LDAP_CONNST_NEEDSOCKET ) ?
- "NeedSocket" : ( lc->lconn_status ==
- LDAP_CONNST_CONNECTING ) ? "Connecting" : "Connected" );
- fprintf( stderr, " last used: %s\n",
- ctime( &lc->lconn_lastused ));
- if ( !all ) {
- break;
- }
- }
-}
-
-
-void
-dump_requests_and_responses( LDAP *ld )
-{
- LDAPRequest *lr;
- LDAPMessage *lm, *l;
-
- fprintf( stderr, "** Outstanding Requests:\n" );
- if (( lr = ld->ld_requests ) == NULL ) {
- fprintf( stderr, " Empty\n" );
- }
- for ( ; lr != NULL; lr = lr->lr_next ) {
- fprintf( stderr, " * msgid %d, origid %d, status %s\n",
- lr->lr_msgid, lr->lr_origid, ( lr->lr_status ==
- LDAP_REQST_INPROGRESS ) ? "InProgress" :
- ( lr->lr_status == LDAP_REQST_CHASINGREFS ) ? "ChasingRefs" :
- ( lr->lr_status == LDAP_REQST_NOTCONNECTED ) ? "NotConnected" :
- "Writing" );
- fprintf( stderr, " outstanding referrals %d, parent count %d\n",
- lr->lr_outrefcnt, lr->lr_parentcnt );
- }
-
- fprintf( stderr, "** Response Queue:\n" );
-#ifdef _REENTRANT
- LOCK_RESPONSE(ld);
-#endif
- if (( lm = ld->ld_responses ) == NULLMSG ) {
- fprintf( stderr, " Empty\n" );
- }
- for ( ; lm != NULLMSG; lm = lm->lm_next ) {
- fprintf( stderr, " * msgid %d, type %d\n",
- lm->lm_msgid, lm->lm_msgtype );
- if (( l = lm->lm_chain ) != NULL ) {
- fprintf( stderr, " chained responses:\n" );
- for ( ; l != NULLMSG; l = l->lm_chain ) {
- fprintf( stderr,
- " * msgid %d, type %d\n",
- l->lm_msgid, l->lm_msgtype );
- }
- }
- }
-#ifdef _REENTRANT
- UNLOCK_RESPONSE(ld);
-#endif
-}
-#endif /* LDAP_DEBUG */
-
-
-void
-free_request( LDAP *ld, LDAPRequest *lr )
-{
- LDAPRequest *tmplr, *nextlr;
- int i;
-
- Debug( LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 214, "free_request (origid %1$d, msgid %2$d)\n"),
- lr->lr_origid, lr->lr_msgid, 0 );
-
- if ( lr->lr_parent != NULL ) {
- --lr->lr_parent->lr_outrefcnt;
- } else {
- /* free all referrals (child requests) */
- for ( tmplr = lr->lr_refnext; tmplr != NULL; tmplr = nextlr ) {
- nextlr = tmplr->lr_refnext;
- free_request( ld, tmplr );
- }
- }
-
- if ( lr->lr_prev == NULL ) {
- ld->ld_requests = lr->lr_next;
- } else {
- lr->lr_prev->lr_next = lr->lr_next;
- }
-
- if ( lr->lr_next != NULL ) {
- lr->lr_next->lr_prev = lr->lr_prev;
- }
-
- if ( lr->lr_ber != NULL ) {
- ber_free( lr->lr_ber, 1 );
- }
-
- if ( lr->lr_res_error != NULL ) {
- free( lr->lr_res_error );
- }
-
- if ( lr->lr_res_matched != NULL ) {
- free( lr->lr_res_matched );
- }
-
- if ( lr->lr_ref_tofollow != NULL ) {
- for (i= 0; lr->lr_ref_tofollow[i] != NULL; i++)
- free(lr->lr_ref_tofollow[i]);
- free(lr->lr_ref_tofollow);
- }
- if ( lr->lr_ref_unfollowed != NULL ) {
- for (i= 0; lr->lr_ref_unfollowed[i] != NULL; i++)
- free(lr->lr_ref_unfollowed[i]);
- free(lr->lr_ref_unfollowed);
- }
- if ( lr->lr_ref_followed != NULL ) {
- for (i= 0; lr->lr_ref_followed[i] != NULL; i++)
- free(lr->lr_ref_followed[i]);
- free(lr->lr_ref_followed);
- }
-
- free( lr );
-}
-
-
-static void
-free_servers( LDAPServer *srvlist )
-{
- LDAPServer *nextsrv;
-
- while ( srvlist != NULL ) {
- nextsrv = srvlist->lsrv_next;
- if ( srvlist->lsrv_dn != NULL ) {
- free( srvlist->lsrv_dn );
- }
- if ( srvlist->lsrv_host != NULL ) {
- free( srvlist->lsrv_host );
- }
- free( srvlist );
- srvlist = nextsrv;
- }
-}
-
-/*
- * nsldapi_connection_lost_nolock() resets "ld" to a non-connected, known
- * state. It should be called whenever a fatal error occurs on the
- * Sockbuf "sb." sb == NULL means we don't know specifically where
- * the problem was so we assume all connections are bad.
- */
-void
-nsldapi_connection_lost_nolock( LDAP *ld, Sockbuf *sb )
-{
- LDAPRequest *lr;
-
- /*
- * change status of all pending requests that are associated with "sb
- * to "connection dead."
- * also change the connection status to "dead" and remove it from
- * the list of sockets we are interested in.
- */
- for ( lr = ld->ld_requests; lr != NULL; lr = lr->lr_next ) {
- if ( sb == NULL ||
- ( lr->lr_conn != NULL && lr->lr_conn->lconn_sb == sb )) {
- lr->lr_status = LDAP_REQST_CONNDEAD;
- if ( lr->lr_conn != NULL ) {
- lr->lr_conn->lconn_status = LDAP_CONNST_DEAD;
- }
- }
- }
-}
-
-#ifdef LDAP_DNS
-static LDAPServer *
-dn2servers( LDAP *ld, char *dn ) /* dn can also be a domain.... */
-{
- char *p, *domain, *host, *server_dn, **dxs;
- int i, port;
- LDAPServer *srvlist, *prevsrv, *srv;
-
- if (( domain = strrchr( dn, '@' )) != NULL ) {
- ++domain;
- } else {
- domain = dn;
- }
-
- if (( dxs = getdxbyname( domain )) == NULL ) {
- ld->ld_errno = LDAP_NO_MEMORY;
- return( NULL );
- }
-
- srvlist = NULL;
-
- for ( i = 0; dxs[ i ] != NULL; ++i ) {
- port = LDAP_PORT;
- server_dn = NULL;
- if ( strchr( dxs[ i ], ':' ) == NULL ) {
- host = dxs[ i ];
- } else if ( strlen( dxs[ i ] ) >= 7 &&
- strncmp( dxs[ i ], "ldap://", 7 ) == 0 ) {
- host = dxs[ i ] + 7;
- if (( p = strchr( host, ':' )) == NULL ) {
- p = host;
- } else {
- *p++ = '\0';
- port = atoi( p );
- }
- if (( p = strchr( p, '/' )) != NULL ) {
- server_dn = ++p;
- if ( *server_dn == '\0' ) {
- server_dn = NULL;
- }
- }
- } else {
- host = NULL;
- }
-
- if ( host != NULL ) { /* found a server we can use */
- if (( srv = (LDAPServer *)calloc( 1,
- sizeof( LDAPServer ))) == NULL ) {
- free_servers( srvlist );
- srvlist = NULL;
- break; /* exit loop & return */
- }
-
- /* add to end of list of servers */
- if ( srvlist == NULL ) {
- srvlist = srv;
- } else {
- prevsrv->lsrv_next = srv;
- }
- prevsrv = srv;
-
- /* copy in info. */
- if (( srv->lsrv_host = strdup( host )) == NULL ||
- ( server_dn != NULL && ( srv->lsrv_dn =
- strdup( server_dn )) == NULL )) {
- free_servers( srvlist );
- srvlist = NULL;
- break; /* exit loop & return */
- }
- srv->lsrv_port = port;
- }
- }
-
- ldap_value_free( dxs );
-
- if ( srvlist == NULL ) {
- ld->ld_errno = LDAP_SERVER_DOWN;
- }
-
- return( srvlist );
-}
-#endif /* LDAP_DNS */
diff --git a/usr/src/lib/libldap4/common/result.c b/usr/src/lib/libldap4/common/result.c
deleted file mode 100644
index 07b21483c6..0000000000
--- a/usr/src/lib/libldap4/common/result.c
+++ /dev/null
@@ -1,1657 +0,0 @@
-/*
- * Copyright 1998-2003 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*
- * Copyright (c) 1990 Regents of the University of Michigan.
- * All rights reserved.
- *
- * result.c - wait for an ldap result
- */
-
-#ifndef lint
-static char copyright[] = "@(#) Copyright (c) 1990 Regents of the University of Michigan.\nAll rights reserved.\n";
-#endif
-
-#include <stdio.h>
-#include <string.h>
-#ifdef MACOS
-#include <stdlib.h>
-#include <time.h>
-#include "macos.h"
-#else /* MACOS */
-#if defined( DOS ) || defined( _WIN32 )
-#include <time.h>
-#include "msdos.h"
-#ifdef PCNFS
-#include <tklib.h>
-#include <tk_errno.h>
-#include <bios.h>
-#endif /* PCNFS */
-#ifdef NCSA
-#include "externs.h"
-#endif /* NCSA */
-#else /* DOS */
-#include <sys/time.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include <errno.h>
-#ifdef _AIX
-#include <sys/select.h>
-#endif /* _AIX */
-#include "portable.h"
-#endif /* DOS */
-#endif /* MACOS */
-#ifdef VMS
-#include "ucx_select.h"
-#endif
-#include "lber.h"
-#include "ldap.h"
-#include "ldap-private.h"
-#include "ldap-int.h"
-
-#ifdef USE_SYSCONF
-#include <unistd.h>
-#endif /* USE_SYSCONF */
-
-#ifdef NEEDPROTOS
-static int ldap_abandoned( LDAP *ld, int msgid );
-static int ldap_mark_abandoned( LDAP *ld, int msgid );
-static int wait4msg( LDAP *ld, int msgid, int all, struct timeval *timeout,
- LDAPMessage **result );
-static int read1msg( LDAP *ld, int msgid, int all, Sockbuf *sb, LDAPConn *lc,
- LDAPMessage **result );
-static int build_result_ber( LDAP *ld, BerElement *ber, LDAPRequest *lr );
-static void merge_error_info( LDAP *ld, LDAPRequest *parentr, LDAPRequest *lr );
-#ifdef CLDAP
-static int ldap_select1( LDAP *ld, struct timeval *timeout );
-#endif
-static int Ref_AddToRequest(LDAPRequest *lr, char **refs);
-static void Ref_FreeAll(LDAPRequest *lr);
-#else /* NEEDPROTOS */
-static int ldap_abandoned();
-static int ldap_mark_abandoned();
-static int wait4msg();
-static int read1msg();
-static int build_result_ber();
-static void merge_error_info();
-#ifdef CLDAP
-static int ldap_select1();
-#endif
-#endif /* NEEDPROTOS */
-
-#if !defined( MACOS ) && !defined( DOS )
-extern int errno;
-#endif
-
-/*
- * ldap_result - wait for an ldap result response to a message from the
- * ldap server. If msgid is -1, any message will be accepted, otherwise
- * ldap_result will wait for a response with msgid.
- * If all is LDAP_MSG_ONE the first message with id msgid will be accepted.
- * If all is LDAP_MSG_RECEIVED, the received messages with the id msgid will
- * be accepted.
- * Otherwise, ldap_result will wait for all responses with id msgid and
- * then return a pointer to the entire list of messages. This is only
- * useful for search responses, which can be of 3 message types (zero or
- * more entries, zero or more references, one or more results). The type
- * of the first message* received is returned.
- * When waiting, any messages that have been abandoned are discarded.
- *
- * Example:
- * ldap_result( s, msgid, all, timeout, result )
- */
-int
-ldap_result( LDAP *ld, int msgid, int all, struct timeval *timeout,
- LDAPMessage **result )
-{
- LDAPMessage *lm, *lastlm, *nextlm;
- int rv;
-
- /*
- * First, look through the list of responses we have received on
- * this association and see if the response we're interested in
- * is there. If it is, return it. If not, call wait4msg() to
- * wait until it arrives or timeout occurs.
- */
-
-#ifdef _REENTRANT
- LOCK_RESPONSE(ld);
- LOCK_LDAP(ld);
-#endif
- Debug( LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 223, "ldap_result\n"), 0, 0, 0 );
-
- *result = NULLMSG;
- lastlm = NULLMSG;
-
- /* look in the received responses */
- for ( lm = ld->ld_responses; lm != NULLMSG; lm = nextlm ) {
- nextlm = lm->lm_next;
-
- /* if the msg has been abandonned, free it */
- if ( ldap_abandoned( ld, lm->lm_msgid ) ) {
- ldap_mark_abandoned( ld, lm->lm_msgid );
-
- if ( lastlm == NULLMSG ) {
- ld->ld_responses = lm->lm_next;
- } else {
- lastlm->lm_next = nextlm;
- }
-
- ldap_msgfree( lm );
-
- continue;
- }
-
- if ( msgid == LDAP_RES_ANY || lm->lm_msgid == msgid ) {
- LDAPMessage *tmp;
-
- /* If return ONE or RECEIVED message(s) or not a search result, return lm */
- if ( all == LDAP_MSG_ONE || all == LDAP_MSG_RECEIVED
- || (lm->lm_msgtype != LDAP_RES_SEARCH_RESULT
- && lm->lm_msgtype != LDAP_RES_SEARCH_ENTRY
- && lm->lm_msgtype != LDAP_RES_SEARCH_REFERENCE) )
- break;
-
- /* Search in the set of messages if one is a search result */
- for ( tmp = lm; tmp != NULLMSG; tmp = tmp->lm_chain ) {
- if ( tmp->lm_msgtype == LDAP_RES_SEARCH_RESULT )
- break;
- }
- /* No, well wait for the result message */
- if ( tmp == NULLMSG ) {
-#ifdef _REENTRANT
- UNLOCK_LDAP(ld);
-#endif
- rv = wait4msg( ld, msgid, all, timeout, result );
-#ifdef _REENTRANT
- UNLOCK_RESPONSE(ld);
-#endif
- return( rv );
- }
- /* Here we have the Search result pointed by tmp */
- break;
- }
- /* Check next response */
- lastlm = lm;
- }
-
- /* No response matching found : Wait for one */
- if ( lm == NULLMSG ) {
-#ifdef _REENTRANT
- UNLOCK_LDAP(ld);
-#endif
- rv = wait4msg( ld, msgid, all, timeout, result );
-#ifdef _REENTRANT
- UNLOCK_RESPONSE(ld);
-#endif
- return( rv );
- }
-
- /* lm points to the message (chain) to return */
-
- /* Remove message to return from ld_responses list */
- if ( lastlm == NULLMSG ) {
- if (all == LDAP_MSG_ONE && lm->lm_chain != NULLMSG){
- ld->ld_responses = lm->lm_chain;
- } else {
- ld->ld_responses = lm->lm_next;
- }
- } else {
- if (all == LDAP_MSG_ONE && lm->lm_chain != NULLMSG) {
- lastlm->lm_next = lm->lm_chain;
- } else {
- lastlm->lm_next = lm->lm_next;
- }
- }
-
- if ( all == LDAP_MSG_ONE )
- lm->lm_chain = NULLMSG;
- /* Otherwise return the whole chain */
- /* No reponses attached */
- lm->lm_next = NULLMSG;
-
- *result = lm;
- ld->ld_errno = LDAP_SUCCESS;
- rv = lm->lm_msgtype;
-#ifdef _REENTRANT
- UNLOCK_LDAP(ld);
- UNLOCK_RESPONSE(ld);
-#endif
- return( rv );
-}
-
-static int
-wait4msg( LDAP *ld, int msgid, int all, struct timeval *timeout,
- LDAPMessage **result )
-{
- int rc;
- struct timeval tv, *tvp;
- time_t start_time, tmp_time;
- LDAPConn *lc, *nextlc;
-
-#ifdef LDAP_DEBUG
- if ( timeout == NULL ) {
- Debug( LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 224, "wait4msg (infinite timeout)\n"),
- 0, 0, 0 );
- } else {
- Debug( LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 225, "wait4msg (timeout %1$ld sec, %2$ld usec)\n"),
- timeout->tv_sec, timeout->tv_usec, 0 );
- }
-#endif /* LDAP_DEBUG */
-
- if ( timeout == NULL ) {
- tvp = NULL;
- } else {
- tv = *timeout;
- tvp = &tv;
- start_time = time( NULL );
- }
-
- rc = -2;
- while ( rc == -2 ) {
-#ifdef LDAP_DEBUG
- if ( ldap_debug & LDAP_DEBUG_TRACE ) {
- dump_connection( ld, ld->ld_conns, 1 );
- dump_requests_and_responses( ld );
- }
-#endif /* LDAP_DEBUG */
- for ( lc = ld->ld_conns; lc != NULL; lc = lc->lconn_next ) {
- if ( lc->lconn_sb->sb_ber.ber_ptr <
- lc->lconn_sb->sb_ber.ber_end ) {
- /* A Message is available, decode and process it */
- rc = read1msg( ld, msgid, all, lc->lconn_sb,
- lc, result );
- break;
- }
- }
- /* There was no message available : Wait for one */
- if ( lc == NULL ) {
- rc = do_ldap_select( ld, tvp );
-
-
-#if defined( LDAP_DEBUG ) && !defined( MACOS ) && !defined( DOS )
- if ( rc == -1 ) {
- Debug( LDAP_DEBUG_TRACE,
- catgets(slapdcat, 1, 226, "do_ldap_select returned -1: errno %d\n"),
- errno, 0, 0 );
- }
-#endif
-
-#if !defined( MACOS ) && !defined( DOS )
- if ( rc == 0 || ( rc == -1 && (ld->ld_restart || errno != EINTR ))) {
-#else
- if ( rc == -1 || rc == 0 ) {
-#endif
- ld->ld_errno = (rc == -1 ? LDAP_SERVER_DOWN :
- LDAP_TIMEOUT);
- if ( rc == -1 ) {
-#ifdef _REENTRANT
- LOCK_LDAP(ld);
-#endif
- nsldapi_connection_lost_nolock( ld, NULL);
-#ifdef _REENTRANT
- UNLOCK_LDAP(ld);
-#endif
- }
- return( rc );
- }
-
- if ( rc == -1 ) {
- rc = -2; /* select interrupted: Continue the loop */
- } else {
- rc = -2;
- for ( lc = ld->ld_conns; rc == -2 && lc != NULL;
- lc = nextlc ) {
- nextlc = lc->lconn_next;
- if ( lc->lconn_status == LDAP_CONNST_CONNECTED) {
- /* Check on each connection. */
- long is_ready = is_read_ready( ld, lc->lconn_sb );
-
- if (is_ready > 0) {
- /* A Message is available, decode and process it */
- rc = read1msg( ld, msgid, all,
- lc->lconn_sb, lc, result );
- } else if ( is_ready < 0){
- /* Error in the select : what to do in here ? */
- /* So far : */
- rc = -1;
- }
- }
- }
- }
- }
-
- if ( rc == -2 && tvp != NULL ) {
- tmp_time = time( NULL );
- if (( tv.tv_sec -= ( tmp_time - start_time )) <= 0 ) {
- /* At this point if all == LDAP_MSG_RECEIVED, we must
- return all available messages for the msgid */
- if (all == LDAP_MSG_RECEIVED) {
- /* Search in responses if some have the correct id */
- /* if yes return the chain */
- /* Otherwise return timeout */
- break;
- }
-
- rc = 0; /* timed out */
- ld->ld_errno = LDAP_TIMEOUT;
- break;
- }
-
- Debug( LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 227, "wait4msg: %ld secs to go\n"),
- tv.tv_sec, 0, 0 );
- start_time = tmp_time;
- }
- }
-
- return( rc );
-}
-
-
-static int
-read1msg( LDAP *ld, int msgid, int all, Sockbuf *sb,
- LDAPConn *lc,
- LDAPMessage **result )
-{
- BerElement ber;
- LDAPMessage *new, *L_res, *l, *prev, *tmp;
- int id;
- unsigned int tag, atag, len;
- int foundit = 0;
- LDAPRequest *lr, *lrparent;
- LDAPRef *theReferences;
- BerElement tmpber;
- int rc, refer_cnt, hadref, simple_request, samereq = 0, total_count;
- int retcode;
- int theErrCode = LDAP_SUCCESS;
- unsigned int lderr;
- char *msgtypestr;
- char ** theRefs = NULL;
- char * theOid = NULL;
- char *lddn, *lderrmsg;
-
- Debug( LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 228, "read1msg\n"), 0, 0, 0 );
-
-read_from_sb:
- lderr = LDAP_SUCCESS; /* Be optimistic */
-
- ber_zero_init( &ber, 0 );
- set_ber_options( ld, &ber );
-
- /* get the next message */
- if ( (tag = ber_get_next( sb, &len, &ber ))
- != LDAP_TAG_MESSAGE ) {
- ld->ld_errno = (tag == LBER_DEFAULT ? LDAP_SERVER_DOWN :
- LDAP_LOCAL_ERROR);
- if ( tag == LBER_DEFAULT ) {
-#ifdef _REENTRANT
- LOCK_LDAP(ld);
-#endif
- nsldapi_connection_lost_nolock( ld, sb );
-#ifdef _REENTRANT
- UNLOCK_LDAP(ld);
-#endif
- }
- return( -1 );
- }
-
- /* message id */
- if ( ber_get_int( &ber, &id ) == LBER_ERROR ) {
- ld->ld_errno = LDAP_DECODING_ERROR;
- return( -1 );
- }
-
- /* if it's been abandoned, toss it */
- if ( ldap_abandoned( ld, (int)id ) ) {
- free( ber.ber_buf ); /* gack! */
- return( -2 ); /* continue looking */
- }
-
- /* the message type */
- if ( (tag = ber_peek_tag( &ber, &len )) == LBER_ERROR ) {
- ld->ld_errno = LDAP_DECODING_ERROR;
- return( -1 );
- }
-
- /* KE
- * Treat unsolicited notification if we got one!
- * id==0
- * tag==LDAP_RES_EXTENDED
- *
- * resultCode== protocolError
- * strongAuthRequired
- * unavailable
- * tag==LDAP_TAG_EXT_RESPNAME
- * response name (oid)==1.3.6.1.1.4.1.1466.20036
- * no response field
- *
- * Example:
- * --------
- * Ber format: {iaata}
- * which means: returnCode dn errorMessage LDAP_TAG_EXT_RESPNAME "1.3.6.1.1.4.1.1466.20036"
- */
- if ( (id==0) && (tag==LDAP_RES_EXTENDED) )
- {
- tmpber = ber;
- if (ber_scanf( &ber, "{iaa", &lderr, &lddn, &lderrmsg) != LBER_ERROR)
- {
- if (ber_peek_tag ( &ber, &atag) == LDAP_TAG_EXT_RESPNAME)
- {
- if ( ber_get_stringa( &ber, &theOid) == LBER_ERROR )
- {
- ld->ld_errno = LDAP_DECODING_ERROR;
- return(-1);
- }
- }
- else
- {
- ld->ld_errno = LDAP_DECODING_ERROR;
- return(-1);
- }
-
- if (ber_peek_tag ( &ber, &atag) == LDAP_TAG_EXT_RESPONSE)
- {
- /* this field must be absent */
- ld->ld_errno = LDAP_DECODING_ERROR;
- return(-1);
- }
- if ( ber_scanf(&ber, "}")== LBER_ERROR)
- {
- ld->ld_errno = LDAP_DECODING_ERROR;
- return(-1);
- }
-
- /* make a new ldap message to return the result */
- if ( (new = (LDAPMessage *) calloc( 1, sizeof(LDAPMessage) )) == NULL )
- {
- ld->ld_errno = LDAP_NO_MEMORY;
- return(-1);
- }
- new->lm_msgid = 0;
- new->lm_msgtype = tag;
- new->lm_ber = ber_dup( &tmpber );
-
- if ( (strncmp(theOid, "1.3.6.1.1.4.1.1466.20036", 24)==0) &&
- (lderr==LDAP_PROTOCOL_ERROR) ||
- (lderr==LDAP_STRONG_AUTH_REQUIRED) ||
- (lderr==LDAP_UNAVAILABLE) )
- {
- /* make a new ldap message to return the result */
- if ( (L_res = (LDAPMessage *) calloc( 1, sizeof(LDAPMessage) )) == NULL )
- {
- ld->ld_errno = LDAP_NO_MEMORY;
- return(-1);
- }
- L_res->lm_msgid = 0;
- L_res->lm_msgtype = tag;
- L_res->lm_ber = ber_dup( &tmpber );
- *result = L_res;
-
- /* It is a notice of disconnection
- * Return immediatly with an error code to stop
- * reading any new message and to prevent the use
- */
- ld->ld_errno = LDAP_SERVER_DOWN;
- ldap_insert_notif(ld, new); /* in head */
- return(-1);
- }
- else
- {
- /* This is another notification
- * Keep on the processing of received messages
- */
- ldap_add_notif(ld, new); /* in tail */
- goto read_from_sb;
- }
- }
- else
- {
- Debug(LDAP_DEBUG_ANY, catgets(slapdcat, 1, 1673, "Error while decoding Extended Response message"), NULL, NULL, NULL);
- ld->ld_errno = LDAP_DECODING_ERROR;
- return(-1);
- }
- }
- else if (( lr = find_request_by_msgid( ld, id )) == NULL )
- {
- Debug( LDAP_DEBUG_ANY, catgets(slapdcat, 1, 229, "no request for response with msgid %ld (tossing)\n"), id, 0, 0 );
- free( ber.ber_buf ); /* gack! */
- return( -2 ); /* continue looking */
- }
-
- if (tag == LDAP_RES_SEARCH_ENTRY)
- msgtypestr = catgets(slapdcat, 1, 1281, "search entry");
- else if (tag == LDAP_RES_SEARCH_REFERENCE)
- msgtypestr = catgets(slapdcat, 1, 1282, "search reference");
- else
- msgtypestr = catgets(slapdcat, 1, 1283, "result");
-
- Debug( LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 230, "got %1$s msgid %2$ld, original id %3$d\n"),
- msgtypestr, id, lr->lr_origid );
-
- id = lr->lr_origid;
-
- /* REFERRALS HANDLING*/
- refer_cnt = 0;
- simple_request = 0;
- hadref = 0;
- rc = -2; /* default is to keep looking (no response found) */
- lr->lr_res_msgtype = tag;
-
- if ( tag != LDAP_RES_SEARCH_ENTRY ) { /* If it's not an entry, ie it's a result or a reference */
- if ( ld->ld_version >= LDAP_VERSION2 &&
- ( lr->lr_parent != NULL ||
- ld->ld_follow_referral /* || ClientControl to follow referral present */ )) {
- tmpber = ber;
- if (tag == LDAP_RES_SEARCH_REFERENCE){
- /* LDAP V3 reference. Decode it */
- Debug(LDAP_DEBUG_TRACE, catgets(slapdcat, 1, -1, "LDAP search reference received. Will follow it later\n"),
- 0, 0,0);
- if (ber_scanf(&tmpber, "{v}", &theRefs) == LBER_ERROR){
- Debug ( LDAP_DEBUG_ANY, catgets(slapdcat, 1, 1284, "Error while decoding Search Reference Result message\n"),
- NULL, NULL, NULL);
- rc = -1;
- theRefs = NULL;
- } else {
- /* Store the referrals in request. We will follow them when the result arrives */
- Ref_AddToRequest(lr, theRefs);
- theRefs = NULL;
- free( ber.ber_buf ); /* gack! */
- ber.ber_buf = NULL;
- return (rc);
- }
- } else {
- if (ber_scanf( &tmpber, "{iaa", &lderr, &lr->lr_res_matched, &lr->lr_res_error) != LBER_ERROR){
- if (lderr == LDAP_PARTIAL_RESULTS){
- Debug(LDAP_DEBUG_TRACE, catgets(slapdcat, 1, -1, "LDAPv2 partial error received\n"), 0, 0,0);
- /* Ldapv2 referrals */
- theRefs = ldap_errormsg2referrals(lr->lr_res_error);
- ber_scanf(&tmpber, "}");
- } else if (lderr == LDAP_REFERRAL ){
- /* We have some referrals, decode them */
- Debug(LDAP_DEBUG_TRACE, catgets(slapdcat, 1, -1, "LDAPv3 referral error received\n"), 0, 0,0);
- if (ber_peek_tag ( &tmpber, &atag) == LDAP_TAG_REFERRAL){
- if (ber_scanf(&tmpber, "{v}}", &theRefs) == LBER_ERROR){
- Debug( LDAP_DEBUG_ANY, catgets(slapdcat, 1, 1285, "Error while decoding referrals in msg\n"),
- NULL, NULL, NULL );
- rc = -1; /* ??? */
- theRefs = NULL;
- }
- } /* else error there should be at least one ref */
- } else if (((lderr == LDAP_NO_SUCH_OBJECT) ||
- (lderr == LDAP_BUSY) ||
- (lderr == LDAP_UNAVAILABLE) ||
- (lderr == LDAP_SERVER_DOWN) ||
- (lderr == LDAP_CONNECT_ERROR)) &&
- (lr->lr_parent != NULL) && /* its subrequest */
- (lr->lr_ref_tofollow != NULL)) { /* And it has some other referral to try */
- samereq = 1;
- theRefs = lr->lr_ref_tofollow;
- lr->lr_ref_tofollow = NULL;
- lrparent = lr->lr_parent;
- /* delete lr */
- free_request(ld, lr);
- /* lr now points on parent request */
- lr = lrparent;
- /* Follow referrals */
- } else {
- /* Here we have a simple result */
- hadref = lr->lr_outrefcnt;
- }
- } else {
- Debug( LDAP_DEBUG_ANY, catgets(slapdcat, 1, 1286, "Error while decoding result for request %$1d\n"),
- lr->lr_origid, NULL, NULL);
- rc = -1; /* ??? */
- }
- }
-
- total_count = 0;
- if (tag != LDAP_RES_SEARCH_REFERENCE && lr->lr_references) {
- /* Some search references pending... Let's try to chase them */
- hadref = 1;
- theReferences = lr->lr_references;
-
- Debug(LDAP_DEBUG_TRACE, catgets(slapdcat, 1, -1, "Now following the search references received\n"),
- 0, 0,0);
-
- while (theReferences != NULL){
- if ((retcode = chase_referrals(ld, lr, theReferences->lref_refs , &refer_cnt, 0)) != LDAP_SUCCESS) {
- /* think about what to do */
- Debug( LDAP_DEBUG_ANY, catgets(slapdcat, 1, -1, "Error while chasing referral (%1$d)\n"),
- retcode, NULL, NULL);
- theErrCode = LDAP_REFERRAL;
- }
- if (refer_cnt >= 0)
- total_count += refer_cnt;
- theReferences = theReferences->lref_next;
- }
- Ref_FreeAll(lr);
- if (theErrCode != LDAP_SUCCESS) {
- if (ld->ld_error != NULL && *ld->ld_error) {
- if (lr->lr_res_error)
- free(lr->lr_res_error);
- lr->lr_res_error = strdup(ld->ld_error);
- }
- }
- lr->lr_res_errno = theErrCode;
- }
- /* if theRefs != NULL we have some referrals to chase, do it */
- if (theRefs){
- hadref = 1;
- if ((retcode = chase_referrals(ld, lr, theRefs, &refer_cnt, samereq)) != LDAP_SUCCESS){
- /* think about what to do */
- Debug( LDAP_DEBUG_ANY, catgets(slapdcat, 1, -1, "Error while chasing referral (%1$d)\n"),
- retcode, NULL, NULL);
- }
-
- if (refer_cnt >= 0)
- total_count += refer_cnt;
-
- ldap_value_free(theRefs);
- if (samereq){ /* Just tried another referral for same request */
- free(ber.ber_buf);
- ber.ber_buf = NULL;
- rc = -2;
- /* continue */
- }
- if (retcode != LDAP_SUCCESS) {
- if (ld->ld_version == LDAP_VERSION2){
- if (lr->lr_res_error)
- free(lr->lr_res_error);
- lr->lr_res_error = ldap_referral2error_msg(lr->lr_ref_unfollowed);
- } else if (ld->ld_error != NULL && *ld->ld_error) {
- if (lr->lr_res_error)
- free(lr->lr_res_error);
- lr->lr_res_error = strdup(ld->ld_error);
- }
- }
- lr->lr_res_errno = ld->ld_errno;
-
- } else if (theErrCode == LDAP_SUCCESS) {
- /* no referral have been chased */
- lr->lr_res_errno = (lderr == LDAP_PARTIAL_RESULTS || lderr == LDAP_REFERRAL) ? LDAP_SUCCESS : lderr;
- }
-
- Debug( LDAP_DEBUG_TRACE,
- catgets(slapdcat, 1, 231, "new result: res_errno: %1$d, res_error: <%2$s>, res_matched: <%3$s>\n"),
- lr->lr_res_errno, lr->lr_res_error ? lr->lr_res_error : "",
- lr->lr_res_matched ? lr->lr_res_matched : "" );
- }
-
-
- Debug( LDAP_DEBUG_TRACE,
- catgets(slapdcat, 1, 232, "read1msg: %1$d new referrals\n"), total_count, 0, 0 );
-
- if ( refer_cnt != 0 ) { /* chasing referrals */
- free( ber.ber_buf ); /* gack! */
- ber.ber_buf = NULL;
- if ( refer_cnt < 0 ) {
- return( -1 ); /* fatal error */
- }
- lr->lr_status = LDAP_REQST_CHASINGREFS;
- } else if (tag == LDAP_RES_SEARCH_REFERENCE && !ld->ld_follow_referral) {
- /* We had a ref and we don't follow referral : Do nothing there ?! */
- Debug( LDAP_DEBUG_TRACE,
- catgets(slapdcat, 1, -1, "read1msg: returning search reference\n"), 0, 0, 0 );
-
- } else {
- /* No referral chasing */
- if ( lr->lr_outrefcnt <= 0 && lr->lr_parent == NULL ) {
- /* request without any referrals */
- simple_request = ( hadref ? 0 : 1 );
- } else {
- /* request with referrals or child request */
- free( ber.ber_buf ); /* gack! */
- ber.ber_buf = NULL;
- }
-
-
- while ( lr->lr_parent != NULL ) {
- merge_error_info( ld, lr->lr_parent, lr );
- lr = lr->lr_parent;
- if ( --lr->lr_outrefcnt > 0 ) {
- break; /* not completedly done yet */
- }
- }
-
- if ( lr->lr_outrefcnt <= 0 && lr->lr_parent == NULL ) { /* The main request has no more outstanding refs */
- id = lr->lr_msgid;
- tag = lr->lr_res_msgtype;
- Debug( LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 233, "request %1$ld done\n"),
- id, 0, 0 );
- Debug( LDAP_DEBUG_TRACE,
- catgets(slapdcat, 1, 234, "res_errno: %1$d, res_error: <%2$s>, res_matched: <%3$s>\n"),
- lr->lr_res_errno, lr->lr_res_error ? lr->lr_res_error : "",
- lr->lr_res_matched ? lr->lr_res_matched : "" );
- if ( !simple_request ) { /* We have to rebuild the result */
- if ( ber.ber_buf != NULL ) {
- free( ber.ber_buf ); /* gack! */
- ber.ber_buf = NULL;
- }
- if ( build_result_ber( ld, &ber, lr )
- == LBER_ERROR ) {
- ld->ld_errno = LDAP_NO_MEMORY;
- rc = -1; /* fatal error */
- }
- }
-
- free_request( ld, lr );
- }
-
- if ( lc != NULL ) {
- free_connection( ld, lc, 0, 1 );
- }
- }
- }
-
- if ( ber.ber_buf == NULL ) { /* If the buffer has been freed, return */
- return( rc );
- }
- /* End of REFERRALS */
-
- /* make a new ldap message */
- if ( (new = (LDAPMessage *) calloc( 1, sizeof(LDAPMessage) ))
- == NULL ) {
- ld->ld_errno = LDAP_NO_MEMORY;
- return( -1 );
- }
- new->lm_msgid = (int)id;
- new->lm_msgtype = tag;
- new->lm_ber = ber_dup( &ber );
-
-#ifndef NO_CACHE
- if ( ld->ld_cache != NULL ) {
- add_result_to_cache( ld, new );
- }
-#endif /* NO_CACHE */
-
- /* is this the one we're looking for? */
- if ( msgid == LDAP_RES_ANY || id == msgid ) {
- if ( all == LDAP_MSG_ONE /* all apply only to search, so if not a search,return the val */
- || (new->lm_msgtype != LDAP_RES_SEARCH_RESULT
- && new->lm_msgtype != LDAP_RES_SEARCH_ENTRY
- && new->lm_msgtype != LDAP_RES_SEARCH_REFERENCE) ) {
- *result = new;
- ld->ld_errno = LDAP_SUCCESS;
- return( tag );
- } else if ( new->lm_msgtype == LDAP_RES_SEARCH_RESULT) {
- foundit = 1; /* return the chain later */
- }
- }
-
- /*
- * if not, we must add it to the list of responses. if
- * the msgid is already there, it must be part of an existing
- * search response.
- */
-
- prev = NULLMSG;
- for ( l = ld->ld_responses; l != NULLMSG; l = l->lm_next ) {
- if ( l->lm_msgid == new->lm_msgid )
- break;
- prev = l;
- }
-
- /* not part of an existing search response */
- if ( l == NULLMSG ) {
- if ( foundit ) { /* it a search result anyway, so return it */
- *result = new;
- ld->ld_errno = LDAP_SUCCESS;
- return( tag );
- }
-
- new->lm_next = ld->ld_responses;
- ld->ld_responses = new;
- return( -2 ); /* continue looking */
- }
-
- Debug( LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 235, "adding response id %1$d type %2$d:\n"),
- new->lm_msgid, new->lm_msgtype, 0 );
-
- /* part of a search response - add to end of list of entries or references */
- for ( tmp = l; tmp->lm_chain != NULLMSG &&
- (tmp->lm_chain->lm_msgtype == LDAP_RES_SEARCH_ENTRY ||
- tmp->lm_chain->lm_msgtype == LDAP_RES_SEARCH_REFERENCE);
- tmp = tmp->lm_chain )
- ; /* NULL */
- tmp->lm_chain = new;
-
- /* return the whole chain if that's what we were looking for */
- if ( foundit ) {
- if ( prev == NULLMSG )
- ld->ld_responses = l->lm_next;
- else
- prev->lm_next = l->lm_next;
- *result = l;
- ld->ld_errno = LDAP_SUCCESS;
- return( l->lm_msgtype ); /* Patch 16 : was return(tag) */
- }
-
- return( -2 ); /* continue looking */
-}
-
-
-static int
-build_result_ber( LDAP *ld, BerElement *ber, LDAPRequest *lr )
-{
- unsigned int len;
- int along;
-
- Debug (LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 1287, "=> building_ber_error msgid %ld\n"), lr->lr_msgid, 0,0);
- ber_zero_init( ber, 0 );
- set_ber_options( ld, ber );
- if (ld->ld_version == LDAP_VERSION3){
- if ( ber_printf( ber, "{it{ess",
- lr->lr_msgid,
- lr->lr_res_msgtype,
- lr->lr_res_errno,
- lr->lr_res_matched ? lr->lr_res_matched : "",
- lr->lr_res_error ? lr->lr_res_error : "" ) == LBER_ERROR){
- return (LBER_ERROR);
- }
- if (lr->lr_res_errno == LDAP_REFERRAL &&
- ber_printf(ber, "t{v}", LDAP_TAG_REFERRAL, lr->lr_ref_unfollowed) == LBER_ERROR){
- return (LBER_ERROR);
- }
- if (ber_printf(ber, "}}") == LBER_ERROR){
- return (LBER_ERROR);
- }
- } else {
- if ( ber_printf( ber, "{it{ess}}",
- lr->lr_msgid,
- lr->lr_res_msgtype,
- lr->lr_res_errno,
- lr->lr_res_matched ? lr->lr_res_matched : "",
- lr->lr_res_error ? lr->lr_res_error : "" ) == LBER_ERROR ) {
- return( LBER_ERROR );
- }
- }
-
- ber_reset( ber, 1 );
- if ( ber_skip_tag( ber, &len ) == LBER_ERROR ) {
- return( LBER_ERROR );
- }
-
- if ( ber_get_int( ber, &along ) == LBER_ERROR ) {
- return( LBER_ERROR );
- }
-
- return( ber_peek_tag( ber, &len ));
-}
-
-
-static void
-merge_error_info( LDAP *ld, LDAPRequest *parentr, LDAPRequest *lr )
-{
- int i, j;
-/*
- * Merge error information in "lr" with "parentr" error code and string.
- */
- if ( lr->lr_res_errno == LDAP_PARTIAL_RESULTS ) {
- parentr->lr_res_errno = lr->lr_res_errno;
- if ( lr->lr_res_error != NULL ) {
- (void)append_referral( ld, &parentr->lr_res_error,
- lr->lr_res_error );
- }
- } else if ( lr->lr_res_errno != LDAP_SUCCESS &&
- parentr->lr_res_errno == LDAP_SUCCESS ) {
- parentr->lr_res_errno = lr->lr_res_errno;
- if ( parentr->lr_res_error != NULL ) {
- free( parentr->lr_res_error );
- }
- parentr->lr_res_error = lr->lr_res_error;
- lr->lr_res_error = NULL;
- if ( NAME_ERROR( lr->lr_res_errno )) {
- if ( parentr->lr_res_matched != NULL ) {
- free( parentr->lr_res_matched );
- }
- parentr->lr_res_matched = lr->lr_res_matched;
- lr->lr_res_matched = NULL;
- }
- if (lr->lr_ref_unfollowed != NULL){
- for (i=0;lr->lr_ref_unfollowed[i] != NULL; i++);
- j = 0;
- if (parentr->lr_ref_unfollowed != NULL){
- for (j=0;parentr->lr_ref_unfollowed[j]!= NULL ;j++);
- j++;
- }
- parentr->lr_ref_unfollowed = (char **)realloc (parentr->lr_ref_unfollowed, (j+i+1) * sizeof(char *));
- if (parentr->lr_ref_unfollowed != NULL){
- for (i = 0; lr->lr_ref_unfollowed[i] != NULL; i++){
- parentr->lr_ref_unfollowed[j+i] = lr->lr_ref_unfollowed[i];
- lr->lr_ref_unfollowed[i] = NULL;
- }
- parentr->lr_ref_unfollowed[i+j+1] = NULL;
- } else {
- if (parentr->lr_res_errno == LDAP_SUCCESS)
- parentr->lr_res_errno = LDAP_NO_MEMORY;
- }
- }
- }
-
- Debug( LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 236, "merged parent (id %1$d) error info: "),
- parentr->lr_msgid, 0, 0 );
- Debug( LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 237, "result errno %1$d, error <%2$s>, matched <%3$s>\n"),
- parentr->lr_res_errno,
- parentr->lr_res_error ? parentr->lr_res_error : "",
- parentr->lr_res_matched ? parentr->lr_res_matched : "" );
-}
-
-#ifdef CLDAP
-#if !defined( MACOS ) && !defined( DOS ) && !defined( _WIN32 )
-static int
-ldap_select1( LDAP *ld, struct timeval *timeout )
-{
- fd_set readfds;
- static int tblsize;
-
- if ( tblsize == 0 ) {
-#ifdef USE_SYSCONF
- tblsize = (int) sysconf( _SC_OPEN_MAX );
-#else /* USE_SYSCONF */
- tblsize = getdtablesize();
-#endif /* USE_SYSCONF */
- }
-
- FD_ZERO( &readfds );
- FD_SET( ld->ld_sb.sb_sd, &readfds );
-
- return( select( tblsize, &readfds, 0, 0, timeout ) );
-}
-#endif /* !MACOS */
-
-
-#ifdef MACOS
-static int
-ldap_select1( LDAP *ld, struct timeval *timeout )
-{
- return( tcpselect( ld->ld_sb.sb_sd, timeout ));
-}
-#endif /* MACOS */
-
-
-#if ( defined( DOS ) && defined( WINSOCK )) || defined( _WIN32 )
-static int
-ldap_select1( LDAP *ld, struct timeval *timeout )
-{
- fd_set readfds;
- int rc;
-
- FD_ZERO( &readfds );
- FD_SET( ld->ld_sb.sb_sd, &readfds );
-
- rc = select( 1, &readfds, 0, 0, timeout );
- return( rc == SOCKET_ERROR ? -1 : rc );
-}
-#endif /* WINSOCK || _WIN32 */
-
-
-#ifdef DOS
-#ifdef PCNFS
-static int
-ldap_select1( LDAP *ld, struct timeval *timeout )
-{
- fd_set readfds;
- int res;
-
- FD_ZERO( &readfds );
- FD_SET( ld->ld_sb.sb_sd, &readfds );
-
- res = select( FD_SETSIZE, &readfds, NULL, NULL, timeout );
- if ( res == -1 && errno == EINTR) {
- /* We've been CTRL-C'ed at this point. It'd be nice to
- carry on but PC-NFS currently won't let us! */
- printf("\n*** CTRL-C ***\n");
- exit(-1);
- }
- return( res );
-}
-#endif /* PCNFS */
-
-#ifdef NCSA
-static int
-ldap_select1( LDAP *ld, struct timeval *timeout )
-{
- int rc;
- clock_t endtime;
-
- if ( timeout != NULL ) {
- endtime = timeout->tv_sec * CLK_TCK +
- timeout->tv_usec * CLK_TCK / 1000000 + clock();
- }
-
- do {
- Stask();
- rc = netqlen( ld->ld_sb.sb_sd );
- } while ( rc <= 0 && ( timeout == NULL || clock() < endtime ));
-
- return( rc > 0 ? 1 : 0 );
-}
-#endif /* NCSA */
-#endif /* DOS */
-#endif /* CLDAP */
-
-
-int
-ldap_msgfree( LDAPMessage *lm )
-{
- LDAPMessage *next;
- int type = 0;
-
- Debug( LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 238, "ldap_msgfree\n"), 0, 0, 0 );
-
- for ( ; lm != NULLMSG; lm = next ) {
- next = lm->lm_chain;
- type = lm->lm_msgtype;
- if (lm->lm_ber)
- ber_free( lm->lm_ber, 1 );
- free( (char *) lm );
- }
-
- return( type );
-}
-
-/*
- * ldap_msgdelete - delete a message. It returns:
- * 0 if the entire message was deleted
- * -1 if the message was not found, or only part of it was found
- */
-int
-ldap_msgdelete( LDAP *ld, int msgid )
-{
- LDAPMessage *lm, *prev;
-
-#ifdef _REENTRANT
- LOCK_LDAP(ld);
- LOCK_RESPONSE(ld);
-#endif
- Debug( LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 239, "ldap_msgdelete\n"), 0, 0, 0 );
-
- prev = NULLMSG;
- for ( lm = ld->ld_responses; lm != NULLMSG; lm = lm->lm_next ) {
- if ( lm->lm_msgid == msgid )
- break;
- prev = lm;
- }
-
- if ( lm == NULLMSG ) {
-#ifdef _REENTRANT
- UNLOCK_LDAP(ld);
- UNLOCK_RESPONSE(ld);
-#endif
- return( -1 );
- }
-
- if ( prev == NULLMSG )
- ld->ld_responses = lm->lm_next;
- else
- prev->lm_next = lm->lm_next;
-
- if ( ldap_msgfree( lm ) == LDAP_RES_SEARCH_ENTRY ) {
-#ifdef _REENTRANT
- UNLOCK_LDAP(ld);
- UNLOCK_RESPONSE(ld);
-#endif
- return( -1 );
- }
-
-#ifdef _REENTRANT
- UNLOCK_LDAP(ld);
- UNLOCK_RESPONSE(ld);
-#endif
- return( 0 );
-}
-
-
-/*
- * return 1 if message msgid is waiting to be abandoned, 0 otherwise
- */
-static int
-ldap_abandoned( LDAP *ld, int msgid )
-{
- int i;
-
- if ( ld == NULL ) return(1);
- if ( ld->ld_abandoned == NULL )
- return( 0 );
-
- for ( i = 0; ld->ld_abandoned[i] != -1; i++ )
- if ( ld->ld_abandoned[i] == msgid )
- return( 1 );
-
- return( 0 );
-}
-
-
-static int
-ldap_mark_abandoned( LDAP *ld, int msgid )
-{
- int i;
-
- if ( ld->ld_abandoned == NULL )
- return( -1 );
-
- for ( i = 0; ld->ld_abandoned[i] != -1; i++ )
- if ( ld->ld_abandoned[i] == msgid )
- break;
-
- if ( ld->ld_abandoned[i] == -1 )
- return( -1 );
-
- for ( ; ld->ld_abandoned[i] != -1; i++ ) {
- ld->ld_abandoned[i] = ld->ld_abandoned[i + 1];
- }
-
- return( 0 );
-}
-
-
-#ifdef CLDAP
-int
-cldap_getmsg( LDAP *ld, struct timeval *timeout, BerElement *ber )
-{
- int rc;
- unsigned int tag, len;
-
-#ifdef _REENTRANT
- LOCK_LDAP(ld);
-#endif
- if ( ld->ld_sb.sb_ber.ber_ptr >= ld->ld_sb.sb_ber.ber_end ) {
- rc = ldap_select1( ld, timeout );
- if ( rc == -1 || rc == 0 ) {
- ld->ld_errno = (rc == -1 ? LDAP_SERVER_DOWN :
- LDAP_TIMEOUT);
-#ifdef _REENTRANT
- UNLOCK_LDAP(ld);
-#endif
- return( rc );
- }
- }
-
- /* get the next message */
- if ( (tag = ber_get_next( &ld->ld_sb, &len, ber ))
- != LDAP_TAG_MESSAGE ) {
- ld->ld_errno = (tag == LBER_DEFAULT ? LDAP_SERVER_DOWN :
- LDAP_LOCAL_ERROR);
-#ifdef _REENTRANT
- UNLOCK_LDAP(ld);
-#endif
- return( -1 );
- }
-
-#ifdef _REENTRANT
- UNLOCK_LDAP(ld);
-#endif
- return( tag );
-}
-#endif /* CLDAP */
-
-/* ldapv3 API extensions */
-
-int ldap_msgtype(LDAPMessage *res)
-{
- if (res == NULL)
- return (LDAP_RES_ANY);
- return (res->lm_msgtype);
-}
-
-
-int ldap_msgid(LDAPMessage *res)
-{
- if (res == NULL)
- return (LDAP_RES_ANY);
- return (res->lm_msgid);
-}
-
-int ldap_parse_result(LDAP *ld, LDAPMessage *res, int *errcodep, char **matcheddnp,
- char **errmsgp, char ***referralsp, LDAPControl ***serverctrlsp,
- int freeit)
-{
- LDAPMessage *lm;
- BerElement ber;
- unsigned int alen;
- int along;
- unsigned int tag;
- int i;
- size_t rc;
- char * acharp = NULL, * a2ndcharp = NULL;
- char ** arefs = NULL;
-
- Debug( LDAP_DEBUG_TRACE, "ldap_parse_result\n", 0, 0, 0 );
-
- if (res == NULLMSG)
- return (LDAP_PARAM_ERROR);
-
- if (matcheddnp && *matcheddnp){
- free(*matcheddnp);
- *matcheddnp = NULL;
- }
- if (errmsgp && *errmsgp){
- free(*errmsgp);
- *errmsgp = NULL;
- }
- if (referralsp && *referralsp){
- free_strarray(*referralsp);
- *referralsp = NULL;
- }
-
- if (serverctrlsp && *serverctrlsp){
- ldap_controls_free(*serverctrlsp);
- *serverctrlsp = NULL;
- }
-
- for (lm = res; lm->lm_chain != NULL; lm = lm->lm_chain)
-
- if ( lm->lm_msgtype != LDAP_RES_SEARCH_ENTRY
- && lm->lm_msgtype != LDAP_RES_SEARCH_REFERENCE)
- break;
-
- ber = *(lm->lm_ber);
-
-#ifdef _REENTRANT
- LOCK_LDAP(ld);
-#endif
- if (ld->ld_version == LDAP_VERSION3) {
- rc = ber_scanf( &ber, "{iaa", &along, &acharp, &a2ndcharp);
- if (rc == LBER_ERROR){
- if (freeit)
- ldap_msgfree( res );
-#ifdef _REENTRANT
- UNLOCK_LDAP(ld);
-#endif
- return (LDAP_DECODING_ERROR);
- }
- if (matcheddnp) {
- *matcheddnp = acharp;
- } else {
- ldap_memfree(acharp);
- }
- if (errmsgp) {
- *errmsgp = a2ndcharp;
- } else {
- ldap_memfree(a2ndcharp);
- }
-
- if (errcodep) {
- *errcodep = along;
- }
-
- if (along == LDAP_REFERRAL){
- if (ber_peek_tag ( &ber, &tag) == LDAP_TAG_REFERRAL) {
- rc = ber_scanf(&ber, "{v}", &arefs);
- if (rc == LBER_ERROR){
- /* try to free other stuff */
- if (freeit)
- ldap_msgfree( res );
-#ifdef _REENTRANT
- UNLOCK_LDAP(ld);
-#endif
- return (LDAP_DECODING_ERROR);
- }
- if (referralsp) {
- *referralsp = arefs;
- } else {
- for (i = 0; arefs[i] != NULL; i++)
- ldap_memfree(arefs[i]);
- ldap_memfree((char *)arefs);
- }
- } else {
- /* referral errcode without URL is forbiden */
- if (freeit)
- ldap_msgfree( res );
-#ifdef _REENTRANT
- UNLOCK_LDAP(ld);
-#endif
- return (LDAP_DECODING_ERROR);
- }
- }
- rc = ber_scanf(&ber, "}");
- if (rc == LBER_ERROR){
- if (freeit)
- ldap_msgfree( res );
-#ifdef _REENTRANT
- UNLOCK_LDAP(ld);
-#endif
- return (LDAP_DECODING_ERROR);
- }
- /* It's the end of the result but the PDU may have controls */
- if (serverctrlsp && (ber_peek_tag(&ber, &alen) == LDAP_TAG_CONTROL_LIST)) {
- Debug( LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 392, "Controls found in result\n"), 0, 0, 0 );
- *serverctrlsp = ldap_controls_decode(&ber,
- (int *)&rc);
- if (*serverctrlsp == NULL) {
- if (freeit)
- ldap_msgfree( res );
-#ifdef _REENTRANT
- UNLOCK_LDAP(ld);
-#endif
- return (LDAP_DECODING_ERROR);
- }
- } else {
- Debug( LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 393, "NO controls found in result\n"), 0, 0, 0 );
- }
- }
- else if (ld->ld_version == LDAP_VERSION2) {
- rc = ber_scanf( &ber, "{iaa}", &along, &acharp,
- &a2ndcharp );
- if (rc == LBER_ERROR){
- if (freeit)
- ldap_msgfree( res );
-#ifdef _REENTRANT
- UNLOCK_LDAP(ld);
-#endif
- return (LDAP_DECODING_ERROR);
- }
- if (matcheddnp) {
- *matcheddnp = acharp;
- } else {
- ldap_memfree(acharp);
- }
- if (errmsgp) {
- *errmsgp = a2ndcharp;
- } else {
- ldap_memfree(a2ndcharp);
- }
- if (errcodep) {
- *errcodep = along;
- }
- }
- else {
- rc = ber_scanf( &ber, "{ia}", &along, &a2ndcharp );
- if (rc == LBER_ERROR){
- if (freeit)
- ldap_msgfree( res );
-#ifdef _REENTRANT
- UNLOCK_LDAP(ld);
-#endif
- return (LDAP_DECODING_ERROR);
- }
-
- if (errmsgp) {
- *errmsgp = a2ndcharp;
- } else {
- ldap_memfree(a2ndcharp);
- }
- if (errcodep) {
- *errcodep = along;
- }
- }
-
- if ( freeit )
- ldap_msgfree(res);
-
-#ifdef _REENTRANT
- UNLOCK_LDAP(ld);
-#endif
- return (LDAP_SUCCESS);
-}
-
-int ldap_parse_sasl_bind_result(LDAP *ld, LDAPMessage *res, struct berval **servercredp, int freeit)
-{
- LDAPMessage *lm;
- BerElement ber;
- int along;
- unsigned int tag;
- int i;
- size_t rc;
- char * acharp = NULL, *a2ndcharp = NULL;
- char ** arefs = NULL;
- struct berval * creds = NULL;
-
- Debug( LDAP_DEBUG_TRACE, "ldap_parse_extended_result\n", 0, 0, 0 );
-
- if (res == NULLMSG)
- return (LDAP_PARAM_ERROR);
-
-#ifdef _REENTRANT
- LOCK_LDAP(ld);
-#endif
- if ((res->lm_msgtype != LDAP_RES_BIND) || (ld->ld_version != LDAP_VERSION3)){
- ld->ld_errno = LDAP_PARAM_ERROR;
-#ifdef _REENTRANT
- UNLOCK_LDAP(ld);
-#endif
- return (LDAP_PARAM_ERROR);
- }
-#ifdef _REENTRANT
- UNLOCK_LDAP(ld);
-#endif
-
- ber = *(res->lm_ber);
- rc = ber_scanf( &ber, "{iaa", &along, &acharp, &a2ndcharp);
- if (rc == LBER_ERROR){
- if (freeit)
- ldap_msgfree( res );
-#ifdef _REENTRANT
- LOCK_LDAP(ld);
-#endif
- ld->ld_errno = LDAP_DECODING_ERROR;
-#ifdef _REENTRANT
- UNLOCK_LDAP(ld);
-#endif
- return (LDAP_DECODING_ERROR);
- }
- ldap_memfree(acharp);
- ldap_memfree(a2ndcharp);
- if (along == LDAP_SUCCESS || along == LDAP_SASL_BIND_INPROGRESS){
- /* Decode the serverSaslCreds if any */
- if (ber_peek_tag ( &ber, &tag) == LDAP_TAG_SASLCREDS) {
- rc = ber_get_stringal( &ber, &creds);
- if (rc == LBER_ERROR ){
- if (freeit)
- ldap_msgfree(res);
-#ifdef _REENTRANT
- LOCK_LDAP(ld);
-#endif
- ld->ld_errno = LDAP_DECODING_ERROR;
-#ifdef _REENTRANT
- UNLOCK_LDAP(ld);
-#endif
- return (LDAP_DECODING_ERROR);
- }
- if (servercredp) {
- *servercredp = creds;
- } else {
- ber_bvfree( creds );
- }
- }
- } else if (along == LDAP_REFERRAL) {
- if (ber_peek_tag ( &ber, &tag) == LDAP_TAG_REFERRAL){
- rc = ber_scanf(&ber, "{v}", &arefs);
- if (rc == LBER_ERROR){
- /* try to free other stuff */
- if (freeit)
- ldap_msgfree( res );
-#ifdef _REENTRANT
- LOCK_LDAP(ld);
-#endif
- ld->ld_errno = LDAP_DECODING_ERROR;
-#ifdef _REENTRANT
- UNLOCK_LDAP(ld);
-#endif
- return (LDAP_DECODING_ERROR);
- }
- for (i = 0; arefs[i] != NULL; i++)
- ldap_memfree(arefs[i]);
- ldap_memfree((char *)arefs);
- } else {
- /* There should be at least one ref */
- if (freeit)
- ldap_msgfree( res );
-#ifdef _REENTRANT
- LOCK_LDAP(ld);
-#endif
- ld->ld_errno = LDAP_DECODING_ERROR;
-#ifdef _REENTRANT
- UNLOCK_LDAP(ld);
-#endif
- return (LDAP_DECODING_ERROR);
- }
- }
-
- rc = ber_scanf(&ber, "}");
- if (rc == LBER_ERROR){
- if (freeit)
- ldap_msgfree( res );
-#ifdef _REENTRANT
- LOCK_LDAP(ld);
-#endif
- ld->ld_errno = LDAP_DECODING_ERROR;
-#ifdef _REENTRANT
- UNLOCK_LDAP(ld);
-#endif
- return (LDAP_DECODING_ERROR);
- }
-
- if ( freeit )
- ldap_msgfree(res);
-#ifdef _REENTRANT
- LOCK_LDAP(ld);
-#endif
- ld->ld_errno = along;
-#ifdef _REENTRANT
- UNLOCK_LDAP(ld);
-#endif
- return (along);
-}
-
-int ldap_parse_extended_result(LDAP *ld, LDAPMessage *res, char **resultoidp,
- struct berval **resultdata, int freeit)
-{
- LDAPMessage *lm;
- BerElement ber;
- int along;
- unsigned int tag;
- int i;
- size_t rc;
- char * acharp = NULL, *a2ndcharp = NULL, *anoid = NULL;
- char **arefs = NULL;
- struct berval * aresp = NULL;
-
- Debug( LDAP_DEBUG_TRACE, "ldap_parse_sasl_bind_result\n", 0, 0, 0 );
-
- if ( res == NULLMSG )
- return (LDAP_PARAM_ERROR);
-
-#ifdef _REENTRANT
- LOCK_LDAP(ld);
-#endif
- if ((res->lm_msgtype != LDAP_RES_EXTENDED) || (ld->ld_version != LDAP_VERSION3))
- {
- if ( res->lm_msgid != 0 )
-#ifdef _REENTRANT
- UNLOCK_LDAP(ld);
-#endif
- return (LDAP_PARAM_ERROR);
- }
-#ifdef _REENTRANT
- UNLOCK_LDAP(ld);
-#endif
-
- ber = *(res->lm_ber);
- rc = ber_scanf( &ber, "{iaa", &along, &acharp, &a2ndcharp);
- if (rc == LBER_ERROR){
- if (freeit)
- ldap_msgfree( res );
- return (LDAP_DECODING_ERROR);
- }
- ldap_memfree(acharp);
- ldap_memfree(a2ndcharp);
-
- if (along == LDAP_REFERRAL) {
- if (ber_peek_tag ( &ber, &tag) == LDAP_TAG_REFERRAL){
- rc = ber_scanf(&ber, "{v}", &arefs);
- if (rc == LBER_ERROR){
- /* try to free other stuff */
- if (freeit)
- ldap_msgfree( res );
- return (LDAP_DECODING_ERROR);
- }
- for (i = 0; arefs[i] != NULL; i++)
- ldap_memfree(arefs[i]);
- ldap_memfree((char *)arefs);
- } else {
- /* There should be at least one ref */
- if (freeit)
- ldap_msgfree( res );
- return (LDAP_DECODING_ERROR);
- }
- }
-
- if (ber_peek_tag ( &ber, &tag) == LDAP_TAG_EXT_RESPNAME) {
- rc = ber_get_stringa( &ber, &anoid);
- if (rc == LBER_ERROR ){
- if (freeit)
- ldap_msgfree(res);
- return (LDAP_DECODING_ERROR);
- }
- if (resultoidp) {
- *resultoidp = anoid;
- } else {
- ldap_memfree( anoid );
- }
- }
- if (ber_peek_tag ( &ber, &tag) == LDAP_TAG_EXT_RESPONSE) {
- rc = ber_get_stringal( &ber, &aresp);
- if (rc == LBER_ERROR ){
- if (freeit)
- ldap_msgfree(res);
- return (LDAP_DECODING_ERROR);
- }
- if (resultdata) {
- *resultdata = aresp;
- } else {
- ber_bvfree( aresp );
- }
- }
-
- rc = ber_scanf(&ber, "}");
- if (rc == LBER_ERROR){
- if (freeit)
- ldap_msgfree( res );
- return (LDAP_DECODING_ERROR);
- }
-
- if ( freeit )
- ldap_msgfree(res);
-
- return (along);
-}
-
-
-static int Ref_AddToRequest(LDAPRequest *lr, char **refs) {
- int count;
- LDAPRef *lref;
- LDAPRef *newRef;
-
- if ((newRef = (LDAPRef *)calloc(1, sizeof (LDAPRef))) == NULL){
- return LDAP_NO_MEMORY;
- }
- newRef->lref_refs = refs;
- newRef->lref_next = NULL;
- lref = lr->lr_references;
- if (lref == NULL){
- lr->lr_references = newRef;
- } else {
- while (lref->lref_next != NULL)
- lref = lref->lref_next;
- lref->lref_next = newRef;
- }
- return LDAP_SUCCESS;
-}
-
-static void Ref_FreeAll(LDAPRequest *lr)
-{
- LDAPRef *lref, *next;
- lref = lr->lr_references;
- while (lref != NULL){
- next = lref->lref_next;
- ldap_value_free(lref->lref_refs);
- free (lref);
- lref = next;
- }
- lr->lr_references = NULL;
-}
diff --git a/usr/src/lib/libldap4/common/saslbind.c b/usr/src/lib/libldap4/common/saslbind.c
deleted file mode 100644
index ba8b5b4c3d..0000000000
--- a/usr/src/lib/libldap4/common/saslbind.c
+++ /dev/null
@@ -1,340 +0,0 @@
-/*
- *
- * Copyright 2000 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- *
- *
- * Comments:
- *
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#include <stdio.h>
-#include <string.h>
-
-#include "lber.h"
-#include "ldap.h"
-#include "ldap-private.h"
-#include "ldap-int.h"
-#include "sec.h"
-#include <strings.h>
-
-BerElement * ldap_build_sasl_bind_req( LDAP *ld, char *dn, char *mechanism, struct berval *creds, LDAPControl ** serverctrls)
-{
- BerElement *ber = NULL;
- int err;
-
- /* Create a Bind Request for SASL authentication.
- * It look like this :
- * BindRequest := [APPLICATION 0] SEQUENCE {
- * version INTEGER,
- * name LDAPDN,
- * authentication CHOICE {
- * sasl [3] SEQUENCE {
- * mechanism LDAPString,
- * credential OCTET STRING OPTIONAL
- * }
- * }
- * }
- * all wrapped up in an LDAPMessage sequence.
- */
-
- if (dn == NULL || *dn == '\0'){
- ld->ld_errno = LDAP_PARAM_ERROR;
- return (NULLBER);
- }
-
-
- if ( (ber = alloc_ber_with_options( ld )) == NULLBER ) {
- return (NULLBER);
- }
- if ( ber_printf( ber, "{it{ist{s", ++ld->ld_msgid, LDAP_REQ_BIND, ld->ld_version, dn, LDAP_AUTH_SASL, mechanism) == -1){
- ld->ld_errno = LDAP_ENCODING_ERROR;
- ber_free(ber, 1);
- return (NULLBER);
- }
- if (creds != NULL && creds->bv_val != NULL) {
- if (ber_printf(ber, "o", creds->bv_val, creds->bv_len) == -1){
- ld->ld_errno = LDAP_ENCODING_ERROR;
- ber_free(ber, 1);
- return (NULLBER);
- }
- }
- if (ber_printf(ber, "}}") == -1){
- ld->ld_errno = LDAP_ENCODING_ERROR;
- ber_free( ber, 1 );
- return( NULLBER );
- }
- /* LDAPv3 */
- /* Code controls if any */
- if (serverctrls && serverctrls[0]) {
- if (ldap_controls_code(ber, serverctrls) != LDAP_SUCCESS){
- ld->ld_errno = LDAP_ENCODING_ERROR;
- ber_free( ber, 1 );
- return( NULLBER );
- }
- } else if (ld->ld_srvctrls && ld->ld_srvctrls[0]) {
- /* Otherwise, is there any global server ctrls ? */
- if (ldap_controls_code(ber, ld->ld_srvctrls) != LDAP_SUCCESS){
- ld->ld_errno = LDAP_ENCODING_ERROR;
- ber_free( ber, 1 );
- return( NULLBER );
- }
- }
-
- if ( ber_printf( ber, "}" ) == -1 ) {
- ld->ld_errno = LDAP_ENCODING_ERROR;
- ber_free( ber, 1 );
- return( NULLBER );
- }
-
- return (ber);
-}
-
-/*
- * ldap_sasl_bind - bind to the ldap server (and X.500).
- * dn, mechanism, cred, serverctrls, and clientctrls are supplied.
- * the message id of the request is returned in msgid
- * Returns LDAP_SUCCESS or an error code.
- */
-
-int ldap_sasl_bind(
- LDAP *ld,
- char *dn,
- char *mechanism,
- struct berval *cred,
- LDAPControl **serverctrls,
- LDAPControl **clientctrls,
- int *msgidp)
-{
- int theErr = LDAP_SUCCESS;
- int rv;
- BerElement *ber = NULL;
-
- Debug ( LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 1288, "ldap_sasl_bind\n"), 0,0,0);
-
-#ifdef _REENTRANT
- LOCK_LDAP(ld);
-#endif
- if (strcasecmp(mechanism, LDAP_SASL_SIMPLE) == 0){
- /* Simple bind */
- if ( (ber = ldap_build_simple_bind_req(ld, dn, cred->bv_val, serverctrls)) == NULLBER){
- ldap_get_option(ld, LDAP_OPT_ERROR_NUMBER, &theErr);
-#ifdef _REENTRANT
- UNLOCK_LDAP(ld);
-#endif
- return (theErr);
- }
- }
-
- if (strcasecmp(mechanism, LDAP_SASL_CRAM_MD5) == 0){
- if (( ber = ldap_build_sasl_bind_req(ld, dn, LDAP_SASL_CRAM_MD5, cred, serverctrls)) == NULLBER) {
- ldap_get_option(ld, LDAP_OPT_ERROR_NUMBER, &theErr);
-#ifdef _REENTRANT
- UNLOCK_LDAP(ld);
-#endif
- return (theErr);
- }
- }
-
- if (strcasecmp(mechanism, LDAP_SASL_EXTERNAL) == 0){
- if (( ber = ldap_build_sasl_bind_req(ld, dn, LDAP_SASL_EXTERNAL, cred, serverctrls)) == NULLBER) {
- ldap_get_option(ld, LDAP_OPT_ERROR_NUMBER, &theErr);
-#ifdef _REENTRANT
- UNLOCK_LDAP(ld);
-#endif
- return (theErr);
- }
- }
-
- if (strcasecmp(mechanism, LDAP_SASL_X511_PROTECTED) == 0){
-#ifdef _REENTRANT
- UNLOCK_LDAP(ld);
-#endif
- return (LDAP_NOT_SUPPORTED);
-/*
- * if (( ber = ldap_build_sasl_bind_req(ld, dn, LDAP_SASL_X511_PROTECTED, cred, serverctrls)) == NULLBER) {
- * ldap_get_option(ld, LDAP_OPT_ERROR_NUMBER, &theErr);
- *#ifdef _REENTRANT
- * UNLOCK_LDAP(ld);
- *#endif
- * return (theErr);
- * }
- */
- }
- if (strcasecmp(mechanism, LDAP_SASL_X511_STRONG) == 0){
-#ifdef _REENTRANT
- UNLOCK_LDAP(ld);
-#endif
- return (LDAP_NOT_SUPPORTED);
-/*
- * if (( ber = ldap_build_sasl_bind_req(ld, dn, LDAP_SASL_X511_PROTECTED, cred, serverctrls)) == NULLBER) {
- * ldap_get_option(ld, LDAP_OPT_ERROR_NUMBER, &theErr);
- *#ifdef _REENTRANT
- * UNLOCK_LDAP(ld);
- *#endif
- * return (theErr);
- * }
- */
- }
- if (strcasecmp(mechanism, LDAP_SASL_KERBEROS_V4) == 0){
-#ifdef _REENTRANT
- UNLOCK_LDAP(ld);
-#endif
- return (LDAP_NOT_SUPPORTED);
-/*
- * if (( ber = ldap_build_sasl_bind_req(ld, dn, LDAP_SASL_X511_PROTECTED, cred, serverctrls)) == NULLBER) {
- * ldap_get_option(ld, LDAP_OPT_ERROR_NUMBER, &theErr);
- *#ifdef _REENTRANT
- * UNLOCK_LDAP(ld);
- *#endif
- * return (theErr);
- * }
- */
- }
- if (strcasecmp(mechanism, LDAP_SASL_GSSAPI) == 0){
-#ifdef _REENTRANT
- UNLOCK_LDAP(ld);
-#endif
- return (LDAP_NOT_SUPPORTED);
-/*
- * if (( ber = ldap_build_sasl_bind_req(ld, dn, LDAP_SASL_X511_PROTECTED, cred, serverctrls)) == NULLBER) {
- * ldap_get_option(ld, LDAP_OPT_ERROR_NUMBER, &theErr);
- *#ifdef _REENTRANT
- * UNLOCK_LDAP(ld);
- *#endif
- * return (theErr);
- * }
- */
- }
- if (strcasecmp(mechanism, LDAP_SASL_SKEY) == 0){
-#ifdef _REENTRANT
- UNLOCK_LDAP(ld);
-#endif
- return (LDAP_NOT_SUPPORTED);
-/*
- * if (( ber = ldap_build_sasl_bind_req(ld, dn, LDAP_SASL_X511_PROTECTED, cred, serverctrls)) == NULLBER) {
- * ldap_get_option(ld, LDAP_OPT_ERROR_NUMBER, &theErr);
- *#ifdef _REENTRANT
- * UNLOCK_LDAP(ld);
- *#endif
- * return (theErr);
- * }
- */
- }
- if (ber == NULL){
-#ifdef _REENTRANT
- UNLOCK_LDAP(ld);
-#endif
- return (LDAP_PARAM_ERROR);
- }
-
-#ifndef NO_CACHE
- if ( ld->ld_cache != NULL ) {
- ldap_flush_cache( ld );
- }
-#endif /* !NO_CACHE */
-
- /* send the message */
- rv = send_initial_request( ld, LDAP_REQ_BIND, dn, ber );
- if (rv == -1){
- rv = ld->ld_errno;
- if (rv == LDAP_SUCCESS){
- rv = LDAP_OTHER;
- }
-#ifdef _REENTRANT
- UNLOCK_LDAP(ld);
-#endif
- return (rv);
- }
- *msgidp = rv;
-#ifdef _REENTRANT
- UNLOCK_LDAP(ld);
-#endif
- return ( LDAP_SUCCESS );
-}
-
-/*
- * ldap_sasl_bind_s - bind to the ldap server (and X.500).
- * dn, mechanism, cred, serverctrls, and clientctrls are supplied.
- * the message id of the request is returned in msgid
- * Returns LDAP_SUCCESS or an error code.
- */
-
-int ldap_sasl_bind_s(
- LDAP *ld,
- char *dn,
- char *mechanism,
- struct berval *cred,
- LDAPControl **serverctrls,
- LDAPControl **clientctrls,
- struct berval **servercredp)
-{
- int msgid;
- int retcode;
- LDAPMessage *res;
-
- Debug ( LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 1288, "ldap_sasl_bind\n"), 0,0,0);
-
- if ((retcode = ldap_sasl_bind(ld, dn, mechanism, cred, serverctrls, clientctrls, &msgid)) != LDAP_SUCCESS)
- return (retcode);
- if (ldap_result(ld, msgid, 1, (struct timeval *)NULL, &res ) == -1)
- return (ld->ld_errno );
-
- return (ldap_parse_sasl_bind_result(ld, res, servercredp, 1));
-}
-
-int ldap_sasl_cram_md5_bind_s(
- LDAP *ld,
- char *dn,
- struct berval *cred,
- LDAPControl **serverctrls,
- LDAPControl **clientctrls )
-{
- int res;
- struct berval *challenge = NULL;
- struct berval resp;
- unsigned char digest[16];
- char *theHDigest;
-
- if (dn == NULL){
- return (LDAP_PARAM_ERROR);
- }
-
- bzero(digest, sizeof (digest));
-
- if ((res = ldap_sasl_bind_s(ld, dn, LDAP_SASL_CRAM_MD5, NULL, serverctrls, clientctrls, &challenge))
- != LDAP_SASL_BIND_INPROGRESS){
- return (res);
- }
- if (challenge == NULL){
- return (LDAP_PARAM_ERROR);
- }
-
- Debug (LDAP_DEBUG_TRACE, "SASL challenge: %s\n", challenge->bv_val, 0, 0);
-
- hmac_md5((unsigned char *)challenge->bv_val, challenge->bv_len,
- (unsigned char *)cred->bv_val, cred->bv_len, digest);
- ber_bvfree(challenge);
- challenge = NULL;
-
- theHDigest = hexa_print(digest, 16);
- if (theHDigest == NULL){
- return (LDAP_NO_MEMORY);
- }
-
- resp.bv_len = (strlen(dn) + 32 + 1);
- if ((resp.bv_val = (char *)malloc(resp.bv_len+1)) == NULL) {
- return(LDAP_NO_MEMORY);
- }
-
- sprintf(resp.bv_val, "%s %s", dn, theHDigest);
- free(theHDigest);
-
- Debug (LDAP_DEBUG_TRACE, "SASL response: %s\n", resp.bv_val, 0, 0);
- res = ldap_sasl_bind_s(ld, dn, LDAP_SASL_CRAM_MD5, &resp, serverctrls, clientctrls, &challenge);
-
- free(resp.bv_val);
- return (res);
-}
diff --git a/usr/src/lib/libldap4/common/sbind.c b/usr/src/lib/libldap4/common/sbind.c
deleted file mode 100644
index 086459b142..0000000000
--- a/usr/src/lib/libldap4/common/sbind.c
+++ /dev/null
@@ -1,171 +0,0 @@
-/*
- *
- * Portions Copyright 1998 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- *
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*
- * Copyright (c) 1993 Regents of the University of Michigan.
- * All rights reserved.
- *
- * sbind.c
- */
-
-#ifndef lint
-static char copyright[] = "@(#) Copyright (c) 1993 Regents of the University of Michigan.\nAll rights reserved.\n";
-#endif
-
-#include <stdio.h>
-#include <string.h>
-
-#ifdef MACOS
-#include "macos.h"
-#endif /* MACOS */
-
-#if !defined( MACOS ) && !defined( DOS )
-#include <sys/types.h>
-#include <sys/socket.h>
-#endif
-
-#include "lber.h"
-#include "ldap.h"
-#include "ldap-private.h"
-#include "ldap-int.h"
-
-BerElement * ldap_build_simple_bind_req(LDAP *ld, char *dn, char *passwd, LDAPControl **serverctrls)
-{
- /*
- * The bind request looks like this:
- * BindRequest ::= SEQUENCE {
- * version INTEGER,
- * name DistinguishedName, -- who
- * authentication CHOICE {
- * simple [0] OCTET STRING -- passwd
- * }
- * }
- * all wrapped up in an LDAPMessage sequence.
- */
-
- BerElement *ber = NULL;
-
- if ( dn == NULL )
- dn = "";
- if ( passwd == NULL )
- passwd = "";
-
- if ( (ber = alloc_ber_with_options( ld )) == NULLBER ) {
- return (NULLBER);
- }
-
- /* fill it in */
- if ( ber_printf( ber, "{it{ists}", ++ld->ld_msgid, LDAP_REQ_BIND, ld->ld_version, dn, LDAP_AUTH_SIMPLE, passwd ) == -1 ) {
- ld->ld_errno = LDAP_ENCODING_ERROR;
- ber_free( ber, 1 );
- return( NULLBER );
- }
-
- /* LDAPv3 */
- /* Code controls if any */
- if (serverctrls && serverctrls[0]) {
- if (ldap_controls_code(ber, serverctrls) != LDAP_SUCCESS){
- ld->ld_errno = LDAP_ENCODING_ERROR;
- ber_free( ber, 1 );
- return( NULLBER );
- }
- } else if (ld->ld_srvctrls && ld->ld_srvctrls[0]) {
- /* Otherwise, is there any global server ctrls ? */
- if (ldap_controls_code(ber, ld->ld_srvctrls) != LDAP_SUCCESS){
- ld->ld_errno = LDAP_ENCODING_ERROR;
- ber_free( ber, 1 );
- return( NULLBER );
- }
- }
-
- if ( ber_printf( ber, "}" ) == -1 ) {
- ld->ld_errno = LDAP_ENCODING_ERROR;
- ber_free( ber, 1 );
- return( NULLBER );
- }
-
- return (ber);
-}
-
-/*
- * ldap_simple_bind - bind to the ldap server (and X.500). The dn and
- * password of the entry to which to bind are supplied. The message id
- * of the request initiated is returned.
- *
- * Example:
- * ldap_simple_bind( ld, "cn=manager, o=university of michigan, c=us",
- * "secret" )
- */
-
-int
-ldap_simple_bind( LDAP *ld, char *dn, char *passwd )
-{
- BerElement *ber;
- int rv;
-
-
-#ifdef _REENTRANT
- LOCK_LDAP(ld);
-#endif
- Debug( LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 240, "ldap_simple_bind\n"), 0, 0, 0 );
-
- if ( dn == NULL )
- dn = "";
- if ( passwd == NULL )
- passwd = "";
-
- /* create a message to send */
- if ( (ber = ldap_build_simple_bind_req( ld, dn, passwd, NULL )) == NULLBER ) {
-#ifdef _REENTRANT
- UNLOCK_LDAP(ld);
-#endif
- return( -1 );
- }
-
-#ifndef NO_CACHE
- if ( ld->ld_cache != NULL ) {
- ldap_flush_cache( ld );
- }
-#endif /* !NO_CACHE */
-
- /* send the message */
- rv = send_initial_request( ld, LDAP_REQ_BIND, dn, ber );
-#ifdef _REENTRANT
- UNLOCK_LDAP(ld);
-#endif
- return ( rv );
-}
-
-/*
- * ldap_simple_bind - bind to the ldap server (and X.500) using simple
- * authentication. The dn and password of the entry to which to bind are
- * supplied. LDAP_SUCCESS is returned upon success, the ldap error code
- * otherwise.
- *
- * Example:
- * ldap_simple_bind_s( ld, "cn=manager, o=university of michigan, c=us",
- * "secret" )
- */
-
-int
-ldap_simple_bind_s( LDAP *ld, char *dn, char *passwd )
-{
- int msgid;
- LDAPMessage *result;
-
- Debug( LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 241, "ldap_simple_bind_s\n"), 0, 0, 0 );
-
- if ( (msgid = ldap_simple_bind( ld, dn, passwd )) == -1 )
- return( ld->ld_errno );
-
- if ( ldap_result( ld, msgid, 1, (struct timeval *) 0, &result ) == -1 )
- return( ld->ld_errno ); /* ldap_result sets ld_errno */
-
- return( ldap_result2error( ld, result, 1 ) );
-}
diff --git a/usr/src/lib/libldap4/common/search.c b/usr/src/lib/libldap4/common/search.c
deleted file mode 100644
index ca0910aa6d..0000000000
--- a/usr/src/lib/libldap4/common/search.c
+++ /dev/null
@@ -1,939 +0,0 @@
-/*
- *
- * Copyright (c) 1998-2001 by Sun Microsystems, Inc.
- * All rights reserved.
- *
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*
- * Copyright (c) 1990 Regents of the University of Michigan.
- * All rights reserved.
- *
- * search.c
- */
-
-#ifndef lint
-static char copyright[] = "@(#) Copyright (c) 1990 Regents of the University of Michigan.\nAll rights reserved.\n";
-#endif
-
-#include <stdio.h>
-#include <string.h>
-#include <ctype.h>
-#include <stdlib.h> /* free() for Solaris */
-
-#ifdef MACOS
-#include <stdlib.h>
-#include "macos.h"
-#endif /* MACOS */
-
-#if defined(DOS) || defined(_WIN32)
-#include "msdos.h"
-#endif /* DOS */
-
-#if !defined(MACOS) && !defined(DOS) && !defined(_WIN32)
-#include <sys/time.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#endif
-#include "lber.h"
-#include "ldap.h"
-#include "ldap-private.h"
-#include "ldap-int.h"
-
-#ifdef NEEDPROTOS
-static char *find_right_paren(char *s);
-static char *put_complex_filter(BerElement *ber, char *str,
- unsigned int tag, int not);
-static int put_filter(BerElement *ber, char *str);
-static int put_simple_filter(BerElement *ber, char *str);
-static int put_substring_filter(BerElement *ber, char *type, char *str);
-static int put_filter_list(BerElement *ber, char *str);
-static char *star_search(char *str);
-static int hex_char2int(char c);
-static int decode_value(char *str);
-#else
-static char *find_right_paren();
-static char *put_complex_filter();
-static int put_filter();
-static int put_simple_filter();
-static int put_substring_filter();
-static int put_filter_list();
-static char *star_search();
-static int hex_char2int();
-static int decode_value();
-#endif /* NEEDPROTOS */
-
-
-BerElement *
-ldap_build_search_req(LDAP *ld, char *base, int scope, char *filter,
- char **attrs, int attrsonly, LDAPControl ** serverctrls,
- struct timeval *timeoutp, int sizelimit)
-{
- BerElement *ber;
- int err;
- int theSizeLimit, theTimeLimit;
- char *theFilter;
-
- /*
- * Create the search request. It looks like this:
- * SearchRequest := [APPLICATION 3] SEQUENCE {
- * baseObject DistinguishedName,
- * scope ENUMERATED {
- * baseObject (0),
- * singleLevel (1),
- * wholeSubtree (2)
- * },
- * derefAliases ENUMERATED {
- * neverDerefaliases (0),
- * derefInSearching (1),
- * derefFindingBaseObj (2),
- * alwaysDerefAliases (3)
- * },
- * sizelimit INTEGER (0 .. 65535),
- * timelimit INTEGER (0 .. 65535),
- * attrsOnly BOOLEAN,
- * filter Filter,
- * attributes SEQUENCE OF AttributeType
- * }
- * wrapped in an ldap message.
- */
-
- if (filter == NULL || *filter == '\0') {
- ld->ld_errno = LDAP_PARAM_ERROR;
- return (NULLBER);
- }
-
- /* create a message to send */
- if ((ber = alloc_ber_with_options(ld)) == NULLBER) {
- return (NULLBER);
- }
-
- if (base == NULL) {
- base = "";
- }
-
- if (timeoutp != NULL) {
- if (timeoutp->tv_sec > 0) {
- theTimeLimit = (int)(timeoutp->tv_sec +
- (timeoutp->tv_usec / 1000000));
- } else if (timeoutp->tv_usec > 0) {
- theTimeLimit = 1; /* minimum we can express in LDAP */
- } else {
- theTimeLimit = 0; /* no limit */
- }
- } else {
- theTimeLimit = ld->ld_timelimit;
- }
-
-#ifdef CLDAP
- if (ld->ld_sb.sb_naddr > 0) {
- err = ber_printf(ber, "{ist{seeiib", ++ld->ld_msgid,
- ld->ld_cldapdn, LDAP_REQ_SEARCH, base, scope, ld->ld_deref,
- sizelimit == -1 ? ld->ld_sizelimit : sizelimit, theTimeLimit,
- attrsonly);
- } else {
-#endif /* CLDAP */
- err = ber_printf(ber, "{it{seeiib", ++ld->ld_msgid,
- LDAP_REQ_SEARCH, base, scope, ld->ld_deref,
- sizelimit == -1 ? ld->ld_sizelimit : sizelimit,
- theTimeLimit, attrsonly);
-#ifdef CLDAP
- }
-#endif /* CLDAP */
-
- if (err == -1) {
- ld->ld_errno = LDAP_ENCODING_ERROR;
- ber_free(ber, 1);
- return (NULLBER);
- }
-
- theFilter = filter;
- while (*theFilter == ' ') theFilter++;
- if ((*theFilter == '&') || (*theFilter == '|') || (*theFilter == '!')) {
- char *ptr = theFilter;
- theFilter = (char *)calloc(1, strlen(ptr) + 3);
- sprintf(theFilter, "(%s)", ptr);
- } else {
- theFilter = strdup(filter);
- }
- err = put_filter(ber, theFilter);
- free(theFilter);
-
- if (err == -1) {
- ld->ld_errno = LDAP_FILTER_ERROR;
- ber_free(ber, 1);
- return (NULLBER);
- }
-
- if (ber_printf(ber, "{v}}", attrs) == -1) {
- ld->ld_errno = LDAP_ENCODING_ERROR;
- ber_free(ber, 1);
- return (NULLBER);
- }
-
- /* LDAPv3 */
- /* Code controls if any */
- if (serverctrls && serverctrls[0]) {
- if (ldap_controls_code(ber, serverctrls) != LDAP_SUCCESS) {
- ld->ld_errno = LDAP_ENCODING_ERROR;
- ber_free(ber, 1);
- return (NULLBER);
- }
- } else if (ld->ld_srvctrls && ld->ld_srvctrls[0]) {
- /* Otherwise, is there any global server ctrls ? */
- if (ldap_controls_code(ber, ld->ld_srvctrls) != LDAP_SUCCESS) {
- ld->ld_errno = LDAP_ENCODING_ERROR;
- ber_free(ber, 1);
- return (NULLBER);
- }
- }
-
- if (ber_printf(ber, "}") == -1) {
- ld->ld_errno = LDAP_ENCODING_ERROR;
- ber_free(ber, 1);
- return (NULLBER);
- }
-
- return (ber);
-}
-
-/*
- * ldap_search - initiate an ldap (and X.500) search operation. Parameters:
- *
- * ld LDAP descriptor
- * base DN of the base object
- * scope the search scope - one of LDAP_SCOPE_BASE,
- * LDAP_SCOPE_ONELEVEL, LDAP_SCOPE_SUBTREE
- * filter a string containing the search filter
- * (e.g., "(|(cn=bob)(sn=bob))")
- * attrs list of attribute types to return for matches
- * attrsonly 1 => attributes only 0 => attributes and values
- *
- * Example:
- * char *attrs[] = { "mail", "title", 0 };
- * msgid = ldap_search( ld, "c=us@o=UM", LDAP_SCOPE_SUBTREE, "cn~=bob",
- * attrs, attrsonly );
- */
-int
-ldap_search(LDAP *ld, char *base, int scope, char *filter,
- char **attrs, int attrsonly)
-{
- BerElement *ber;
-
-#if defined(SUN) && defined(_REENTRANT)
- int rv;
-
- LOCK_LDAP(ld);
-#endif
- Debug(LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 242, "ldap_search\n"),
- 0, 0, 0);
-
- if ((ber = ldap_build_search_req(ld, base, scope, filter, attrs,
- attrsonly, NULL, NULL, -1)) == NULLBER) {
-#if defined(SUN) && defined(_REENTRANT)
- UNLOCK_LDAP(ld);
-#endif
- return (-1);
- }
-
-#ifndef NO_CACHE
- if (ld->ld_cache != NULL) {
- if (check_cache(ld, LDAP_REQ_SEARCH, ber) == 0) {
- ber_free(ber, 1);
- ld->ld_errno = LDAP_SUCCESS;
- rv = ld->ld_msgid;
-#ifdef _REENTRANT
- UNLOCK_LDAP(ld);
-#endif
- return (rv);
- }
- add_request_to_cache(ld, LDAP_REQ_SEARCH, ber);
- }
-#endif /* NO_CACHE */
-
- /* send the message */
- rv = send_initial_request(ld, LDAP_REQ_SEARCH, base, ber);
-#ifdef _REENTRANT
- UNLOCK_LDAP(ld);
-#endif
- return (rv);
-}
-
-
-static char *
-find_right_paren(char *s)
-{
- int balance, escape;
-
- balance = 1;
- escape = 0;
- while (*s && balance) {
- if (escape == 0) {
- if (*s == '(')
- balance++;
- else if (*s == ')')
- balance--;
- }
- if (*s == '\\' && ! escape)
- escape = 1;
- else
- escape = 0;
- if (balance)
- s++;
- }
-
- return (*s ? s : NULL);
-}
-
-static char *
-put_complex_filter(BerElement *ber, char *str, unsigned int tag, int not)
-{
- char *next;
-
- /*
- * We have (x(filter)...) with str sitting on
- * the x. We have to find the paren matching
- * the one before the x and put the intervening
- * filters by calling put_filter_list().
- */
-
- /* put explicit tag */
- if (ber_printf(ber, "t{", tag) == -1)
- return (NULL);
-/*
- if (!not && ber_printf(ber, "{") == -1)
- return (NULL);
-*/
-
- str++;
- if ((next = find_right_paren(str)) == NULL)
- return (NULL);
-
- *next = '\0';
- if (put_filter_list(ber, str) == -1)
- return (NULL);
- *next++ = ')';
-
- /* flush explicit tagged thang */
- if (ber_printf(ber, "}") == -1)
- return (NULL);
-/*
- if (!not && ber_printf(ber, "}") == -1)
- return (NULL);
-*/
-
- return (next);
-}
-
-static int
-put_filter(BerElement *ber, char *str)
-{
- char *next, *tmp, *s, *d;
- int parens, balance, escape;
- int multipleparen = 0;
-
- /*
- * A Filter looks like this:
- * Filter ::= CHOICE {
- * and [0] SET OF Filter,
- * or [1] SET OF Filter,
- * not [2] Filter,
- * equalityMatch [3] AttributeValueAssertion,
- * substrings [4] SubstringFilter,
- * greaterOrEqual [5] AttributeValueAssertion,
- * lessOrEqual [6] AttributeValueAssertion,
- * present [7] AttributeType,
- * approxMatch [8] AttributeValueAssertion,
- * extensibleMatch [9] MatchingRuleAssertion
- * }
- *
- * SubstringFilter ::= SEQUENCE {
- * type AttributeType,
- * SEQUENCE OF CHOICE {
- * initial [0] IA5String,
- * any [1] IA5String,
- * final [2] IA5String
- * }
- * }
- * MatchingRuleAssertion ::= SEQUENCE {
- * matchingRule [1] MatchingRuleId OPTIONAL,
- * type [2] AttributeDescription OPTIONAL,
- * matchValue [3] AssertionValue,
- * dnAttributes [4] BOOLEAN DEFAULT FALSE
- * }
- *
- * Note: tags in a choice are always explicit
- */
-
- Debug(LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 243,
- "put_filter \"%s\"\n"), str, 0, 0);
-
- parens = 0;
- while (*str) {
- switch (*str) {
- case '(':
- str++;
- parens++;
- switch (*str) {
- case '&':
- Debug(LDAP_DEBUG_TRACE, catgets(slapdcat, 1,
- 244, "put_filter: AND\n"), 0, 0, 0);
-
- if ((str = put_complex_filter(ber, str,
- LDAP_FILTER_AND, 0)) == NULL)
- return (-1);
-
- parens--;
- break;
-
- case '|':
- Debug(LDAP_DEBUG_TRACE, catgets(slapdcat, 1,
- 245, "put_filter: OR\n"), 0, 0, 0);
-
- if ((str = put_complex_filter(ber, str,
- LDAP_FILTER_OR, 0)) == NULL)
- return (-1);
-
- parens--;
- break;
-
- case '!':
- Debug(LDAP_DEBUG_TRACE, catgets(slapdcat, 1,
- 246, "put_filter: NOT\n"), 0, 0, 0);
-
- if ((str = put_complex_filter(ber, str,
- LDAP_FILTER_NOT, 1)) == NULL)
- return (-1);
-
- parens--;
- break;
-
- case '(':
- Debug(LDAP_DEBUG_TRACE, catgets(slapdcat, 1,
- 402, "put_filter: Double Parentheses\n"),
- 0, 0, 0);
- multipleparen++;
- continue;
-
- default:
- Debug(LDAP_DEBUG_TRACE, catgets(slapdcat, 1,
- 247, "put_filter: simple\n"), 0, 0, 0);
-
- balance = 1;
- escape = 0;
- next = str;
- while (*next && balance) {
- if (escape == 0) {
- if (*next == '(')
- balance++;
- else if (*next == ')')
- balance--;
- }
- if (*next == '\\' && ! escape)
- escape = 1;
- else
- escape = 0;
- if (balance)
- next++;
- }
- if (balance != 0)
- return (-1);
-
- *next = '\0';
- if (put_simple_filter(ber, str) == -1)
- return (-1);
- *next++ = ')';
- str = next;
- parens--;
- break;
- }
- break;
-
- case ')':
- Debug(LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 248,
- "put_filter: end\n"), 0, 0, 0);
- if (multipleparen) {
- multipleparen--;
- } else {
- if (ber_printf(ber, "]") == -1)
- return (-1);
- }
-
- str++;
- parens--;
- break;
-
- case ' ':
- str++;
- break;
-
- default: /* assume it's a simple type=value filter */
- Debug(LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 249,
- "put_filter: default\n"), 0, 0, 0);
- next = strchr(str, '\0');
- if (put_simple_filter(ber, str) == -1) {
- return (-1);
- }
- str = next;
- break;
- }
- }
-
- return (parens ? -1 : 0);
-}
-
-/*
- * Put a list of filters like this "(filter1)(filter2)..."
- */
-
-static int
-put_filter_list(BerElement *ber, char *str)
-{
- char *next;
- char save;
-
- Debug(LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 250,
- "put_filter_list \"%s\"\n"), str, 0, 0);
-
- while (*str) {
- while (*str && isspace(*str))
- str++;
- if (*str == '\0')
- break;
-
- if ((next = find_right_paren(str + 1)) == NULL)
- return (-1);
- save = *++next;
-
- /* now we have "(filter)" with str pointing to it */
- *next = '\0';
- if (put_filter(ber, str) == -1)
- return (-1);
- *next = save;
-
- str = next;
- }
-
- return (0);
-}
-
-static int
-put_simple_filter(BerElement *ber, char *str)
-{
- char *s;
- char *value, savechar;
- unsigned int ftype;
- int rc;
- int len;
-
- Debug(LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 251,
- "put_simple_filter \"%s\"\n"), str, 0, 0);
-
- if ((s = strchr(str, '=')) == NULL)
- return (-1);
- value = s + 1;
- *s-- = '\0';
- savechar = *s;
-
- switch (*s) {
- case '<':
- ftype = LDAP_FILTER_LE;
- *s = '\0';
- break;
- case '>':
- ftype = LDAP_FILTER_GE;
- *s = '\0';
- break;
- case '~':
- ftype = LDAP_FILTER_APPROX;
- *s = '\0';
- break;
- /* LDAP V3 : New extensible matching */
- case ':':
- rc = put_extensible_filter(ber, str, value);
- *(value -1) = '=';
- return (rc);
- default:
- if (star_search(value) == NULL) {
- ftype = LDAP_FILTER_EQUALITY;
- } else if (strcmp(value, "*") == 0) {
- ftype = LDAP_FILTER_PRESENT;
- } else {
- rc = put_substring_filter(ber, str, value);
- *(value-1) = '=';
- return (rc);
- }
- break;
- }
-
- if (*(value -1) == '=')
- return (rc);
- if (ftype == LDAP_FILTER_PRESENT) {
- rc = ber_printf(ber, "ts", ftype, str);
- } else {
- if ((len = decode_value(value)) >= 0)
- rc = ber_printf(ber, "t{so}", ftype, str, value, len);
- }
-
- *s = savechar;
- *(value-1) = '=';
- return (rc == -1 ? rc : 0);
-}
-
-static int
-put_substring_filter(BerElement *ber, char *type, char *val)
-{
- char *nextstar, gotstar = 0;
- unsigned int ftype;
- int len;
-
- Debug(LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 252,
- "put_substring_filter \"%1$s=%2$s\"\n"), type, val, 0);
-
- if (ber_printf(ber, "t{s{", LDAP_FILTER_SUBSTRINGS, type) == -1)
- return (-1);
-
- while (val != NULL) {
- if ((nextstar = star_search(val)) != NULL)
- *nextstar++ = '\0';
-
- if (gotstar == 0) {
- ftype = LDAP_SUBSTRING_INITIAL;
- } else if (nextstar == NULL) {
- ftype = LDAP_SUBSTRING_FINAL;
- } else {
- ftype = LDAP_SUBSTRING_ANY;
- }
- if (*val != '\0') {
- if ((len = decode_value(val)) == -1 ||
- ber_printf(ber, "to", ftype, val, len) == -1)
- return (-1);
- }
-
- gotstar = 1;
- if (nextstar != NULL)
- *(nextstar-1) = '*';
- val = nextstar;
- }
-
- if (ber_printf(ber, "}}") == -1)
- return (-1);
-
- return (0);
-}
-
-static int
-put_extensible_filter(BerElement *ber, char *type, char *val)
-{
- char *ptr, *ptype;
- char *dn, *rule;
- int len;
-
- Debug(LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 252,
- "put_extensible_filter \"%1$s=%2$s\"\n"), type, val, 0);
-
- /* type is off form : attr:dn:matchingrule: or :dn:matchingrule: */
- /* type ends with ':', suppress it */
- ptr = strdup(type);
- ptype = ptr;
- while (*ptype) {
- *ptype = tolower(*ptype);
- ptype++;
- }
-
- len = strlen(ptr);
- if (len > 0 && ptr[len -1] == ':')
- ptr [len - 1] = '\0';
- else {
- return (-1);
- }
-
- ptype = ptr;
- /* Search first ':dn' */
- if ((dn = strstr(ptype, ":dn")) == NULL) {
- /* No dn */
- /* if there's a : its separating type and matching rule */
- rule = strchr(ptype, ':');
- if (rule == ptype) {
- ptype = NULL;
- }
- } else {
- if (dn == ptype) {
- ptype = NULL;
- } else {
- *dn = '\0';
- }
-
- rule = dn + 3;
- }
-
- if (rule && rule[0] == ':') {
- rule[0] = '\0';
- rule++;
- } else {
- rule = NULL;
- }
-
- if ((ptype == NULL || *ptype == '\0') && rule == NULL) {
- free(ptr);
- return (-1);
- }
-
- if (ber_printf(ber, "t{", LDAP_FILTER_EXTENSIBLE) == -1) {
- free(ptr);
- return (-1);
- }
-
- if (rule && *rule && (ber_printf(ber, "ts",
- LDAP_TAG_FEXT_RULE, rule) == -1)) {
- free(ptr);
- return (-1);
- }
-
- if (ptype && *ptype && (ber_printf(ber, "ts",
- LDAP_TAG_FEXT_TYPE, ptype) == -1)) {
- free(ptr);
- return (-1);
- }
-
- /* Code value */
- if ((len = decode_value(val)) == -1 ||
- ber_printf(ber, "to", LDAP_TAG_FEXT_VAL, val, len) == -1) {
- free(ptr);
- return (-1);
- }
-
- if (dn && (ber_printf(ber, "tb", LDAP_TAG_FEXT_DN, 1) == -1)) {
- free(ptr);
- return (-1);
- }
-
- free(ptr);
-
- if (ber_printf(ber, "}") == -1)
- return (-1);
-
- return (0);
-}
-
-int
-ldap_search_st(LDAP *ld, char *base, int scope, char *filter, char **attrs,
- int attrsonly, struct timeval *timeout, LDAPMessage **res)
-{
- int msgid;
-
- if ((msgid = ldap_search(ld, base, scope, filter, attrs, attrsonly))
- == -1)
- return (ld->ld_errno);
-
- if (ldap_result(ld, msgid, 1, timeout, res) == -1)
- return (ld->ld_errno);
-
- if (ld->ld_errno == LDAP_TIMEOUT) {
- (void) ldap_abandon(ld, msgid);
- ld->ld_errno = LDAP_TIMEOUT;
- return (ld->ld_errno);
- }
-
- return (ldap_result2error(ld, *res, 0));
-}
-
-int
-ldap_search_s(LDAP *ld, char *base, int scope, char *filter, char **attrs,
- int attrsonly, LDAPMessage **res)
-{
- int msgid;
-
- if ((msgid = ldap_search(ld, base, scope, filter, attrs, attrsonly))
- == -1)
- return (ld->ld_errno);
-
- if (ldap_result(ld, msgid, 1, (struct timeval *)NULL, res) == -1)
- return (ld->ld_errno);
-
- return (ldap_result2error(ld, *res, 0));
-}
-
-/* LDAPv3 API EXTENSIONS */
-int ldap_search_ext(LDAP *ld, char *base, int scope, char *filter,
- char **attrs, int attrsonly, LDAPControl **serverctrls,
- LDAPControl **clientctrls, struct timeval *timeoutp, int sizelimit,
- int *msgidp)
-{
- BerElement *ber;
- int rv;
-
- if (timeoutp != NULL && timeoutp->tv_sec == 0 &&
- timeoutp->tv_usec == 0) {
- timeoutp = NULL;
- }
-
-#ifdef _REENTRANT
- LOCK_LDAP(ld);
-#endif
- Debug(LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 242,
- "ldap_search\n"), 0, 0, 0);
-
- if ((ber = ldap_build_search_req(ld, base, scope, filter, attrs,
- attrsonly, serverctrls, timeoutp, sizelimit)) == NULLBER) {
- rv = ld->ld_errno;
- if (rv == LDAP_SUCCESS)
- rv = LDAP_OTHER;
-#ifdef _REENTRANT
- UNLOCK_LDAP(ld);
-#endif
- return (rv);
- }
-
-#ifndef NO_CACHE
- if (ld->ld_cache != NULL) {
- if (check_cache(ld, LDAP_REQ_SEARCH, ber) == 0) {
- ber_free(ber, 1);
- ld->ld_errno = LDAP_SUCCESS;
- *msgidp = ld->ld_msgid;
-#ifdef _REENTRANT
- UNLOCK_LDAP(ld);
-#endif
- return (LDAP_SUCCESS);
- }
- add_request_to_cache(ld, LDAP_REQ_SEARCH, ber);
- }
-#endif /* NO_CACHE */
-
- /* send the message */
- rv = send_initial_request(ld, LDAP_REQ_SEARCH, base, ber);
- if (rv == -1) {
- rv = ld->ld_errno;
- if (rv == LDAP_SUCCESS) {
- rv = LDAP_OTHER;
- }
-#ifdef _REENTRANT
- UNLOCK_LDAP(ld);
-#endif
- return (rv);
- }
-
- *msgidp = rv;
-#if _REENTRANT
- UNLOCK_LDAP(ld);
-#endif
- return (LDAP_SUCCESS);
-}
-
-
-int ldap_search_ext_s(LDAP *ld, char *base, int scope, char *filter,
- char **attrs, int attrsonly, LDAPControl **serverctrls,
- LDAPControl **clientctrls, struct timeval *timeoutp, int sizelimit,
- LDAPMessage **res)
-{
- int msgid;
- int retcode = LDAP_SUCCESS;
-
- if ((retcode = ldap_search_ext(ld, base, scope, filter, attrs,
- attrsonly, serverctrls, clientctrls, timeoutp, sizelimit,
- &msgid)) != LDAP_SUCCESS)
- return (retcode);
- if (ldap_result(ld, msgid, 1, timeoutp, res) == -1)
- return (ld->ld_errno);
-
-
-#if _REENTRANT
- LOCK_LDAP(ld);
-#endif
- retcode = ldap_parse_result(ld, *res, &ld->ld_errno, &ld->ld_matched,
- &ld->ld_error, &ld->ld_referrals, &ld->ld_ret_ctrls, 0);
- if (retcode == LDAP_SUCCESS)
- retcode = ld->ld_errno;
-#if _REENTRANT
- UNLOCK_LDAP(ld);
-#endif
- return (retcode);
-}
-
-/*
- * Search string for ascii '*' (asterisk) character.
- * RFC 1960 permits an escaped asterisk to pass through.
- * RFC 2254 adds the definition of encoded characters:
- *
- * Character ASCII value
- * ---------------------------
- * * 0x2a
- * ( 0x28
- * ) 0x29
- * \ 0x5c
- * NUL 0x00
- *
- * No distinction of escaped characters is made here.
- */
-static char *
-star_search(char *str)
-{
- for (; *str; str++) {
- switch (*str) {
- case '*':
- return (str);
- case '\\':
- if (str[1] == '\0')
- break; /* input string exahausted */
- ++str; /* Assume RFC 1960 escaped character */
- /* Check for RFC 2254 hex encoding */
- if (hex_char2int(str[0]) >= 0 &&
- hex_char2int(str[1]) >= 0) {
- str++; /* skip over RFC 2254 hex encoding */
- }
- default:
- break;
- }
- }
- return (NULL);
-}
-
-/*
- * Return integer value of hexadecimal character or (-1) if character is
- * not a hexadecimal digit [0-9A-Fa-f].
- */
-static int
-hex_char2int(char c)
-{
- if (c >= '0' && c <= '9') {
- return (c-'0');
- } else if (c >= 'A' && c <= 'F') {
- return (c-'A'+10);
- } else if (c >= 'a' && c <= 'f') {
- return (c-'a'+10);
- }
- return (-1);
-}
-
-/*
- * Modifys passed string converting escaped hexadecimal characters as
- * per RFC 2254 and un-escapes escaped characters. Returns length of
- * modified string as it may contain null characters as per RFC 2254.
- */
-static int
-decode_value(char *start)
-{
- char *read, *write;
- int hn, ln;
-
- for (read = write = start; *read; *write++ = *read++) {
- if (*read == '\\') {
- if (*++read == '\0')
- break; /* input string exahausted */
- /*
- * Assume *read is simple RFC 1960 escaped character.
- * However check for RFC 2254 hex encoding.
- */
- if ((hn = hex_char2int(read[0])) >= 0 &&
- (ln = hex_char2int(read[1])) >= 0) {
- read++;
- *read = (hn<<4)+ln;
- }
- }
- }
- *write = '\0';
- return (write-start);
-}
-
diff --git a/usr/src/lib/libldap4/common/sort.c b/usr/src/lib/libldap4/common/sort.c
deleted file mode 100644
index 881fe01510..0000000000
--- a/usr/src/lib/libldap4/common/sort.c
+++ /dev/null
@@ -1,180 +0,0 @@
-/*
- *
- * Portions Copyright 1998 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- *
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*
- * Copyright (c) 1994 Regents of the University of Michigan.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms are permitted
- * provided that this notice is preserved and that due credit is given
- * to the University of Michigan at Ann Arbor. The name of the University
- * may not be used to endorse or promote products derived from this
- * software without specific prior written permission. This software
- * is provided ``as is'' without express or implied warranty.
- *
- * sort.c: LDAP library entry and value sort routines
- */
-
-#include <stdio.h>
-#include <ctype.h>
-#include <string.h>
-#include <stdlib.h>
-#include <time.h>
-#ifdef MACOS
-#include "macos.h"
-#else /* MACOS */
-#ifdef DOS
-#include <malloc.h>
-#include "msdos.h"
-#endif /* DOS */
-#endif /* MACOS */
-
-#include "lber.h"
-#include "ldap.h"
-#include "ldap-private.h"
-#include "ldap-int.h"
-
-struct entrything {
- char **et_vals;
- LDAPMessage *et_msg;
-};
-
-#ifndef NEEDPROTOS
-static int (*et_cmp_fn)();
-static int et_cmp();
-#else /* !NEEDPROTOS */
-static int (*et_cmp_fn)( char *a, char *b );
-#ifdef SUN
-static int et_cmp( const void *aa, const void *bb);
-#else
-static int et_cmp( void *aa, void *bb);
-#endif
-#endif /* !NEEDPROTOS */
-
-int
-ldap_sort_strcasecmp(
- char **a,
- char **b
-)
-{
- return( strcasecmp( *a, *b ) );
-}
-
-static int
-et_cmp(
-#ifdef SUN
- const void *aa,
- const void *bb
-#else
- void *aa,
- void *bb
-#endif
-)
-{
- int i, rc;
- struct entrything *a = (struct entrything *)aa;
- struct entrything *b = (struct entrything *)bb;
-
- if ( a->et_vals == NULL && b->et_vals == NULL )
- return( 0 );
- if ( a->et_vals == NULL )
- return( -1 );
- if ( b->et_vals == NULL )
- return( 1 );
-
- for ( i = 0; a->et_vals[i] && b->et_vals[i]; i++ ) {
- if ( (rc = (*et_cmp_fn)( a->et_vals[i], b->et_vals[i] ))
- != 0 ) {
- return( rc );
- }
- }
-
- if ( a->et_vals[i] == NULL && b->et_vals[i] == NULL )
- return( 0 );
- if ( a->et_vals[i] == NULL )
- return( -1 );
- return( 1 );
-}
-
-int
-ldap_sort_entries(
- LDAP *ld,
- LDAPMessage **chain,
- char *attr, /* NULL => sort by DN */
- int (*cmp)()
-)
-{
- int i;
- size_t count;
- struct entrything *et;
- LDAPMessage *e, *last;
- LDAPMessage **ep;
-
- count = ldap_count_entries( ld, *chain );
-
- if ( (et = (struct entrything *) malloc( count *
- sizeof(struct entrything) )) == NULL ) {
- ld->ld_errno = LDAP_NO_MEMORY;
- return( -1 );
- }
-
- e = *chain;
- for ( i = 0; i < count; i++ ) {
- et[i].et_msg = e;
- if ( attr == NULL ) {
- char *dn;
-
- dn = ldap_get_dn( ld, e );
- et[i].et_vals = ldap_explode_dn( dn, 1 );
- free( dn );
- } else {
- et[i].et_vals = ldap_get_values( ld, e, attr );
- }
-
- e = e->lm_chain;
- }
- last = e;
-
- et_cmp_fn = cmp;
-#ifdef SUN
- qsort( et, count, sizeof(struct entrything), et_cmp );
-#else
- qsort( et, count, sizeof(struct entrything), (void *) et_cmp );
-#endif
-
- ep = chain;
- for ( i = 0; i < count; i++ ) {
- *ep = et[i].et_msg;
- ep = &(*ep)->lm_chain;
-
- ldap_value_free( et[i].et_vals );
- }
- *ep = last;
- free( (char *) et );
-
- return( 0 );
-}
-
-/* ARGSUSED */
-int
-ldap_sort_values(
- LDAP *ld,
- char **vals,
- int (*cmp)()
-)
-{
- size_t nel;
-
- for ( nel = 0; vals[nel] != NULL; nel++ )
- ; /* NULL */
-
- qsort( vals, nel, sizeof(char *), cmp );
-
- return( 0 );
-}
diff --git a/usr/src/lib/libldap4/common/sortctrl.c b/usr/src/lib/libldap4/common/sortctrl.c
deleted file mode 100644
index d21a01e33f..0000000000
--- a/usr/src/lib/libldap4/common/sortctrl.c
+++ /dev/null
@@ -1,426 +0,0 @@
-/*
- *
- * Copyright 1999 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- *
- *
- * Comments:
- *
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#include <stdio.h>
-#include <string.h>
-#include <ctype.h>
-
-#include "lber.h"
-#include "ldap.h"
-#include "ldap-private.h"
-#include "ldap-int.h"
-
-static int count_tokens(char *s);
-static int isattrdescchar(char c);
-static int read_next_token(char **s, LDAPsortkey **key);
-
-
-int ldap_create_sort_control(LDAP *ld, LDAPsortkey **sortKeyList,
- const char ctl_iscritical, LDAPControl **ctrlp)
-{
- BerElement *ber;
- int i, rc;
-
- if (NULL == ld) {
- return (LDAP_PARAM_ERROR);
- }
-
- if (sortKeyList == NULL || ctrlp == NULL) {
- ld->ld_errno = LDAP_PARAM_ERROR;
- return (LDAP_PARAM_ERROR);
- }
-
- /* create a ber package to hold the controlValue */
- if ((ber = alloc_ber_with_options(ld)) == NULLBER) {
- ld->ld_errno = LDAP_NO_MEMORY;
- return (LDAP_NO_MEMORY);
- }
-
- /* encode the start of the sequence of sequences into the ber */
- if (ber_printf(ber, "{") == -1) {
- goto encoding_error_exit;
- }
-
- /*
- * the sort control value will be encoded as a sequence of sequences
- * which are each encoded as one of the following: {s} or {sts} or
- * {stb} or {ststb} since the orderingRule and reverseOrder flag are
- * both optional
- */
- for (i = 0; sortKeyList[i] != NULL; i++) {
-
- /* encode the attributeType into the ber */
- if (ber_printf(ber, "{s", (sortKeyList[i])->sk_attrtype)
- == -1) {
- goto encoding_error_exit;
- }
-
- /* encode the optional orderingRule into the ber */
- if ((sortKeyList[i])->sk_matchruleoid != NULL) {
- if (ber_printf(ber, "ts", LDAP_TAG_SK_MATCHRULE,
- (sortKeyList[i])->sk_matchruleoid)
- == -1) {
- goto encoding_error_exit;
- }
- }
-
- /* Encode the optional reverseOrder flag into the ber. */
- /* If the flag is false, it should be absent. */
- if ((sortKeyList[i])->sk_reverseorder) {
- if (ber_printf(ber, "tb}", LDAP_TAG_SK_REVERSE,
- (sortKeyList[i])->sk_reverseorder) == -1) {
- goto encoding_error_exit;
- }
- } else {
- if (ber_printf(ber, "}") == -1) {
- goto encoding_error_exit;
- }
- }
- }
-
- /* encode the end of the sequence of sequences into the ber */
- if (ber_printf(ber, "}") == -1) {
- goto encoding_error_exit;
- }
-
- rc = ldap_build_control(LDAP_CONTROL_SORTREQUEST, ber, 1,
- ctl_iscritical, ctrlp);
- ld->ld_errno = rc;
- return (rc);
-
-encoding_error_exit:
- ld->ld_errno = LDAP_ENCODING_ERROR;
- ber_free(ber, 1);
- return (LDAP_ENCODING_ERROR);
-}
-
-
-int ldap_parse_sort_control(LDAP *ld, LDAPControl **ctrlp,
- unsigned long *result, char **attribute)
-{
- BerElement *ber;
- int i, foundSortControl;
- LDAPControl *sortCtrlp;
- unsigned int len;
- char *attr;
- int tag;
-
- if ((NULL == ld) || (result == NULL) ||
- (attribute == NULL)) {
- return (LDAP_PARAM_ERROR);
- }
-
-
- /* find the sortControl in the list of controls if it exists */
- if (ctrlp == NULL) {
- ld->ld_errno = LDAP_CONTROL_NOT_FOUND;
- return (LDAP_CONTROL_NOT_FOUND);
- }
- foundSortControl = 0;
- for (i = 0; ((ctrlp[i] != NULL) && (!foundSortControl)); i++) {
- foundSortControl = !(strcmp(ctrlp[i]->ldctl_oid,
- LDAP_CONTROL_SORTRESPONSE));
- }
- if (!foundSortControl) {
- ld->ld_errno = LDAP_CONTROL_NOT_FOUND;
- return (LDAP_CONTROL_NOT_FOUND);
- } else {
- /* let local var point to the sortControl */
- sortCtrlp = ctrlp[i-1];
- }
-
- /*
- * allocate a Ber element with the contents of the sort_control's
- * struct berval
- */
- if ((ber = ber_init(&sortCtrlp->ldctl_value)) == NULL) {
- ld->ld_errno = LDAP_NO_MEMORY;
- return (LDAP_NO_MEMORY);
- }
-
- /* decode the result from the Berelement */
- if (ber_scanf(ber, "{i", result) == LBER_ERROR) {
- ld->ld_errno = LDAP_DECODING_ERROR;
- ber_free(ber, 1);
- return (LDAP_DECODING_ERROR);
- }
-
- /*
- * if the server returned one, decode the attribute from the Ber element
- */
- if (ber_peek_tag(ber, &len) == LDAP_TAG_SR_ATTRTYPE) {
- if (ber_scanf(ber, "ta", &tag, &attr) == LBER_ERROR) {
- ld->ld_errno = LDAP_DECODING_ERROR;
- ber_free(ber, 1);
- return (LDAP_DECODING_ERROR);
- }
- *attribute = attr;
- } else {
- *attribute = NULL;
- }
-
- if (ber_scanf(ber, "}") == LBER_ERROR) {
- ld->ld_errno = LDAP_DECODING_ERROR;
- ber_free(ber, 1);
- return (LDAP_DECODING_ERROR);
- }
-
- /* the ber encoding is no longer needed */
- ber_free(ber, 1);
- return (LDAP_SUCCESS);
-}
-
-
-/*
- * Routines for the manipulation of string-representations of sort control
- * keylists
- */
-static int count_tokens(char *s)
-{
- int count = 0;
- char *p = s;
- int whitespace = 1;
- /*
- * Loop along the string counting the number of times we see the
- * beginning of non-whitespace. This tells us
- * the number of tokens in the string
- */
- while (*p != '\0') {
- if (whitespace) {
- if (!isspace(*p)) {
- whitespace = 0;
- count++;
- }
- } else {
- if (isspace(*p)) {
- whitespace = 1;
- }
- }
- p++;
- }
- return (count);
-}
-
-
-/* Is this character a valid attribute description character ? */
-static int isattrdescchar(char c)
-{
- /* Alphanumeric chars are in */
- if (isalnum(c)) {
- return (1);
- }
- /* As is ';' */
- if (';' == c) {
- return (1);
- }
- /* Everything else is out */
- return (0);
-}
-
-
-static int read_next_token(char **s, LDAPsortkey **key)
-{
- char c = 0;
- char *pos = *s;
- int retval = 0;
- LDAPsortkey *new_key = NULL;
-
- char *matchrule_source = NULL;
- int matchrule_size = 0;
- char *attrdesc_source = NULL;
- int attrdesc_size = 0;
- int reverse = 0;
-
- int state = 0;
-
- while (((c = *pos++) != '\0') && (state != 4)) {
- switch (state) {
- case 0:
- /* case where we've not seen the beginning of the attr yet */
- /* If we still see whitespace, nothing to do */
- if (!isspace(c)) {
- /* Otherwise, something to look at */
- /* Is it a minus sign ? */
- if ('-' == c) {
- reverse = 1;
- } else {
- attrdesc_source = pos - 1;
- state = 1;
- }
- }
- break;
- case 1:
- /*
- * case where we've seen the beginning of the attr, but not
- * the end
- */
- /* Is this char either whitespace or a ':' ? */
- if (isspace(c) || (':' == c)) {
- attrdesc_size = (pos - attrdesc_source) - 1;
- if (':' == c) {
- state = 2;
- } else {
- state = 4;
- }
- }
- break;
- case 2:
- /*
- * case where we've seen the end of the attr and want the
- * beginning of match rule
- */
- if (!isspace(c)) {
- matchrule_source = pos - 1;
- state = 3;
- } else {
- state = 4;
- }
- break;
- case 3:
- /*
- * case where we've seen the beginning of match rule and
- * want to find the end
- */
- if (isspace(c)) {
- matchrule_size = (pos - matchrule_source) - 1;
- state = 4;
- }
- break;
- default:
- break;
- }
- }
-
- if (3 == state) {
- /*
- * means we fell off the end of the string looking for the
- * end of the marching rule
- */
- matchrule_size = (pos - matchrule_source) - 1;
- }
-
- if (1 == state) {
- /*
- * means we fell of the end of the string looking for the
- * end of the attribute
- */
- attrdesc_size = (pos - attrdesc_source) - 1;
- }
-
- if (NULL == attrdesc_source) {
- /* Didn't find anything */
- return (-1);
- }
-
- new_key = (LDAPsortkey*)malloc(sizeof (LDAPsortkey));
- if (0 == new_key) {
- return (LDAP_NO_MEMORY);
- }
-
- /* Allocate the strings */
- new_key->sk_attrtype = (char *)malloc(attrdesc_size + 1);
- if (NULL != matchrule_source) {
- new_key->sk_matchruleoid = (char *)malloc(matchrule_size + 1);
- } else {
- new_key->sk_matchruleoid = NULL;
- }
- /* Copy over the strings */
- memcpy(new_key->sk_attrtype, attrdesc_source, attrdesc_size);
- *(new_key->sk_attrtype + attrdesc_size) = '\0';
- if (NULL != matchrule_source) {
- memcpy(new_key->sk_matchruleoid, matchrule_source,
- matchrule_size);
- *(new_key->sk_matchruleoid + matchrule_size) = '\0';
- }
-
- new_key->sk_reverseorder = reverse;
-
- *s = pos - 1;
- *key = new_key;
- return (retval);
-}
-
-
-int
-ldap_create_sort_keylist(LDAPsortkey ***sortKeyList, char *string_rep)
-{
- int count = 0;
- LDAPsortkey **pointer_array = NULL;
- char *current_position = NULL;
- char *s = NULL;
- int retval = 0;
- int i = 0;
-
- /* Figure out how many there are */
- if (NULL == string_rep) {
- return (LDAP_PARAM_ERROR);
- }
- if (NULL == sortKeyList) {
- return (LDAP_PARAM_ERROR);
- }
- count = count_tokens(string_rep);
- if (0 == count) {
- *sortKeyList = NULL;
- return (LDAP_PARAM_ERROR);
- }
- /* Allocate enough memory for the pointers */
- pointer_array = (LDAPsortkey**)malloc(sizeof (LDAPsortkey*)
- * (count + 1));
- if (NULL == pointer_array) {
- return (LDAP_NO_MEMORY);
- }
- /*
- * Now walk along the string, allocating and filling in the
- * LDAPsearchkey structure
- */
- current_position = string_rep;
-
- for (i = 0; i < count; i++) {
- if (0 != (retval = read_next_token(&current_position,
- &(pointer_array[i])))) {
- pointer_array[count] = NULL;
- ldap_free_sort_keylist(pointer_array);
- *sortKeyList = NULL;
- return (retval);
- }
- }
- pointer_array[count] = NULL;
- *sortKeyList = pointer_array;
- return (LDAP_SUCCESS);
-}
-
-
-void
-ldap_free_sort_keylist(LDAPsortkey **sortKeyList)
-{
- LDAPsortkey *this_one = NULL;
- int i = 0;
-
- if (NULL == sortKeyList) {
- return;
- }
-
- /* Walk down the list freeing the LDAPsortkey structures */
- for (this_one = sortKeyList[0]; this_one;
- this_one = sortKeyList[++i]) {
- /* Free the strings, if present */
- if (NULL != this_one->sk_attrtype) {
- free(this_one->sk_attrtype);
- }
- if (NULL != this_one->sk_matchruleoid) {
- free(this_one->sk_matchruleoid);
- }
- free(this_one);
- }
- /* Free the pointer list */
- free(sortKeyList);
-}
diff --git a/usr/src/lib/libldap4/common/srchpref.c b/usr/src/lib/libldap4/common/srchpref.c
deleted file mode 100644
index c8a5f3d205..0000000000
--- a/usr/src/lib/libldap4/common/srchpref.c
+++ /dev/null
@@ -1,430 +0,0 @@
-/*
- *
- * Portions Copyright 1998 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- *
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*
- * Copyright (c) 1993, 1994 Regents of the University of Michigan.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms are permitted
- * provided that this notice is preserved and that due credit is given
- * to the University of Michigan at Ann Arbor. The name of the University
- * may not be used to endorse or promote products derived from this
- * software without specific prior written permission. This software
- * is provided ``as is'' without express or implied warranty.
- *
- * searchpref.c: search preferences library routines for LDAP clients
- * 17 May 1994 by Gordon Good
- */
-
-#include <stdio.h>
-#include <ctype.h>
-#include <string.h>
-#include <stdlib.h>
-#ifdef MACOS
-#include "macos.h"
-#else /* MACOS */
-#ifdef DOS
-#include <malloc.h>
-#include "msdos.h"
-#else /* DOS */
-#include <sys/types.h>
-#include <sys/file.h>
-#ifndef VMS
-#include <unistd.h>
-#endif /* VMS */
-#endif /* DOS */
-#endif /* MACOS */
-
-#include "lber.h"
-#include "ldap.h"
-#include "ldap-private.h"
-
-#ifndef NEEDPROTOS
-int next_line_tokens();
-void free_strarray();
-static void free_searchobj();
-static int read_next_searchobj();
-#else /* !NEEDPROTOS */
-int next_line_tokens( char **bufp, ssize_t *blenp, char ***toksp );
-void free_strarray( char **sap );
-static void free_searchobj( struct ldap_searchobj *so );
-static int read_next_searchobj( char **bufp, ssize_t *blenp,
- struct ldap_searchobj **sop, int soversion );
-#endif /* !NEEDPROTOS */
-
-
-static char *sobjoptions[] = {
- "internal",
- NULL
-};
-
-
-static unsigned int sobjoptvals[] = {
- LDAP_SEARCHOBJ_OPT_INTERNAL,
-};
-
-
-int
-ldap_init_searchprefs( char *file, struct ldap_searchobj **solistp )
-{
- FILE *fp;
- char *buf;
- ssize_t rlen, len;
- int rc, eof;
-
- if (( fp = fopen( file, "r" )) == NULL ) {
- return( LDAP_SEARCHPREF_ERR_FILE );
- }
-
- if ( fseek( fp, 0L, SEEK_END ) != 0 ) { /* move to end to get len */
- fclose( fp );
- return( LDAP_SEARCHPREF_ERR_FILE );
- }
-
- len = ftell( fp );
-
- if ( fseek( fp, 0L, SEEK_SET ) != 0 ) { /* back to start of file */
- fclose( fp );
- return( LDAP_SEARCHPREF_ERR_FILE );
- }
-
- if (( buf = malloc( (size_t)len )) == NULL ) {
- fclose( fp );
- return( LDAP_SEARCHPREF_ERR_MEM );
- }
-
- rlen = fread( buf, (size_t) 1, (size_t)len, fp );
- eof = feof( fp );
- fclose( fp );
-
- if ( rlen != len && !eof ) { /* error: didn't get the whole file */
- free( buf );
- return( LDAP_SEARCHPREF_ERR_FILE );
- }
-
- rc = ldap_init_searchprefs_buf( buf, rlen, solistp );
- free( buf );
-
- return( rc );
-}
-
-
-int
-ldap_init_searchprefs_buf( char *buf, ssize_t buflen,
- struct ldap_searchobj **solistp )
-{
- int rc, version;
- char **toks;
- struct ldap_searchobj *prevso, *so;
-
- *solistp = prevso = NULLSEARCHOBJ;
-
- if ( next_line_tokens( &buf, &buflen, &toks ) != 2 ||
- strcasecmp( toks[ 0 ], "version" ) != 0 ) {
- free_strarray( toks );
- return( LDAP_SEARCHPREF_ERR_SYNTAX );
- }
- version = atoi( toks[ 1 ] );
- free_strarray( toks );
- if ( version != LDAP_SEARCHPREF_VERSION &&
- version != LDAP_SEARCHPREF_VERSION_ZERO ) {
- return( LDAP_SEARCHPREF_ERR_VERSION );
- }
-
- while ( buflen > 0 && ( rc = read_next_searchobj( &buf, &buflen, &so,
- version )) == 0 && so != NULLSEARCHOBJ ) {
- if ( prevso == NULLSEARCHOBJ ) {
- *solistp = so;
- } else {
- prevso->so_next = so;
- }
- prevso = so;
- }
-
- if ( rc != 0 ) {
- ldap_free_searchprefs( *solistp );
- }
-
- return( rc );
-}
-
-
-
-void
-ldap_free_searchprefs( struct ldap_searchobj *solist )
-{
- struct ldap_searchobj *so, *nextso;
-
- if ( solist != NULL ) {
- for ( so = solist; so != NULL; so = nextso ) {
- nextso = so->so_next;
- free_searchobj( so );
- }
- }
- /* XXX XXX need to do some work here */
-}
-
-
-static void
-free_searchobj( struct ldap_searchobj *so )
-{
- if ( so != NULL ) {
- if ( so->so_objtypeprompt != NULL ) {
- free( so->so_objtypeprompt );
- }
- if ( so->so_prompt != NULL ) {
- free( so->so_prompt );
- }
- if ( so->so_filterprefix != NULL ) {
- free( so->so_filterprefix );
- }
- if ( so->so_filtertag != NULL ) {
- free( so->so_filtertag );
- }
- if ( so->so_defaultselectattr != NULL ) {
- free( so->so_defaultselectattr );
- }
- if ( so->so_defaultselecttext != NULL ) {
- free( so->so_defaultselecttext );
- }
- if ( so->so_salist != NULL ) {
- struct ldap_searchattr *sa, *nextsa;
- for ( sa = so->so_salist; sa != NULL; sa = nextsa ) {
- nextsa = sa->sa_next;
- if ( sa->sa_attrlabel != NULL ) {
- free( sa->sa_attrlabel );
- }
- if ( sa->sa_attr != NULL ) {
- free( sa->sa_attr );
- }
- if ( sa->sa_selectattr != NULL ) {
- free( sa->sa_selectattr );
- }
- if ( sa->sa_selecttext != NULL ) {
- free( sa->sa_selecttext );
- }
- free( sa );
- }
- }
- if ( so->so_smlist != NULL ) {
- struct ldap_searchmatch *sm, *nextsm;
- for ( sm = so->so_smlist; sm != NULL; sm = nextsm ) {
- nextsm = sm->sm_next;
- if ( sm->sm_matchprompt != NULL ) {
- free( sm->sm_matchprompt );
- }
- if ( sm->sm_filter != NULL ) {
- free( sm->sm_filter );
- }
- free( sm );
- }
- }
- free( so );
- }
-}
-
-
-
-struct ldap_searchobj *
-ldap_first_searchobj( struct ldap_searchobj *solist )
-{
- return( solist );
-}
-
-
-struct ldap_searchobj *
-ldap_next_searchobj( struct ldap_searchobj *solist, struct ldap_searchobj *so )
-{
- return( so == NULLSEARCHOBJ ? so : so->so_next );
-}
-
-
-
-static int
-read_next_searchobj( char **bufp, ssize_t *blenp, struct ldap_searchobj **sop,
- int soversion )
-{
- int i, j, tokcnt;
- char **toks;
- struct ldap_searchobj *so;
- struct ldap_searchattr **sa;
- struct ldap_searchmatch **sm;
-
- *sop = NULL;
-
- /*
- * Object type prompt comes first
- */
- if (( tokcnt = next_line_tokens( bufp, blenp, &toks )) != 1 ) {
- free_strarray( toks );
- return( tokcnt == 0 ? 0 : LDAP_SEARCHPREF_ERR_SYNTAX );
- }
-
- if (( so = (struct ldap_searchobj *)calloc( (size_t) 1,
- sizeof( struct ldap_searchobj ))) == NULL ) {
- free_strarray( toks );
- return( LDAP_SEARCHPREF_ERR_MEM );
- }
- so->so_objtypeprompt = toks[ 0 ];
- free( (char *)toks );
-
- /*
- * if this is post-version zero, options come next
- */
- if ( soversion > LDAP_SEARCHPREF_VERSION_ZERO ) {
- if (( tokcnt = next_line_tokens( bufp, blenp, &toks )) < 1 ) {
- free_strarray( toks );
- ldap_free_searchprefs( so );
- return( LDAP_SEARCHPREF_ERR_SYNTAX );
- }
- for ( i = 0; toks[ i ] != NULL; ++i ) {
- for ( j = 0; sobjoptions[ j ] != NULL; ++j ) {
- if ( strcasecmp( toks[ i ], sobjoptions[ j ] ) == 0 ) {
- so->so_options |= sobjoptvals[ j ];
- }
- }
- }
- free_strarray( toks );
- }
-
- /*
- * "Fewer choices" prompt is next
- */
- if (( tokcnt = next_line_tokens( bufp, blenp, &toks )) != 1 ) {
- free_strarray( toks );
- ldap_free_searchprefs( so );
- return( LDAP_SEARCHPREF_ERR_SYNTAX );
- }
- so->so_prompt = toks[ 0 ];
- free( (char *)toks );
-
- /*
- * Filter prefix for "More Choices" searching is next
- */
- if (( tokcnt = next_line_tokens( bufp, blenp, &toks )) != 1 ) {
- free_strarray( toks );
- ldap_free_searchprefs( so );
- return( LDAP_SEARCHPREF_ERR_SYNTAX );
- }
- so->so_filterprefix = toks[ 0 ];
- free( (char *)toks );
-
- /*
- * "Fewer Choices" filter tag comes next
- */
- if (( tokcnt = next_line_tokens( bufp, blenp, &toks )) != 1 ) {
- free_strarray( toks );
- ldap_free_searchprefs( so );
- return( LDAP_SEARCHPREF_ERR_SYNTAX );
- }
- so->so_filtertag = toks[ 0 ];
- free( (char *)toks );
-
- /*
- * Selection (disambiguation) attribute comes next
- */
- if (( tokcnt = next_line_tokens( bufp, blenp, &toks )) != 1 ) {
- free_strarray( toks );
- ldap_free_searchprefs( so );
- return( LDAP_SEARCHPREF_ERR_SYNTAX );
- }
- so->so_defaultselectattr = toks[ 0 ];
- free( (char *)toks );
-
- /*
- * Label for selection (disambiguation) attribute
- */
- if (( tokcnt = next_line_tokens( bufp, blenp, &toks )) != 1 ) {
- free_strarray( toks );
- ldap_free_searchprefs( so );
- return( LDAP_SEARCHPREF_ERR_SYNTAX );
- }
- so->so_defaultselecttext = toks[ 0 ];
- free( (char *)toks );
-
- /*
- * Search scope is next
- */
- if (( tokcnt = next_line_tokens( bufp, blenp, &toks )) != 1 ) {
- free_strarray( toks );
- ldap_free_searchprefs( so );
- return( LDAP_SEARCHPREF_ERR_SYNTAX );
- }
- if ( !strcasecmp(toks[ 0 ], "subtree" )) {
- so->so_defaultscope = LDAP_SCOPE_SUBTREE;
- } else if ( !strcasecmp(toks[ 0 ], "onelevel" )) {
- so->so_defaultscope = LDAP_SCOPE_ONELEVEL;
- } else if ( !strcasecmp(toks[ 0 ], "base" )) {
- so->so_defaultscope = LDAP_SCOPE_BASE;
- } else {
- ldap_free_searchprefs( so );
- return( LDAP_SEARCHPREF_ERR_SYNTAX );
- }
- free_strarray( toks );
-
-
- /*
- * "More Choices" search option list comes next
- */
- sa = &( so->so_salist );
- while (( tokcnt = next_line_tokens( bufp, blenp, &toks )) > 0 ) {
- if ( tokcnt < 5 ) {
- free_strarray( toks );
- ldap_free_searchprefs( so );
- return( LDAP_SEARCHPREF_ERR_SYNTAX );
- }
- if (( *sa = ( struct ldap_searchattr * ) calloc( (size_t) 1,
- sizeof( struct ldap_searchattr ))) == NULL ) {
- free_strarray( toks );
- ldap_free_searchprefs( so );
- return( LDAP_SEARCHPREF_ERR_MEM );
- }
- ( *sa )->sa_attrlabel = toks[ 0 ];
- ( *sa )->sa_attr = toks[ 1 ];
- ( *sa )->sa_selectattr = toks[ 3 ];
- ( *sa )->sa_selecttext = toks[ 4 ];
- /* Deal with bitmap */
- ( *sa )->sa_matchtypebitmap = 0;
- for ( i = (int) strlen( toks[ 2 ] ) - 1, j = 0; i >= 0; i--, j++ ) {
- if ( toks[ 2 ][ i ] == '1' ) {
- ( *sa )->sa_matchtypebitmap |= (1 << j);
- }
- }
- free( toks[ 2 ] );
- free( ( char * ) toks );
- sa = &(( *sa )->sa_next);
- }
- *sa = NULL;
-
- /*
- * Match types are last
- */
- sm = &( so->so_smlist );
- while (( tokcnt = next_line_tokens( bufp, blenp, &toks )) > 0 ) {
- if ( tokcnt < 2 ) {
- free_strarray( toks );
- ldap_free_searchprefs( so );
- return( LDAP_SEARCHPREF_ERR_SYNTAX );
- }
- if (( *sm = ( struct ldap_searchmatch * ) calloc( (size_t) 1,
- sizeof( struct ldap_searchmatch ))) == NULL ) {
- free_strarray( toks );
- ldap_free_searchprefs( so );
- return( LDAP_SEARCHPREF_ERR_MEM );
- }
- ( *sm )->sm_matchprompt = toks[ 0 ];
- ( *sm )->sm_filter = toks[ 1 ];
- free( ( char * ) toks );
- sm = &(( *sm )->sm_next );
- }
- *sm = NULL;
-
- *sop = so;
- return( 0 );
-}
diff --git a/usr/src/lib/libldap4/common/tmplout.c b/usr/src/lib/libldap4/common/tmplout.c
deleted file mode 100644
index a887efa705..0000000000
--- a/usr/src/lib/libldap4/common/tmplout.c
+++ /dev/null
@@ -1,1176 +0,0 @@
-/*
- * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*
- * tmplout.c: display template library output routines for LDAP clients
- * 12 April 1994 by Mark C Smith
- */
-
-#include <stdio.h>
-#include <string.h>
-#include <ctype.h>
-#include <time.h>
-#include <tzfile.h>
-#include <stdlib.h>
-#ifdef MACOS
-#include "macos.h"
-#else /* MACOS */
-#ifdef DOS
-#include <malloc.h>
-#include "msdos.h"
-#else /* DOS */
-#include <sys/time.h>
-#include <sys/types.h>
-#include <sys/file.h>
-#endif /* DOS */
-#endif /* MACOS */
-
-#ifdef VMS
-#include <sys/socket.h>
-#endif /* VMS */
-
-#include "lber.h"
-#include "ldap.h"
-#include "ldap-private.h"
-#include "ldap-int.h"
-#ifdef SUN
-/*
- * to include definition of FILTERFILE and or TEMPLATEFILE
- */
-#include "ldapconfig.h"
-#endif
-
-#ifdef NEEDPROTOS
-static int do_entry2text( LDAP *ld, char *buf, char *base, LDAPMessage *entry,
- struct ldap_disptmpl *tmpl, char **defattrs, char ***defvals,
- writeptype writeproc, void *writeparm, char *eol, int rdncount,
- unsigned int opts, char *urlprefix );
-static int do_entry2text_search( LDAP *ld, char *dn, char *base,
- LDAPMessage *entry, struct ldap_disptmpl *tmpllist, char **defattrs,
- char ***defvals, writeptype writeproc, void *writeparm, char *eol,
- int rdncount, unsigned int opts, char *urlprefix );
-static int do_vals2text( LDAP *ld, char *buf, char **vals, char *label,
- int labelwidth, unsigned int syntaxid, writeptype writeproc,
- void *writeparm, char *eol, int rdncount, char *urlprefix );
-static int max_label_len( struct ldap_disptmpl *tmpl );
-static int output_label( char *buf, char *label, int width,
- writeptype writeproc, void *writeparm, char *eol, int html );
-static int output_dn( char *buf, char *dn, int width, int rdncount,
- writeptype writeproc, void *writeparm, char *eol, char *urlprefix );
-static void strcat_escaped( char *s1, char *s2 );
-static char *time2text( char *ldtimestr, int dateonly );
-static time_t gtime( struct tm *tm );
-static int searchaction( LDAP *ld, char *buf, char *base, LDAPMessage *entry,
- char *dn, struct ldap_tmplitem *tip, int labelwidth, int rdncount,
- writeptype writeproc, void *writeparm, char *eol, char *urlprefix );
-#else /* NEEDPROTOS */
-static int do_entry2text();
-static int do_entry2text_search();
-static int do_vals2text();
-static int max_label_len();
-static int output_label();
-static int output_dn();
-static void strcat_escaped();
-static char *time2text();
-static time_t gtime();
-static int searchaction();
-#endif /* NEEDPROTOS */
-
-#define DEF_LABEL_WIDTH 15
-#define SEARCH_TIMEOUT_SECS 120
-#define OCATTRNAME "objectClass"
-
-
-#define NONFATAL_LDAP_ERR( err ) ( err == LDAP_SUCCESS || \
- err == LDAP_TIMELIMIT_EXCEEDED || err == LDAP_SIZELIMIT_EXCEEDED )
-
-#define DEF_LDAP_URL_PREFIX "ldap:///"
-
-
-int
-ldap_entry2text(
- LDAP *ld,
- char *buf, /* NULL for "use internal" */
- LDAPMessage *entry,
- struct ldap_disptmpl *tmpl,
- char **defattrs,
- char ***defvals,
- writeptype writeproc,
- void *writeparm,
- char *eol,
- int rdncount,
- unsigned int opts
-)
-{
-#if defined( SUN ) && defined( _REENTRANT )
- int rv;
-
- LOCK_LDAP(ld);
-#endif
- Debug( LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 253, "ldap_entry2text\n"), 0, 0, 0 );
-
-#if defined( SUN ) && defined( _REENTRANT )
- rv = do_entry2text( ld, buf, NULL, entry, tmpl, defattrs, defvals,
- writeproc, writeparm, eol, rdncount, opts, NULL );
- UNLOCK_LDAP(ld);
- return( rv );
-#else
- return( do_entry2text( ld, buf, NULL, entry, tmpl, defattrs, defvals,
- writeproc, writeparm, eol, rdncount, opts, NULL ));
-#endif
-}
-
-
-
-int
-ldap_entry2html(
- LDAP *ld,
- char *buf, /* NULL for "use internal" */
- LDAPMessage *entry,
- struct ldap_disptmpl *tmpl,
- char **defattrs,
- char ***defvals,
- writeptype writeproc,
- void *writeparm,
- char *eol,
- int rdncount,
- unsigned int opts,
- char *base,
- char *urlprefix
-)
-{
-#if defined( SUN ) && defined( _REENTRANT )
- int rv;
-
- LOCK_LDAP(ld);
-#endif
- Debug( LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 254, "ldap_entry2html\n"), 0, 0, 0 );
-
- if ( urlprefix == NULL ) {
- urlprefix = DEF_LDAP_URL_PREFIX;
- }
-
-#if defined( SUN ) && defined( _REENTRANT )
- rv = do_entry2text( ld, buf, base, entry, tmpl, defattrs, defvals,
- writeproc, writeparm, eol, rdncount, opts, urlprefix );
- UNLOCK_LDAP(ld);
- return( rv );
-#else
- return( do_entry2text( ld, buf, base, entry, tmpl, defattrs, defvals,
- writeproc, writeparm, eol, rdncount, opts, urlprefix ));
-#endif
-}
-
-
-static int
-do_entry2text(
- LDAP *ld,
- char *buf, /* NULL for use-internal */
- char *base, /* used for search actions */
- LDAPMessage *entry,
- struct ldap_disptmpl *tmpl,
- char **defattrs,
- char ***defvals,
- writeptype writeproc,
- void *writeparm,
- char *eol,
- int rdncount,
- unsigned int opts,
- char *urlprefix /* if non-NULL, do HTML */
-)
-{
- int i, err, html, show, labelwidth;
- int freebuf, freevals;
- char *dn, **vals;
- struct ldap_tmplitem *rowp, *colp;
-
- if (( dn = ldap_get_dn( ld, entry )) == NULL ) {
- return( ld->ld_errno );
- }
-
- if ( buf == NULL ) {
- if (( buf = malloc( LDAP_DTMPL_BUFSIZ )) == NULL ) {
- ld->ld_errno = LDAP_NO_MEMORY;
- free( dn );
- return( ld->ld_errno );
- }
- freebuf = 1;
- } else {
- freebuf = 0;
- }
-
- html = ( urlprefix != NULL );
-
- if ( html ) {
- /*
- * add HTML intro. and title
- */
- if (!(( opts & LDAP_DISP_OPT_HTMLBODYONLY ) != 0 )) {
- sprintf( buf, "<HTML>%s<HEAD>%s<TITLE>%s%s - ", eol, eol, eol,
- ( tmpl == NULL ) ? "Entry" : tmpl->dt_name );
- (*writeproc)( writeparm, buf, strlen( buf ));
- output_dn( buf, dn, 0, rdncount, writeproc, writeparm, "", NULL );
- sprintf( buf, "%s</TITLE>%s</HEAD>%s<BODY>%s<H3>%s - ", eol, eol,
- eol, eol, ( tmpl == NULL ) ? "Entry" : tmpl->dt_name );
- (*writeproc)( writeparm, buf, strlen( buf ));
- output_dn( buf, dn, 0, rdncount, writeproc, writeparm, "", NULL );
- sprintf( buf, "</H3>%s", eol );
- (*writeproc)( writeparm, buf, strlen( buf ));
- }
-
- if (( opts & LDAP_DISP_OPT_NONLEAF ) != 0 &&
- ( vals = ldap_explode_dn( dn, 0 )) != NULL ) {
- char *untagged;
-
- /*
- * add "Move Up" link
- */
- sprintf( buf, "<A HREF=\"%s", urlprefix );
- for ( i = 1; vals[ i ] != NULL; ++i ) {
- if ( i > 1 ) {
- strcat_escaped( buf, ", " );
- }
- strcat_escaped( buf, vals[ i ] );
- }
- if ( vals[ 1 ] != NULL ) {
- untagged = strchr( vals[ 1 ], '=' );
- } else {
- untagged = "=The World";
- }
- sprintf( buf + strlen( buf ),
- "%s\">Move Up To <EM>%s</EM></A>%s<BR>",
- ( vals[ 1 ] == NULL ) ? "??one" : "",
- ( untagged != NULL ) ? untagged + 1 : vals[ 1 ], eol, eol );
- (*writeproc)( writeparm, buf, strlen( buf ));
-
- /*
- * add "Browse" link
- */
- untagged = strchr( vals[ 0 ], '=' );
- sprintf( buf, "<A HREF=\"%s", urlprefix );
- strcat_escaped( buf, dn );
- sprintf( buf + strlen( buf ), "??one?(!(objectClass=dsa))\">Browse Below <EM>%s</EM></A>%s%s",
- ( untagged != NULL ) ? untagged + 1 : vals[ 0 ], eol, eol );
- (*writeproc)( writeparm, buf, strlen( buf ));
-
- ldap_value_free( vals );
- }
-
- (*writeproc)( writeparm, "<HR>", 4 ); /* horizontal rule */
- } else {
- (*writeproc)( writeparm, "\"", 1 );
- output_dn( buf, dn, 0, rdncount, writeproc, writeparm, "", NULL );
- sprintf( buf, "\"%s", eol );
- (*writeproc)( writeparm, buf, strlen( buf ));
- }
-
- if ( tmpl != NULL && ( opts & LDAP_DISP_OPT_AUTOLABELWIDTH ) != 0 ) {
- labelwidth = max_label_len( tmpl ) + 3;
- } else {
- labelwidth = DEF_LABEL_WIDTH;;
- }
-
- err = LDAP_SUCCESS;
-
- if ( tmpl == NULL ) {
- BerElement *ber;
- char *attr;
-
- ber = NULL;
- for ( attr = ldap_first_attribute( ld, entry, &ber );
- NONFATAL_LDAP_ERR( err ) && attr != NULL;
- attr = ldap_next_attribute( ld, entry, ber )) {
- if (( vals = ldap_get_values( ld, entry, attr )) == NULL ) {
- freevals = 0;
- if ( defattrs != NULL ) {
- for ( i = 0; defattrs[ i ] != NULL; ++i ) {
- if ( strcasecmp( attr, defattrs[ i ] ) == 0 ) {
- break;
- }
- }
- if ( defattrs[ i ] != NULL ) {
- vals = defvals[ i ];
- }
- }
- } else {
- freevals = 1;
- }
-
- if ( islower( *attr )) { /* cosmetic -- upcase attr. name */
- *attr = toupper( *attr );
- }
-
- err = do_vals2text( ld, buf, vals, attr, labelwidth,
- LDAP_SYN_CASEIGNORESTR, writeproc, writeparm, eol,
- rdncount, urlprefix );
- if ( freevals ) {
- ldap_value_free( vals );
- }
- }
- } else {
- for ( rowp = ldap_first_tmplrow( tmpl );
- NONFATAL_LDAP_ERR( err ) && rowp != NULLTMPLITEM;
- rowp = ldap_next_tmplrow( tmpl, rowp )) {
- for ( colp = ldap_first_tmplcol( tmpl, rowp ); colp != NULLTMPLITEM;
- colp = ldap_next_tmplcol( tmpl, rowp, colp )) {
- vals = NULL;
- if ( colp->ti_attrname == NULL || ( vals = ldap_get_values( ld,
- entry, colp->ti_attrname )) == NULL ) {
- freevals = 0;
- if ( !LDAP_IS_TMPLITEM_OPTION_SET( colp,
- LDAP_DITEM_OPT_HIDEIFEMPTY ) && defattrs != NULL
- && colp->ti_attrname != NULL ) {
- for ( i = 0; defattrs[ i ] != NULL; ++i ) {
- if ( strcasecmp( colp->ti_attrname, defattrs[ i ] )
- == 0 ) {
- break;
- }
- }
- if ( defattrs[ i ] != NULL ) {
- vals = defvals[ i ];
- }
- }
- } else {
- freevals = 1;
- if ( LDAP_IS_TMPLITEM_OPTION_SET( colp,
- LDAP_DITEM_OPT_SORTVALUES ) && vals[ 0 ] != NULL
- && vals[ 1 ] != NULL ) {
- ldap_sort_values( ld, vals, ldap_sort_strcasecmp );
- }
- }
-
- /*
- * don't bother even calling do_vals2text() if no values
- * or boolean with value false and "hide if false" option set
- */
- show = ( vals != NULL && vals[ 0 ] != NULL );
- if ( show && LDAP_GET_SYN_TYPE( colp->ti_syntaxid )
- == LDAP_SYN_TYPE_BOOLEAN && LDAP_IS_TMPLITEM_OPTION_SET(
- colp, LDAP_DITEM_OPT_HIDEIFFALSE ) &&
- toupper( vals[ 0 ][ 0 ] ) != 'T' ) {
- show = 0;
- }
-
- if ( colp->ti_syntaxid == LDAP_SYN_SEARCHACTION ) {
- if (( opts & LDAP_DISP_OPT_DOSEARCHACTIONS ) != 0 ) {
- if ( colp->ti_attrname == NULL || ( show &&
- toupper( vals[ 0 ][ 0 ] ) == 'T' )) {
- err = searchaction( ld, buf, base, entry, dn, colp,
- labelwidth, rdncount, writeproc,
- writeparm, eol, urlprefix );
- }
- }
- show = 0;
- }
-
- if ( show ) {
- err = do_vals2text( ld, buf, vals, colp->ti_label,
- labelwidth, colp->ti_syntaxid, writeproc, writeparm,
- eol, rdncount, urlprefix );
- }
-
- if ( freevals ) {
- ldap_value_free( vals );
- }
- }
- }
- }
-
- if ( html && !(( opts & LDAP_DISP_OPT_HTMLBODYONLY ) != 0 )) {
- sprintf( buf, "</BODY>%s</HTML>%s", eol, eol );
- (*writeproc)( writeparm, buf, strlen( buf ));
- }
-
- free( dn );
- if ( freebuf ) {
- free( buf );
- }
-
- return( err );
-}
-
-
-int
-ldap_entry2text_search(
- LDAP *ld,
- char *dn, /* if NULL, use entry */
- char *base, /* if NULL, no search actions */
- LDAPMessage *entry, /* if NULL, use dn */
- struct ldap_disptmpl* tmpllist, /* if NULL, load default file */
- char **defattrs,
- char ***defvals,
- writeptype writeproc,
- void *writeparm,
- char *eol,
- int rdncount, /* if 0, display full DN */
- unsigned int opts
-)
-{
-#if defined( SUN ) && defined( _REENTRANT )
- int rv;
-
- LOCK_LDAP(ld);
-#endif
- Debug( LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 255, "ldap_entry2text_search\n"), 0, 0, 0 );
-
-#if defined( SUN ) && defined( _REENTRANT )
- rv = do_entry2text_search( ld, dn, base, entry, tmpllist, defattrs,
- defvals, writeproc, writeparm, eol, rdncount, opts, NULL );
- UNLOCK_LDAP(ld);
- return( rv );
-#else
- return( do_entry2text_search( ld, dn, base, entry, tmpllist, defattrs,
- defvals, writeproc, writeparm, eol, rdncount, opts, NULL ));
-#endif
-}
-
-
-
-int
-ldap_entry2html_search(
- LDAP *ld,
- char *dn, /* if NULL, use entry */
- char *base, /* if NULL, no search actions */
- LDAPMessage *entry, /* if NULL, use dn */
- struct ldap_disptmpl* tmpllist, /* if NULL, load default file */
- char **defattrs,
- char ***defvals,
- writeptype writeproc,
- void *writeparm,
- char *eol,
- int rdncount, /* if 0, display full DN */
- unsigned int opts,
- char *urlprefix
-)
-{
-#if defined( SUN ) && defined( _REENTRANT )
- int rv;
-
- LOCK_LDAP(ld);
-#endif
- Debug( LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 256, "ldap_entry2html_search\n"), 0, 0, 0 );
-
-#if defined( SUN ) && defined( _REENTRANT )
- rv = do_entry2text_search( ld, dn, base, entry, tmpllist, defattrs,
- defvals, writeproc, writeparm, eol, rdncount, opts, urlprefix );
- UNLOCK_LDAP(ld);
- return( rv );
-#else
- return( do_entry2text_search( ld, dn, base, entry, tmpllist, defattrs,
- defvals, writeproc, writeparm, eol, rdncount, opts, urlprefix ));
-#endif
-}
-
-
-static int
-do_entry2text_search(
- LDAP *ld,
- char *dn, /* if NULL, use entry */
- char *base, /* if NULL, no search actions */
- LDAPMessage *entry, /* if NULL, use dn */
- struct ldap_disptmpl* tmpllist, /* if NULL, load default file */
- char **defattrs,
- char ***defvals,
- writeptype writeproc,
- void *writeparm,
- char *eol,
- int rdncount, /* if 0, display full DN */
- unsigned int opts,
- char *urlprefix
-)
-{
- int err, freedn, freetmpls, html;
- char *buf, **fetchattrs, **vals;
- LDAPMessage *ldmp;
- struct ldap_disptmpl *tmpl;
- struct timeval timeout;
-
- if ( dn == NULL && entry == NULLMSG ) {
- ld->ld_errno = LDAP_PARAM_ERROR;
- return( ld->ld_errno );
- }
-
- html = ( urlprefix != NULL );
-
- timeout.tv_sec = SEARCH_TIMEOUT_SECS;
- timeout.tv_usec = 0;
-
- if (( buf = malloc( LDAP_DTMPL_BUFSIZ )) == NULL ) {
- ld->ld_errno = LDAP_NO_MEMORY;
- return( ld->ld_errno );
- }
-
- freedn = freetmpls = 0;
- tmpl = NULL;
-
- if ( tmpllist == NULL ) {
- if (( err = ldap_init_templates( TEMPLATEFILE, &tmpllist )) != 0 ) {
- sprintf( buf, "%sUnable to read template file %s (error %d)%s%s",
- html ? "<!-- " : "", TEMPLATEFILE, err,
- html ? "-->" : "", eol );
- (*writeproc)( writeparm, buf, strlen( buf ));
- }
- freetmpls = 1;
- }
-
- if ( dn == NULL ) {
- if (( dn = ldap_get_dn( ld, entry )) == NULL ) {
- free( buf );
- if ( freetmpls ) {
- ldap_free_templates( tmpllist );
- }
- return( ld->ld_errno );
- }
- freedn = 1;
- }
-
-
- if ( tmpllist != NULL ) {
- ldmp = NULLMSG;
-
- if ( entry == NULL ) {
- char *ocattrs[2];
-
- ocattrs[0] = OCATTRNAME;
- ocattrs[1] = NULL;
-#ifdef CLDAP
- if ( LDAP_IS_CLDAP( ld ))
- err = cldap_search_s( ld, dn, LDAP_SCOPE_BASE,
- "objectClass=*", ocattrs, 0, &ldmp, NULL );
- else
-#endif /* CLDAP */
- err = ldap_search_st( ld, dn, LDAP_SCOPE_BASE,
- "objectClass=*", ocattrs, 0, &timeout, &ldmp );
-
- if ( err == LDAP_SUCCESS ) {
- entry = ldap_first_entry( ld, ldmp );
- }
- }
-
- if ( entry != NULL ) {
- vals = ldap_get_values( ld, entry, OCATTRNAME );
- tmpl = ldap_oc2template( vals, tmpllist );
- if ( vals != NULL ) {
- ldap_value_free( vals );
- }
- }
- if ( ldmp != NULL ) {
- ldap_msgfree( ldmp );
- }
- }
-
- entry = NULL;
-
- if ( tmpl == NULL ) {
- fetchattrs = NULL;
- } else {
- fetchattrs = ldap_tmplattrs( tmpl, NULL, 1, LDAP_SYN_OPT_DEFER );
- }
-
-#ifdef CLDAP
- if ( LDAP_IS_CLDAP( ld ))
- err = cldap_search_s( ld, dn, LDAP_SCOPE_BASE, "objectClass=*",
- fetchattrs, 0, &ldmp, NULL );
- else
-#endif /* CLDAP */
- err = ldap_search_st( ld, dn, LDAP_SCOPE_BASE, "objectClass=*",
- fetchattrs, 0, &timeout, &ldmp );
-
- if ( freedn ) {
- free( dn );
- }
- if ( fetchattrs != NULL ) {
- ldap_value_free( fetchattrs );
- }
-
- if ( err != LDAP_SUCCESS ||
- ( entry = ldap_first_entry( ld, ldmp )) == NULL ) {
- if ( freetmpls ) {
- ldap_free_templates( tmpllist );
- }
- free( buf );
- return( ld->ld_errno );
- }
-
- err = do_entry2text( ld, buf, base, entry, tmpl, defattrs, defvals,
- writeproc, writeparm, eol, rdncount, opts, urlprefix );
-
- free( buf );
- if ( freetmpls ) {
- ldap_free_templates( tmpllist );
- }
- ldap_msgfree( ldmp );
- return( err );
-}
-
-
-int
-ldap_vals2text(
- LDAP *ld,
- char *buf, /* NULL for "use internal" */
- char **vals,
- char *label,
- int labelwidth, /* 0 means use default */
- unsigned int syntaxid,
- writeptype writeproc,
- void *writeparm,
- char *eol,
- int rdncount
-)
-{
-#if defined( SUN ) && defined( _REENTRANT )
- int rv;
-
- LOCK_LDAP(ld);
-#endif
- Debug( LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 257, "ldap_vals2text\n"), 0, 0, 0 );
-
-#if defined( SUN ) && defined( _REENTRANT )
- rv = do_vals2text( ld, buf, vals, label, labelwidth, syntaxid,
- writeproc, writeparm, eol, rdncount, NULL );
- UNLOCK_LDAP(ld);
- return( rv );
-#else
- return( do_vals2text( ld, buf, vals, label, labelwidth, syntaxid,
- writeproc, writeparm, eol, rdncount, NULL ));
-#endif
-}
-
-
-int
-ldap_vals2html(
- LDAP *ld,
- char *buf, /* NULL for "use internal" */
- char **vals,
- char *label,
- int labelwidth, /* 0 means use default */
- unsigned int syntaxid,
- writeptype writeproc,
- void *writeparm,
- char *eol,
- int rdncount,
- char *urlprefix
-)
-{
-#if defined( SUN ) && defined( _REENTRANT )
- int rv;
-
- LOCK_LDAP(ld);
-#endif
- Debug( LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 258, "ldap_vals2html\n"), 0, 0, 0 );
-
- if ( urlprefix == NULL ) {
- urlprefix = DEF_LDAP_URL_PREFIX;
- }
-
-#if defined( SUN ) && defined( _REENTRANT )
- rv = do_vals2text( ld, buf, vals, label, labelwidth, syntaxid,
- writeproc, writeparm, eol, rdncount, urlprefix );
- UNLOCK_LDAP(ld);
- return( rv );
-#else
- return( do_vals2text( ld, buf, vals, label, labelwidth, syntaxid,
- writeproc, writeparm, eol, rdncount, urlprefix ));
-#endif
-}
-
-
-static int
-do_vals2text(
- LDAP *ld,
- char *buf, /* NULL for "use internal" */
- char **vals,
- char *label,
- int labelwidth, /* 0 means use default */
- unsigned int syntaxid,
- writeptype writeproc,
- void *writeparm,
- char *eol,
- int rdncount,
- char *urlprefix
-)
-{
- int i, html, writeoutval, freebuf, notascii;
- char *p, *s, *outval;
-
-
- if ( vals == NULL ) {
- return( LDAP_SUCCESS );
- }
-
- html = ( urlprefix != NULL );
-
- switch( LDAP_GET_SYN_TYPE( syntaxid )) {
- case LDAP_SYN_TYPE_TEXT:
- case LDAP_SYN_TYPE_BOOLEAN:
- break; /* we only bother with these two types... */
- default:
- return( LDAP_SUCCESS );
- }
-
- if ( labelwidth == 0 || labelwidth < 0 ) {
- labelwidth = DEF_LABEL_WIDTH;
- }
-
- if ( buf == NULL ) {
- if (( buf = malloc( LDAP_DTMPL_BUFSIZ )) == NULL ) {
- ld->ld_errno = LDAP_NO_MEMORY;
- return( ld->ld_errno );
- }
- freebuf = 1;
- } else {
- freebuf = 0;
- }
-
- output_label( buf, label, labelwidth, writeproc, writeparm, eol, html );
-
- for ( i = 0; vals[ i ] != NULL; ++i ) {
- for ( p = vals[ i ]; *p != '\0'; ++p ) {
- if ( !isascii( *p )) {
- break;
- }
- }
- notascii = ( *p != '\0' );
- outval = notascii ? "(unable to display non-ASCII text value)"
- : vals[ i ];
-
- writeoutval = 0; /* if non-zero, write outval after switch */
-
- switch( syntaxid ) {
- case LDAP_SYN_CASEIGNORESTR:
- ++writeoutval;
- break;
-
- case LDAP_SYN_RFC822ADDR:
- if ( html ) {
- strcpy( buf, "<DD><A HREF=\"mailto:" );
- strcat_escaped( buf, outval );
- sprintf( buf + strlen( buf ), "\">%s</A><BR>%s", outval, eol );
- (*writeproc)( writeparm, buf, strlen( buf ));
- } else {
- ++writeoutval;
- }
- break;
-
- case LDAP_SYN_DN: /* for now */
- output_dn( buf, outval, labelwidth, rdncount, writeproc,
- writeparm, eol, urlprefix );
- break;
-
- case LDAP_SYN_MULTILINESTR:
- if ( i > 0 && !html ) {
- output_label( buf, label, labelwidth, writeproc,
- writeparm, eol, html );
- }
-
- p = s = outval;
- while (( s = strchr( s, '$' )) != NULL ) {
- *s++ = '\0';
- while ( isspace( *s )) {
- ++s;
- }
- if ( html ) {
- sprintf( buf, "<DD>%s<BR>%s", p, eol );
- } else {
- sprintf( buf, "%-*s%s%s", labelwidth, " ", p, eol );
- }
- (*writeproc)( writeparm, buf, strlen( buf ));
- p = s;
- }
- outval = p;
- ++writeoutval;
- break;
-
- case LDAP_SYN_BOOLEAN:
- outval = toupper( outval[ 0 ] ) == 'T' ? "TRUE" : "FALSE";
- ++writeoutval;
- break;
-
- case LDAP_SYN_TIME:
- case LDAP_SYN_DATE:
- outval = time2text( outval, syntaxid == LDAP_SYN_DATE );
- ++writeoutval;
- break;
-
- case LDAP_SYN_LABELEDURL:
- if ( !notascii && ( p = strchr( outval, '$' )) != NULL ) {
- *p++ = '\0';
- while ( isspace( *p )) {
- ++p;
- }
- s = outval;
- } else if ( !notascii && ( s = strchr( outval, ' ' )) != NULL ) {
- *s++ = '\0';
- while ( isspace( *s )) {
- ++s;
- }
- p = outval;
- } else {
- s = "URL";
- p = outval;
- }
-
- /*
- * at this point `s' points to the label & `p' to the URL
- */
- if ( html ) {
- sprintf( buf, "<DD><A HREF=\"%s\">%s</A><BR>%s", p, s, eol );
- } else {
- sprintf( buf, "%-*s%s%s%-*s%s%s", labelwidth, " ",
- s, eol, labelwidth + 2, " ",p , eol );
- }
- (*writeproc)( writeparm, buf, strlen( buf ));
- break;
-
- default:
- sprintf( buf, " Can't display item type %ld%s",
- syntaxid, eol );
- (*writeproc)( writeparm, buf, strlen( buf ));
- }
-
- if ( writeoutval ) {
- if ( html ) {
- sprintf( buf, "<DD>%s<BR>%s", outval, eol );
- } else {
- sprintf( buf, "%-*s%s%s", labelwidth, " ", outval, eol );
- }
- (*writeproc)( writeparm, buf, strlen( buf ));
- }
- }
-
- if ( freebuf ) {
- free( buf );
- }
-
- return( LDAP_SUCCESS );
-}
-
-
-static int
-max_label_len( struct ldap_disptmpl *tmpl )
-{
- struct ldap_tmplitem *rowp, *colp;
- int len, maxlen;
-
- maxlen = 0;
-
- for ( rowp = ldap_first_tmplrow( tmpl ); rowp != NULLTMPLITEM;
- rowp = ldap_next_tmplrow( tmpl, rowp )) {
- for ( colp = ldap_first_tmplcol( tmpl, rowp ); colp != NULLTMPLITEM;
- colp = ldap_next_tmplcol( tmpl, rowp, colp )) {
- if (( len = strlen( colp->ti_label )) > maxlen ) {
- maxlen = len;
- }
- }
- }
-
- return( maxlen );
-}
-
-
-static int
-output_label( char *buf, char *label, int width, writeptype writeproc,
- void *writeparm, char *eol, int html )
-{
- char *p;
-
- if ( html ) {
- sprintf( buf, "<DT><B>%s</B>", label );
- } else {
- sprintf( buf, " %s:", label );
- p = buf + strlen( buf );
-
- while ( p - buf < width ) {
- *p++ = ' ';
- }
-
- *p = '\0';
- strcat( buf, eol );
- }
-
- return ((*writeproc)( writeparm, buf, strlen( buf )));
-}
-
-
-static int
-output_dn( char *buf, char *dn, int width, int rdncount,
- writeptype writeproc, void *writeparm, char *eol, char *urlprefix )
-{
- char **dnrdns;
- int i;
-
- if (( dnrdns = ldap_explode_dn( dn, 1 )) == NULL ) {
- return( -1 );
- }
-
- if ( urlprefix != NULL ) {
- sprintf( buf, "<DD><A HREF=\"%s", urlprefix );
- strcat_escaped( buf, dn );
- strcat( buf, "\">" );
- } else if ( width > 0 ) {
- sprintf( buf, "%-*s", width, " " );
- } else {
- *buf = '\0';
- }
-
- for ( i = 0; dnrdns[ i ] != NULL && ( rdncount == 0 || i < rdncount );
- ++i ) {
- if ( i > 0 ) {
- strcat( buf, ", " );
- }
- strcat( buf, dnrdns[ i ] );
- }
-
- if ( urlprefix != NULL ) {
- strcat( buf, "</A><BR>" );
- }
-
- ldap_value_free( dnrdns );
-
- strcat( buf, eol );
-
- return ((*writeproc)( writeparm, buf, strlen( buf )));
-}
-
-
-
-#define HREF_CHAR_ACCEPTABLE( c ) (( c >= '-' && c <= '9' ) || \
- ( c >= '@' && c <= 'Z' ) || \
- ( c == '_' ) || \
- ( c >= 'a' && c <= 'z' ))
-
-static void
-strcat_escaped( char *s1, char *s2 )
-{
- char *p, *q;
- char *hexdig = "0123456789ABCDEF";
-
- p = s1 + strlen( s1 );
- for ( q = s2; *q != '\0'; ++q ) {
- if ( HREF_CHAR_ACCEPTABLE( *q )) {
- *p++ = *q;
- } else {
- *p++ = '%';
- *p++ = hexdig[ *q >> 4 ];
- *p++ = hexdig[ *q & 0x0F ];
- }
- }
-
- *p = '\0';
-}
-
-
-#define GET2BYTENUM( p ) (( *p - '0' ) * 10 + ( *(p+1) - '0' ))
-
-static char *
-time2text( char *ldtimestr, int dateonly )
-{
- struct tm t;
- char *p, zone, *fmterr = "badly formatted time";
- time_t gmttime;
- int century;
- static char timestr[128];
-
- memset( (char *)&t, 0, sizeof( struct tm ));
- if ( (int) strlen( ldtimestr ) < 13 ) {
- return( fmterr );
- }
-
- for ( p = ldtimestr; p - ldtimestr < 12; ++p ) {
- if ( !isdigit( *p )) {
- return( fmterr );
- }
- }
-
- p = ldtimestr;
- century = GET2BYTENUM( p ) * 100; p += 2;
- century += GET2BYTENUM( p ); p += 2;
- /* tm_year is the offset of number of years from TM_YEAR_BASE */
- t.tm_year = century - TM_YEAR_BASE;
- t.tm_mon = GET2BYTENUM( p ) - 1; p += 2;
- t.tm_mday = GET2BYTENUM( p ); p += 2;
- t.tm_hour = GET2BYTENUM( p ); p += 2;
- t.tm_min = GET2BYTENUM( p ); p += 2;
- t.tm_sec = GET2BYTENUM( p ); p += 2;
-
- /*strftime will return for e.g. Thu Aug 19 2001 */
- if (strftime(timestr, sizeof(timestr), "%a %b %d %Y", &t) == 0) {
- return( fmterr );
- }
- if (dateonly) {
- strcpy(timestr + 11, timestr + 20);
- }
- return( timestr );
-}
-
-
-
-/* gtime.c - inverse gmtime */
-
-#if !defined( MACOS ) && !defined( _WIN32 ) && !defined( DOS )
-#include <sys/time.h>
-#endif /* !MACOS */
-
-/* gtime(): the inverse of localtime().
- This routine was supplied by Mike Accetta at CMU many years ago.
- */
-
-static int dmsize[] = {
- 31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31
-};
-
-#define dysize(y) \
- (((y) % 4) ? 365 : (((y) % 100) ? 366 : (((y) % 400) ? 365 : 366)))
-
-#define YEAR(y) ((y) >= 100 ? (y) : (y) + 1900)
-
-/* */
-
-static time_t gtime ( struct tm *tm )
-{
- register int i,
- sec,
- mins,
- hour,
- mday,
- mon,
- year;
- register time_t result;
-
- if ((sec = tm -> tm_sec) < 0 || sec > 59
- || (mins = tm -> tm_min) < 0 || mins > 59
- || (hour = tm -> tm_hour) < 0 || hour > 24
- || (mday = tm -> tm_mday) < 1 || mday > 31
- || (mon = tm -> tm_mon + 1) < 1 || mon > 12)
- return ((time_t) -1);
- if (hour == 24) {
- hour = 0;
- mday++;
- }
- year = YEAR (tm -> tm_year);
-
- result = 0L;
- for (i = 1970; i < year; i++)
- result += dysize (i);
- if (dysize (year) == 366 && mon >= 3)
- result++;
- while (--mon)
- result += dmsize[mon - 1];
- result += mday - 1;
- result = 24 * result + hour;
- result = 60 * result + mins;
- result = 60 * result + sec;
-
- return result;
-}
-
-static int
-searchaction( LDAP *ld, char *buf, char *base, LDAPMessage *entry, char *dn,
- struct ldap_tmplitem *tip, int labelwidth, int rdncount,
- writeptype writeproc, void *writeparm, char *eol, char *urlprefix )
-{
- int err, lderr, i, count, html;
- char **vals, **members;
- char *value, *filtpattern, *attr, *selectname;
- char *retattrs[2], filter[ 256 ];
- LDAPMessage *ldmp;
- struct timeval timeout;
-
- html = ( urlprefix != NULL );
-
- for ( i = 0; tip->ti_args != NULL && tip->ti_args[ i ] != NULL; ++i ) {
- ;
- }
- if ( i < 3 ) {
- return( LDAP_PARAM_ERROR );
- }
- attr = tip->ti_args[ 0 ];
- filtpattern = tip->ti_args[ 1 ];
- retattrs[ 0 ] = tip->ti_args[ 2 ];
- retattrs[ 1 ] = NULL;
- selectname = tip->ti_args[ 3 ];
-
- vals = NULL;
- if ( attr == NULL ) {
- value = NULL;
- } else if ( strcasecmp( attr, "-dnb" ) == 0 ) {
- return( LDAP_PARAM_ERROR );
- } else if ( strcasecmp( attr, "-dnt" ) == 0 ) {
- value = dn;
- } else if (( vals = ldap_get_values( ld, entry, attr )) != NULL ) {
- value = vals[ 0 ];
- } else {
- value = NULL;
- }
-
- ldap_build_filter( filter, sizeof( filter ), filtpattern, NULL, NULL, NULL,
- value, NULL );
-
- if ( html ) {
- /*
- * if we are generating HTML, we add an HREF link that embodies this
- * search action as an LDAP URL, instead of actually doing the search
- * now.
- */
- sprintf( buf, "<DT><A HREF=\"%s", urlprefix );
- if ( base != NULL ) {
- strcat_escaped( buf, base );
- }
- strcat( buf, "??sub?" );
- strcat_escaped( buf, filter );
- sprintf( buf + strlen( buf ), "\"><B>%s</B></A><DD><BR>%s",
- tip->ti_label, eol );
- if ((*writeproc)( writeparm, buf, strlen( buf )) < 0 ) {
- return( LDAP_LOCAL_ERROR );
- }
- return( LDAP_SUCCESS );
- }
-
- timeout.tv_sec = SEARCH_TIMEOUT_SECS;
- timeout.tv_usec = 0;
-
-#ifdef CLDAP
- if ( LDAP_IS_CLDAP( ld ))
- lderr = cldap_search_s( ld, base, LDAP_SCOPE_SUBTREE, filter, retattrs,
- 0, &ldmp, NULL );
- else
-#endif /* CLDAP */
- lderr = ldap_search_st( ld, base, LDAP_SCOPE_SUBTREE, filter, retattrs,
- 0, &timeout, &ldmp );
-
- if ( lderr == LDAP_SUCCESS || NONFATAL_LDAP_ERR( lderr )) {
- if (( count = ldap_count_entries( ld, ldmp )) > 0 ) {
- if (( members = (char **)malloc( (count + 1) * sizeof(char *)))
- == NULL ) {
- err = LDAP_NO_MEMORY;
- } else {
- for ( i = 0, entry = ldap_first_entry( ld, ldmp );
- entry != NULL;
- entry = ldap_next_entry( ld, entry ), ++i ) {
- members[ i ] = ldap_get_dn( ld, entry );
- }
- members[ i ] = NULL;
-
- ldap_sort_values( ld, members, ldap_sort_strcasecmp );
-
- err = do_vals2text( ld, NULL, members, tip->ti_label,
- html ? -1 : 0, LDAP_SYN_DN, writeproc, writeparm,
- eol, rdncount, urlprefix );
-
- ldap_value_free( members );
- }
- }
- ldap_msgfree( ldmp );
- }
-
-
- if ( vals != NULL ) {
- ldap_value_free( vals );
- }
-
- return(( err == LDAP_SUCCESS ) ? lderr : err );
-}
diff --git a/usr/src/lib/libldap4/common/ufn.c b/usr/src/lib/libldap4/common/ufn.c
deleted file mode 100644
index 37c9ed3138..0000000000
--- a/usr/src/lib/libldap4/common/ufn.c
+++ /dev/null
@@ -1,594 +0,0 @@
-/*
- *
- * Portions Copyright 1998 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- *
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*
- * Copyright (c) 1990 Regents of the University of Michigan.
- * All rights reserved.
- *
- * ufn.c
- */
-
-#ifndef lint
-static char copyright[] = "@(#) Copyright (c) 1993 Regents of the University of Michigan.\nAll rights reserved.\n";
-#endif
-
-#include <stdio.h>
-#include <string.h>
-#include <ctype.h>
-#include <stdlib.h> /* malloc(), realloc(), free() */
-
-#ifdef MACOS
-#include <stdlib.h>
-#include "macos.h"
-#else /* MACOS */
-#if defined( DOS ) || defined( _WIN32 )
-#include "msdos.h"
-#else /* DOS */
-#include <sys/time.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#endif /* DOS */
-#endif /* MACOS */
-
-#include "lber.h"
-#include "ldap.h"
-#include "ldap-private.h"
-#include "ldap-int.h"
-#ifdef SUN
-/*
- * to include definition of FILTERFILE and or TEMPLATEFILE
- */
-#include "ldapconfig.h"
-#endif
-
-#ifdef NEEDPROTOS
-typedef int (*cancelptype)( void *cancelparm );
-#else /* NEEDPROTOS */
-typedef int (*cancelptype)();
-#endif /* NEEDPROTOS */
-
-#ifdef NEEDPROTOS
-static int ldap_ufn_search_ctx( LDAP *ld, char **ufncomp, int ncomp,
- char *prefix, char **attrs, int attrsonly, LDAPMessage **res,
- cancelptype cancelproc, void *cancelparm, char *tag1, char *tag2,
- char *tag3 );
-static LDAPMessage *ldap_msg_merge( LDAP *ld, LDAPMessage *a, LDAPMessage *b );
-static LDAPMessage *ldap_ufn_expand( LDAP *ld, cancelptype cancelproc,
- void *cancelparm, char **dns, char *filter, int scope,
- char **attrs, int aonly, int *err );
-LDAPFiltDesc *ldap_ufn_setfilter( LDAP *ld, char *fname );
-#else /* NEEDPROTOS */
-static LDAPMessage *ldap_msg_merge();
-static LDAPMessage *ldap_ufn_expand();
-LDAPFiltDesc *ldap_ufn_setfilter();
-#endif /* NEEDPROTOS */
-static LDAPMessage *ldap_msg_merge();
-static LDAPMessage *ldap_ufn_expand();
-
-/*
- * ldap_ufn_search_ctx - do user friendly searching; provide cancel feature;
- * specify ldapfilter.conf tags for each phase of search
- *
- * ld LDAP descriptor
- * ufncomp the exploded user friendly name to look for
- * ncomp number of elements in ufncomp
- * prefix where to start searching
- * attrs list of attribute types to return for matches
- * attrsonly 1 => attributes only 0 => attributes and values
- * res will contain the result of the search
- * cancelproc routine that returns non-zero if operation should be
- * cancelled. This can be NULL. If it is non-NULL, the
- * routine will be called periodically.
- * cancelparm void * that is passed to cancelproc
- * tag[123] the ldapfilter.conf tag that will be used in phases
- * 1, 2, and 3 of the search, respectively
- *
- * Example:
- * char *attrs[] = { "mail", "title", 0 };
- * char *ufncomp[] = { "howes", "umich", "us", 0 }
- * LDAPMessage *res;
- * error = ldap_ufn_search_ctx( ld, ufncomp, 3, NULL, attrs, attrsonly,
- * &res, acancelproc, along, "ufn first",
- * "ufn intermediate", "ufn last" );
- */
-
-static int
-ldap_ufn_search_ctx( LDAP *ld, char **ufncomp, int ncomp, char *prefix,
- char **attrs, int attrsonly, LDAPMessage **res, cancelptype cancelproc,
- void *cancelparm, char *tag1, char *tag2, char *tag3 )
-{
- char *dn, *ftag;
- char **dns;
- int max, i, err, scope, phase, tries;
- LDAPFiltInfo *fi;
- LDAPMessage *tmpcand;
- LDAPMessage *candidates;
- /* LDAPMessage *ldap_msg_merge(), *ldap_ufn_expand(); */
- static char *objattrs[] = { "objectClass", NULL };
-
- /*
- * look up ufn components from most to least significant.
- * there are 3 phases.
- * phase 1 search the root for orgs or countries
- * phase 2 search for orgs
- * phase 3 search for a person
- * in phases 1 and 2, we are building a list of candidate DNs,
- * below which we will search for the final component of the ufn.
- * for each component we try the filters listed in the
- * filterconfig file, first one-level (except the last compoment),
- * then subtree. if any of them produce any results, we go on to
- * the next component.
- */
-
-#if defined( SUN ) && defined( _REENTRANT )
- LOCK_LDAP(ld);
-#endif
- *res = NULL;
- candidates = NULL;
- phase = 1;
- for ( ncomp--; ncomp != -1; ncomp-- ) {
- if ( *ufncomp[ncomp] == '"' ) {
- char *quote;
-
- if ( (quote = strrchr( ufncomp[ncomp], '"' )) != NULL )
- *quote = '\0';
- (void) strcpy( ufncomp[ncomp], ufncomp[ncomp] + 1 );
- }
- if ( ncomp == 0 )
- phase = 3;
-
- switch ( phase ) {
- case 1:
- ftag = tag1;
- scope = LDAP_SCOPE_ONELEVEL;
- break;
- case 2:
- ftag = tag2;
- scope = LDAP_SCOPE_ONELEVEL;
- break;
- case 3:
- ftag = tag3;
- scope = LDAP_SCOPE_SUBTREE;
- break;
- }
-
- /*
- * construct an array of DN's to search below from the
- * list of candidates.
- */
-
- if ( candidates == NULL ) {
- if ( prefix != NULL ) {
- if ( (dns = (char **) malloc( sizeof(char *)
- * 2 )) == NULL ) {
-#if defined( SUN ) && defined( _REENTRANT )
- UNLOCK_LDAP(ld);
-#endif
- return( ld->ld_errno = LDAP_NO_MEMORY );
- }
- dns[0] = strdup( prefix );
- dns[1] = NULL;
- } else {
- dns = NULL;
- }
- } else {
- i = 0, max = 0;
- for ( tmpcand = candidates; tmpcand != NULL &&
- tmpcand->lm_msgtype != LDAP_RES_SEARCH_RESULT;
- tmpcand = tmpcand->lm_chain )
- {
- if ( (dn = ldap_get_dn( ld, tmpcand )) == NULL )
- continue;
-
- if ( dns == NULL ) {
- if ( (dns = (char **) malloc(
- sizeof(char *) * 8 )) == NULL ) {
- ld->ld_errno = LDAP_NO_MEMORY;
-#if defined( SUN ) && defined( _REENTRANT )
- UNLOCK_LDAP(ld);
-#endif
- return( LDAP_NO_MEMORY );
- }
- max = 8;
- } else if ( i >= max ) {
- if ( (dns = (char **) realloc( dns,
- sizeof(char *) * 2 * max ))
- == NULL )
- {
- ld->ld_errno = LDAP_NO_MEMORY;
-#if defined( SUN ) && defined( _REENTRANT )
- UNLOCK_LDAP(ld);
-#endif
- return( LDAP_NO_MEMORY );
- }
- max *= 2;
- }
- dns[i++] = dn;
- dns[i] = NULL;
- }
- ldap_msgfree( candidates );
- candidates = NULL;
- }
- tries = 0;
- tryagain:
- tries++;
- for ( fi = ldap_getfirstfilter( ld->ld_filtd, ftag,
- ufncomp[ncomp] ); fi != NULL;
- fi = ldap_getnextfilter( ld->ld_filtd ) )
- {
- if ( (candidates = ldap_ufn_expand( ld, cancelproc,
- cancelparm, dns, fi->lfi_filter, scope,
- phase == 3 ? attrs : objattrs,
- phase == 3 ? attrsonly : 1, &err )) != NULL )
- {
- break;
- }
-
- if ( err == -1 || err == LDAP_USER_CANCELLED ) {
- if ( dns != NULL ) {
- ldap_value_free( dns );
- dns = NULL;
- }
-#if defined( SUN ) && defined( _REENTRANT )
- UNLOCK_LDAP(ld);
-#endif
- return( err );
- }
- }
-
- if ( candidates == NULL ) {
- if ( tries < 2 && phase != 3 ) {
- scope = LDAP_SCOPE_SUBTREE;
- goto tryagain;
- } else {
- if ( dns != NULL ) {
- ldap_value_free( dns );
- dns = NULL;
- }
-#if defined( SUN ) && defined( _REENTRANT )
- UNLOCK_LDAP(ld);
-#endif
- return( err );
- }
- }
-
- /* go on to the next component */
- if ( phase == 1 )
- phase++;
- if ( dns != NULL ) {
- ldap_value_free( dns );
- dns = NULL;
- }
- }
- *res = candidates;
-
-#if defined( SUN ) && defined( _REENTRANT )
- UNLOCK_LDAP(ld);
-#endif
- return( err );
-}
-
-int
-ldap_ufn_search_ct( LDAP *ld, char *ufn, char **attrs, int attrsonly,
- LDAPMessage **res, cancelptype cancelproc, void *cancelparm,
- char *tag1, char *tag2, char *tag3 )
-{
- char **ufncomp, **prefixcomp;
- char *pbuf;
- int ncomp, pcomp, i, err;
-
-#if defined( SUN ) && defined( _REENTRANT )
- LOCK_LDAP(ld);
-#endif
- /* initialize the getfilter stuff if it's not already */
- if ( ld->ld_filtd == NULL && ldap_ufn_setfilter( ld, FILTERFILE )
- == NULL ) {
-#if defined( SUN ) && defined( _REENTRANT )
- UNLOCK_LDAP(ld);
-#endif
- return( ld->ld_errno = LDAP_LOCAL_ERROR );
- }
-
- /* call ldap_explode_dn() to break the ufn into its components */
- if ( (ufncomp = ldap_explode_dn( ufn, 0 )) == NULL ) {
-#if defined( SUN ) && defined( _REENTRANT )
- UNLOCK_LDAP(ld);
-#endif
- return( ld->ld_errno = LDAP_LOCAL_ERROR );
- }
- for ( ncomp = 0; ufncomp[ncomp] != NULL; ncomp++ )
- ; /* NULL */
-
- /* more than two components => try it fully qualified first */
- if ( ncomp > 2 || ld->ld_ufnprefix == NULL ) {
- err = ldap_ufn_search_ctx( ld, ufncomp, ncomp, NULL, attrs,
- attrsonly, res, cancelproc, cancelparm, tag1, tag2, tag3 );
-
- if ( ldap_count_entries( ld, *res ) > 0 ) {
- ldap_value_free( ufncomp );
-#if defined( SUN ) && defined( _REENTRANT )
- UNLOCK_LDAP(ld);
-#endif
- return( err );
- } else {
- ldap_msgfree( *res );
- *res = NULL;
- }
- }
-
- if ( ld->ld_ufnprefix == NULL ) {
- ldap_value_free( ufncomp );
-#if defined( SUN ) && defined( _REENTRANT )
- UNLOCK_LDAP(ld);
-#endif
- return( err );
- }
-
- /* if that failed, or < 2 components, use the prefix */
- if ( (prefixcomp = ldap_explode_dn( ld->ld_ufnprefix, 0 )) == NULL ) {
- ldap_value_free( ufncomp );
-#if defined( SUN ) && defined( _REENTRANT )
- UNLOCK_LDAP(ld);
-#endif
- return( ld->ld_errno = LDAP_LOCAL_ERROR );
- }
- for ( pcomp = 0; prefixcomp[pcomp] != NULL; pcomp++ )
- ; /* NULL */
- if ( (pbuf = (char *) malloc( strlen( ld->ld_ufnprefix ) + 1 ))
- == NULL ) {
- ldap_value_free( ufncomp );
- ldap_value_free( prefixcomp );
-#if defined( SUN ) && defined( _REENTRANT )
- UNLOCK_LDAP(ld);
-#endif
- return( ld->ld_errno = LDAP_NO_MEMORY );
- }
-
- for ( i = 0; i < pcomp; i++ ) {
- int j;
-
- *pbuf = '\0';
- for ( j = i; j < pcomp; j++ ) {
- (void) strcat( pbuf, prefixcomp[j] );
- if ( j + 1 < pcomp )
- (void) strcat( pbuf, "," );
- }
- err = ldap_ufn_search_ctx( ld, ufncomp, ncomp, pbuf, attrs,
- attrsonly, res, cancelproc, cancelparm, tag1, tag2, tag3 );
-
- if ( ldap_count_entries( ld, *res ) > 0 ) {
- break;
- } else {
- ldap_msgfree( *res );
- *res = NULL;
- }
- }
-
- ldap_value_free( ufncomp );
- ldap_value_free( prefixcomp );
- free( pbuf );
-
-#if defined( SUN ) && defined( _REENTRANT )
- UNLOCK_LDAP(ld);
-#endif
- return( err );
-}
-
-/*
- * same as ldap_ufn_search_ct, except without the ability to specify
- * ldapfilter.conf tags.
- */
-int
-ldap_ufn_search_c( LDAP *ld, char *ufn, char **attrs, int attrsonly,
- LDAPMessage **res, cancelptype cancelproc, void *cancelparm )
-{
- return( ldap_ufn_search_ct( ld, ufn, attrs, attrsonly, res, cancelproc,
- cancelparm, "ufn first", "ufn intermediate", "ufn last" ) );
-}
-
-/*
- * same as ldap_ufn_search_c without the cancel function
- */
-int
-ldap_ufn_search_s( LDAP *ld, char *ufn, char **attrs, int attrsonly,
- LDAPMessage **res )
-{
- struct timeval tv;
-
- tv.tv_sec = ld->ld_timelimit;
-
- return( ldap_ufn_search_ct( ld, ufn, attrs, attrsonly, res,
- ld->ld_timelimit ? ldap_ufn_timeout : NULL,
- ld->ld_timelimit ? (void *) &tv : NULL,
- "ufn first", "ufn intermediate", "ufn last" ) );
-}
-
-
-/*
- * ldap_msg_merge - merge two ldap search result chains. the more
- * serious of the two error result codes is kept.
- */
-
-static LDAPMessage *
-ldap_msg_merge( LDAP *ld, LDAPMessage *a, LDAPMessage *b )
-{
- LDAPMessage *end, *aprev, *aend, *bprev, *bend;
-
- if ( a == NULL )
- return( b );
-
- if ( b == NULL )
- return( a );
-
- /* find the ends of the a and b chains */
- aprev = NULL;
- for ( aend = a; aend->lm_chain != NULL; aend = aend->lm_chain )
- aprev = aend;
- bprev = NULL;
- for ( bend = b; bend->lm_chain != NULL; bend = bend->lm_chain )
- bprev = bend;
-
- /* keep result a */
- if ( ldap_result2error( ld, aend, 0 ) != LDAP_SUCCESS ) {
- /* remove result b */
- ldap_msgfree( bend );
- if ( bprev != NULL )
- bprev->lm_chain = NULL;
- else
- b = NULL;
- end = aend;
- if ( aprev != NULL )
- aprev->lm_chain = NULL;
- else
- a = NULL;
- /* keep result b */
- } else {
- /* remove result a */
- ldap_msgfree( aend );
- if ( aprev != NULL )
- aprev->lm_chain = NULL;
- else
- a = NULL;
- end = bend;
- if ( bprev != NULL )
- bprev->lm_chain = NULL;
- else
- b = NULL;
- }
-
- if ( (a == NULL && b == NULL) || (a == NULL && bprev == NULL) ||
- (b == NULL && aprev == NULL) )
- return( end );
-
- if ( a == NULL ) {
- bprev->lm_chain = end;
- return( b );
- } else if ( b == NULL ) {
- aprev->lm_chain = end;
- return( a );
- } else {
- bprev->lm_chain = end;
- aprev->lm_chain = b;
- return( a );
- }
-}
-
-static LDAPMessage *
-ldap_ufn_expand( LDAP *ld, cancelptype cancelproc, void *cancelparm,
- char **dns, char *filter, int scope, char **attrs, int aonly,
- int *err )
-{
- LDAPMessage *tmpcand, *tmpres;
- char *dn;
- int i, msgid;
- struct timeval tv;
-
- /* search for this component below the current candidates */
- tmpcand = NULL;
- i = 0;
- do {
- if ( dns != NULL )
- dn = dns[i];
- else
- dn = "";
-
- if (( msgid = ldap_search( ld, dn, scope, filter, attrs,
- aonly )) == -1 ) {
- ldap_msgfree( tmpcand );
- *err = ld->ld_errno;
- return( NULL );
- }
-
- tv.tv_sec = 0;
- tv.tv_usec = 100000; /* 1/10 of a second */
-
- do {
- *err = ldap_result( ld, msgid, 1, &tv, &tmpres );
- if ( *err == 0 && cancelproc != NULL &&
- (*cancelproc)( cancelparm ) != 0 ) {
- ldap_abandon( ld, msgid );
- *err = LDAP_USER_CANCELLED;
- ld->ld_errno = LDAP_USER_CANCELLED;
- }
- } while ( *err == 0 );
-
- if ( *err == LDAP_USER_CANCELLED || *err < 0 ||
- ( *err = ldap_result2error( ld, tmpres, 0 )) == -1 ) {
- ldap_msgfree( tmpcand );
- return( NULL );
- }
-
- tmpcand = ldap_msg_merge( ld, tmpcand, tmpres );
-
- i++;
- } while ( dns != NULL && dns[i] != NULL );
-
- if ( ldap_count_entries( ld, tmpcand ) > 0 ) {
- return( tmpcand );
- } else {
- ldap_msgfree( tmpcand );
- return( NULL );
- }
-}
-
-/*
- * ldap_ufn_setfilter - set the filter config file used in ufn searching
- */
-
-LDAPFiltDesc *
-ldap_ufn_setfilter( LDAP *ld, char *fname )
-{
-#if defined( SUN ) && defined( _REENTRANT )
- LDAPFiltDesc *rv;
-
- LOCK_LDAP(ld);
-#endif
- if ( ld->ld_filtd != NULL )
- ldap_getfilter_free( ld->ld_filtd );
-
-#if defined( SUN ) && defined( _REENTRANT )
- ld->ld_filtd = ldap_init_getfilter( fname );
- rv = ld->ld_filtd;
- UNLOCK_LDAP(ld);
- return( rv );
-#else
- return( ld->ld_filtd = ldap_init_getfilter( fname ) );
-#endif
-}
-
-void
-ldap_ufn_setprefix( LDAP *ld, char *prefix )
-{
-#if defined( SUN ) && defined( _REENTRANT )
- LOCK_LDAP(ld);
-#endif
- if ( ld->ld_ufnprefix != NULL )
- free( ld->ld_ufnprefix );
-
- ld->ld_ufnprefix = strdup( prefix );
-#if defined( SUN ) && defined( _REENTRANT )
- UNLOCK_LDAP(ld);
-#endif
-}
-
-int
-ldap_ufn_timeout( void *tvparam )
-{
- struct timeval *tv;
-
- tv = (struct timeval *)tvparam;
-
- if ( tv->tv_sec != 0 ) {
- tv->tv_usec = tv->tv_sec * 1000000; /* sec => micro sec */
- tv->tv_sec = 0;
- }
- tv->tv_usec -= 100000; /* 1/10 of a second */
-
- return( tv->tv_usec <= 0 ? 1 : 0 );
-}
diff --git a/usr/src/lib/libldap4/common/unbind.c b/usr/src/lib/libldap4/common/unbind.c
deleted file mode 100644
index 7c1fe8a333..0000000000
--- a/usr/src/lib/libldap4/common/unbind.c
+++ /dev/null
@@ -1,216 +0,0 @@
-/*
- *
- * Portions Copyright 1999 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- *
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*
- * Copyright (c) 1990 Regents of the University of Michigan.
- * All rights reserved.
- *
- * unbind.c
- */
-
-#ifndef lint
-static char copyright[] = "@(#) Copyright (c) 1990 Regents of the University of Michigan.\nAll rights reserved.\n";
-#endif
-
-#include <stdio.h>
-#include <string.h>
-#ifdef MACOS
-#include <stdlib.h>
-#include "macos.h"
-#else /* MACOS */
-#if defined( DOS ) || defined( _WIN32 )
-#include "msdos.h"
-#ifdef NCSA
-#include "externs.h"
-#endif /* NCSA */
-#else /* DOS */
-#include <sys/types.h>
-#include <sys/time.h>
-#include <sys/socket.h>
-#endif /* DOS */
-#endif /* MACOS */
-
-#include "lber.h"
-#include "ldap.h"
-#include "ldap-private.h"
-#include "ldap-int.h"
-
-
-int
-ldap_unbind( LDAP *ld )
-{
- Debug( LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 259, "ldap_unbind\n"), 0, 0, 0 );
-
- return( ldap_ld_free( ld, 1 ));
-}
-
-
-int
-ldap_ld_free( LDAP *ld, int close )
-{
- LDAPMessage *lm, *next;
- int err = LDAP_SUCCESS;
- LDAPRequest *lr, *nextlr;
-
-#ifdef _REENTRANT
- LOCK_LDAP(ld);
-#endif
- if ( ld->ld_sb.sb_naddr == 0 ) {
- /* free LDAP structure and outstanding requests/responses */
- for ( lr = ld->ld_requests; lr != NULL; lr = nextlr ) {
- nextlr = lr->lr_next;
- free_request( ld, lr );
- }
-
- /* free and unbind from all open connections */
- while ( ld->ld_conns != NULL ) {
- free_connection( ld, ld->ld_conns, 1, close );
- }
- } else {
- int i;
-
- for ( i = 0; i < ld->ld_sb.sb_naddr; ++i ) {
- free( ld->ld_sb.sb_addrs[ i ] );
- }
- free( ld->ld_sb.sb_addrs );
- free( ld->ld_sb.sb_fromaddr );
-#ifdef LDAP_SSL
- if (ld->ld_sb.sb_ssl){
- SSL_delete(ld->ld_sb.sb_ssl);
- }
- ld->ld_sb.sb_ssl = NULL;
- ld->ld_sb.sb_ssl_tls = 0;
-#endif
- }
-
- if (ld->ld_sb.sb_ber.ber_buf) {
- free(ld->ld_sb.sb_ber.ber_buf);
- ld->ld_sb.sb_ber.ber_buf = NULL;
- }
-
-#ifdef _REENTRANT
- LOCK_RESPONSE(ld);
-#endif
- for ( lm = ld->ld_responses; lm != NULL; lm = next ) {
- next = lm->lm_next;
- ldap_msgfree( lm );
- }
-
-#ifdef _REENTRANT
- UNLOCK_RESPONSE(ld);
-#endif
-
-#ifndef NO_CACHE
- if ( ld->ld_cache != NULL )
- ldap_destroy_cache( ld );
-#endif /* !NO_CACHE */
- if ( ld->ld_error != NULL )
- free( ld->ld_error );
- if ( ld->ld_matched != NULL )
- free( ld->ld_matched );
- if ( ld->ld_host != NULL )
- free( ld->ld_host );
- if ( ld->ld_ufnprefix != NULL )
- free( ld->ld_ufnprefix );
- if ( ld->ld_filtd != NULL )
- ldap_getfilter_free( ld->ld_filtd );
- if ( ld->ld_abandoned != NULL )
- free( ld->ld_abandoned );
-
- if ( ld->ld_selectinfo != NULL )
- free_select_info( ld->ld_selectinfo );
-
- if ( ld->ld_defhost != NULL )
- free( ld->ld_defhost );
-
-#ifdef LDAP_SSL
- if (ld->ld_ssl_key != NULL)
- free(ld->ld_ssl_key);
-#endif
-
-#undef ld_attrbuffer
- {
- /* free thread-specific attr buffers */
- int i;
-
- for (i = 0; i < MAX_THREAD_ID; i++)
- if (ld->ld_attrbuffer[i] != NULL) {
- free(ld->ld_attrbuffer[i]);
- ld->ld_attrbuffer[i] = NULL;
- }
- }
-/* free ldapv3 stuff */
- if (ld->ld_srvctrls != NULL)
- ldap_controls_free(ld->ld_srvctrls);
- if (ld->ld_cltctrls != NULL)
- ldap_controls_free(ld->ld_cltctrls);
-
-#ifdef _REENTRANT
- UNLOCK_LDAP(ld);
-
- if (ld->ld_lockcount != 0)
- Debug( LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 260, "Mutex problem: ld_lockcount not equal to zero when freeing context\n"), 0, 0, 0 );
-#endif
-
- free( (char *) ld );
-
- return( err );
-}
-
-int
-ldap_unbind_s( LDAP *ld )
-{
- return( ldap_ld_free( ld, 1 ));
-}
-
-
-int
-send_unbind( LDAP *ld, Sockbuf *sb )
-{
- BerElement *ber;
-
-#if defined( SUN ) && defined( _REENTRANT )
- LOCK_LDAP(ld);
-#endif
- Debug( LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 261, "send_unbind\n"), 0, 0, 0 );
-
- /* create a message to send */
- if ( (ber = alloc_ber_with_options( ld )) == NULLBER ) {
-#if defined( SUN ) && defined( _REENTRANT )
- UNLOCK_LDAP(ld);
-#endif
- return( ld->ld_errno );
- }
-
- /* fill it in */
- if ( ber_printf( ber, "{itn}", ++ld->ld_msgid,
- LDAP_REQ_UNBIND ) == -1 ) {
- ld->ld_errno = LDAP_ENCODING_ERROR;
- ber_free( ber, 1 );
-#if defined( SUN ) && defined( _REENTRANT )
- UNLOCK_LDAP(ld);
-#endif
- return( ld->ld_errno );
- }
-
- /* send the message */
- if ( ber_flush( sb, ber, 1 ) == -1 ) {
- ld->ld_errno = LDAP_SERVER_DOWN;
- ber_free( ber, 1 );
-#if defined( SUN ) && defined( _REENTRANT )
- UNLOCK_LDAP(ld);
-#endif
- return( ld->ld_errno );
- }
-
-#if defined( SUN ) && defined( _REENTRANT )
- UNLOCK_LDAP(ld);
-#endif
- return( LDAP_SUCCESS );
-}
diff --git a/usr/src/lib/libldap4/common/url.c b/usr/src/lib/libldap4/common/url.c
deleted file mode 100644
index dab3cfb258..0000000000
--- a/usr/src/lib/libldap4/common/url.c
+++ /dev/null
@@ -1,836 +0,0 @@
-/*
- * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*
- * Copyright (c) 1996 Regents of the University of Michigan.
- * All rights reserved.
- *
- * LIBLDAP url.c -- LDAP URL related routines
- *
- * LDAP URLs look like this:
- * l d a p : / / hostport / dn [ ? attributes [ ? scope [ ? filter [ ? extensions ] ] ] ]
- *
- * where:
- * attributes is a comma separated list
- * scope is one of these three strings: base one sub (default=base)
- * filter is an string-represented filter as in RFC 1558
- * extensions is a comma separated list of extension
- * and extension is like this: [ ! ] oid/x-oid [ = value ]
- *
- * e.g., ldap://ldap.itd.umich.edu/c=US?o,description?one?o=umich
- *
- * We also tolerate URLs that look like: <ldapurl> and <URL:ldapurl>
- */
-
-#ifndef lint
-static char copyright[] = "@(#) Copyright (c) 1996 Regents of the University of Michigan.\nAll rights reserved.\n";
-#endif
-
-#include <stdio.h>
-#include <string.h>
-#include <ctype.h>
-
-#ifdef MACOS
-#include <stdlib.h>
-#include "macos.h"
-#endif /* MACOS */
-
-#if defined( DOS ) || defined( _WIN32 )
-#include <stdlib.h>
-#include <malloc.h>
-#include "msdos.h"
-#endif /* DOS || _WIN32 */
-
-#if !defined(MACOS) && !defined(DOS) && !defined( _WIN32 )
-#include <sys/time.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#endif /* !MACOS && !DOS && !_WIN32 */
-
-#include "lber.h"
-#include "ldap.h"
-#include "ldap-private.h"
-#include "ldap-int.h"
-
-
-#ifdef NEEDPROTOS
-static int skip_url_prefix( char **urlp, int *enclosedp );
-static void hex_unescape( char *s );
-static int unhex( char c );
-#else /* NEEDPROTOS */
-static int skip_url_prefix();
-static void hex_unescape();
-static int unhex();
-#endif /* NEEDPROTOS */
-
-
-int
-ldap_is_ldap_url( char *url )
-{
- int enclosed;
-
- return( url != NULL && skip_url_prefix( &url, &enclosed ));
-}
-
-
-static int
-skip_url_prefix( char **urlp, int *enclosedp )
-{
-/*
- * return non-zero if this looks like a LDAP URL; zero if not
- * if non-zero returned, *urlp will be moved past "ldap://" part of URL
- */
- if ( *urlp == NULL ) {
- return( 0 );
- }
-
- /* skip leading '<' (if any) */
- if ( **urlp == '<' ) {
- *enclosedp = 1;
- ++*urlp;
- } else {
- *enclosedp = 0;
- }
-
- /* skip leading "URL:" (if any) */
- if ( strlen( *urlp ) >= LDAP_URL_URLCOLON_LEN && strncasecmp(
- *urlp, LDAP_URL_URLCOLON, LDAP_URL_URLCOLON_LEN ) == 0 ) {
- *urlp += LDAP_URL_URLCOLON_LEN;
- }
-
- /* check for missing "ldap://" prefix */
- if ( strlen( *urlp ) < LDAP_URL_PREFIX_LEN ||
- strncasecmp( *urlp, LDAP_URL_PREFIX, LDAP_URL_PREFIX_LEN ) != 0 ) {
- return( 0 );
- }
-
- /* skip over "ldap://" prefix and return success */
- *urlp += LDAP_URL_PREFIX_LEN;
- return( 1 );
-}
-
-int ldap_url_extension_parse( char *exts, LDAPURLExt *** lueppp)
-{
- /* Pick apart the pieces of an LDAP URL Extensions */
- /* No copy of exts is made, LDAPURLExt's points to exts string */
- LDAPURLExt ** lues;
- LDAPURLExt *luep;
- int i = 0;
- char *p = exts;
- char *ptr, *ptr2;
-
- *lueppp = NULL;
-
- /* Count the number of , in extensions */
- while ( (p = strchr (p, ',')) != NULL){
- i++;
- }
- /* There are at most i+1 extensions */
- if ((lues = (LDAPURLExt **)calloc(i+2, sizeof(LDAPURLExt *))) == NULL){
- return (LDAP_URL_ERR_MEM);
- }
-
- p = exts;
- i = 0;
-
- while ( p ) {
- if ((ptr = strchr(p, ',')) != NULL)
- *ptr++ = '\0';
- else
- ptr = NULL;
-
- if ((luep = (LDAPURLExt *)calloc(1, sizeof(LDAPURLExt))) == NULL){
- ldap_free_urlexts(lues);
- return (LDAP_URL_ERR_MEM);
- }
- lues[i] = luep;
-
- if (*p == '!'){
- luep->lue_iscritical = 1;
- p++;
- }
- luep->lue_type = p;
-
- if (( ptr2 = strchr(p, '=')) != NULL) {
- *ptr2++ = '\0';
- luep->lue_value = ptr2;
- hex_unescape(ptr2);
- }
-
- i++;
- p = ptr;
- }
- *lueppp = lues;
-
- return( 0 );
-}
-
-
-int
-ldap_url_parse( char *url, LDAPURLDesc **ludpp )
-{
-/*
- * Pick apart the pieces of an LDAP URL.
- */
-
- LDAPURLDesc *ludp;
- char *attrs = NULL;
- char *p = NULL;
- char *q = NULL;
- char *x = NULL;
- int enclosed, i, nattrs, errcode;
-
- Debug( LDAP_DEBUG_TRACE, catgets(slapdcat, 1, 262, "ldap_url_parse(%s)\n"), url, 0, 0 );
-
- *ludpp = NULL; /* pessimistic */
-
- if ( !skip_url_prefix( &url, &enclosed )) {
- return( LDAP_URL_ERR_NOTLDAP );
- }
-
- /* allocate return struct */
- if (( ludp = (LDAPURLDesc *)calloc( 1, sizeof( LDAPURLDesc )))
- == NULLLDAPURLDESC ) {
- return( LDAP_URL_ERR_MEM );
- }
-
- ludp->lud_port = LDAP_PORT;
-
- /* make working copy of the remainder of the URL */
- if (( url = strdup( url )) == NULL ) {
- ldap_free_urldesc( ludp );
- return( LDAP_URL_ERR_MEM );
- }
-
- if ( enclosed && *((p = url + strlen( url ) - 1)) == '>' ) {
- *p = '\0';
- }
-
- /* set defaults */
- /* LP By default don't set them... Then we can check if they are present or not in URL */
- ludp->lud_scope = LDAP_SCOPE_UNKNOWN;
- ludp->lud_filter = NULL;
-
-
- /* lud_string is the only malloc'd string space we use */
- ludp->lud_string = url;
-
- /* scan forward for '/' that marks end of hostport and begin. of dn */
- if (( ludp->lud_dn = strchr( url, '/' )) != NULL ) {
- *ludp->lud_dn++ = '\0';
- }
-
- /* terminate hostport; point to start of dn */
-
- if (( p = strchr( url, ':' )) != NULL ) {
- *p++ = '\0';
- ludp->lud_port = atoi( p );
- }
-
- if ( *url == '\0' ) {
- ludp->lud_host = NULL;
- } else {
- ludp->lud_host = url;
- hex_unescape( ludp->lud_host );
- }
-
- if (ludp->lud_dn != NULL){
- /* scan for '?' that marks end of dn and beginning of attributes */
- if (( attrs = strchr( ludp->lud_dn, '?' )) != NULL ) {
- /* terminate dn; point to start of attrs. */
- *attrs++ = '\0';
-
- /* scan for '?' that marks end of attrs and begin. of scope */
- if (( p = strchr( attrs, '?' )) != NULL ) {
- /*
- * terminate attrs; point to start of scope and scan for
- * '?' that marks end of scope and begin. of filter
- */
- *p++ = '\0';
-
- if (( q = strchr( p, '?' )) != NULL ) {
- /* terminate scope; point to start of filter */
- *q++ = '\0';
-
- if (( x = strchr(q, '?')) != NULL ) {
- /* terminate filter; point to start of extension */
- *x++ = '\0';
-
- if (*x != '\0'){
- /* parse extensions */
- }
- }
-
- if ( *q != '\0' ) {
- ludp->lud_filter = q;
- hex_unescape( ludp->lud_filter );
- }
- }
-
- if ( strcasecmp( p, "one" ) == 0 ) {
- ludp->lud_scope = LDAP_SCOPE_ONELEVEL;
- } else if ( strcasecmp( p, "base" ) == 0 ) {
- ludp->lud_scope = LDAP_SCOPE_BASE;
- } else if ( strcasecmp( p, "sub" ) == 0 ) {
- ludp->lud_scope = LDAP_SCOPE_SUBTREE;
- } else if ( *p != '\0' ) {
- ldap_free_urldesc( ludp );
- return( LDAP_URL_ERR_BADSCOPE );
- }
- }
- }
- if ( *ludp->lud_dn == '\0' ) {
- ludp->lud_dn = NULL;
- } else {
- hex_unescape( ludp->lud_dn );
- }
-
- /*
- * if attrs list was included, turn it into a null-terminated array
- */
- if ( attrs != NULL && *attrs != '\0' ) {
- for ( nattrs = 1, p = attrs; *p != '\0'; ++p ) {
- if ( *p == ',' ) {
- ++nattrs;
- }
- }
-
- if (( ludp->lud_attrs = (char **)calloc( nattrs + 1,
- sizeof( char * ))) == NULL ) {
- ldap_free_urldesc( ludp );
- return( LDAP_URL_ERR_MEM );
- }
-
- for ( i = 0, p = attrs; i < nattrs; ++i ) {
- ludp->lud_attrs[ i ] = p;
- if (( p = strchr( p, ',' )) != NULL ) {
- *p++ ='\0';
- }
- hex_unescape( ludp->lud_attrs[ i ] );
- }
- }
-
- if (x != NULL && *x != '\0'){
- if (errcode = ldap_url_extension_parse(x, &ludp->lud_extensions)){
- ldap_free_urldesc(ludp);
- return ( errcode );
- }
- }
- }
-
- *ludpp = ludp;
-
- return( 0 );
-}
-
-void ldap_free_urlexts( LDAPURLExt ** lues)
-{
- int i;
- for (i = 0; lues[i] != NULL; i++){
- free(lues[i]);
- }
- free(lues);
-}
-
-
-void
-ldap_free_urldesc( LDAPURLDesc *ludp )
-{
- if ( ludp != NULLLDAPURLDESC ) {
- if ( ludp->lud_string != NULL ) {
- free( ludp->lud_string );
- }
- if ( ludp->lud_attrs != NULL ) {
- free( ludp->lud_attrs );
- }
- if (ludp->lud_extensions != NULL) {
- ldap_free_urlexts(ludp->lud_extensions);
- }
- free( ludp );
- }
-}
-
-
-
-int
-ldap_url_search( LDAP *ld, char *url, int attrsonly )
-{
- int err;
- LDAPURLDesc *ludp;
- BerElement *ber;
- LDAPServer *srv = NULL;
-
-#ifdef _REENTRANT
- LOCK_LDAP(ld);
-#endif
- if ( ldap_url_parse( url, &ludp ) != 0 ) {
- ld->ld_errno = LDAP_PARAM_ERROR;
-#ifdef _REENTRANT
- UNLOCK_LDAP(ld);
-#endif
- return( -1 );
- }
-
- if (( ber = ldap_build_search_req( ld, ludp->lud_dn,
- ludp->lud_scope == LDAP_SCOPE_UNKNOWN ? LDAP_SCOPE_BASE : ludp->lud_scope,
- ludp->lud_filter ? ludp->lud_filter : "(objectclass=*)",
- ludp->lud_attrs, attrsonly, NULL, NULL, -1 )) == NULLBER ) {
-#ifdef _REENTRANT
- UNLOCK_LDAP(ld);
-#endif
- return( -1 );
- }
-
- err = 0;
-
- if ( ludp->lud_host != NULL || ludp->lud_port != 0 ) {
- if (( srv = (LDAPServer *)calloc( 1, sizeof( LDAPServer )))
- == NULL || ( srv->lsrv_host = strdup( ludp->lud_host ==
- NULL ? ld->ld_defhost : ludp->lud_host )) == NULL ) {
- if ( srv != NULL ) {
- free( srv );
- }
- ld->ld_errno = LDAP_NO_MEMORY;
- err = -1;
- } else {
- if ( ludp->lud_port == 0 ) {
- srv->lsrv_port = LDAP_PORT;
- } else {
- srv->lsrv_port = ludp->lud_port;
- }
- }
- }
-
- if ( err != 0 ) {
- ber_free( ber, 1 );
- } else {
- err = send_server_request( ld, ber, ld->ld_msgid, NULL, srv, NULL, 1 );
- }
-
- ldap_free_urldesc( ludp );
-
-#ifdef _REENTRANT
- UNLOCK_LDAP(ld);
-#endif
- return( err );
-}
-
-
-int
-ldap_url_search_st( LDAP *ld, char *url, int attrsonly,
- struct timeval *timeout, LDAPMessage **res )
-{
- int msgid;
- int retcode = LDAP_SUCCESS;
-
- if (( msgid = ldap_url_search( ld, url, attrsonly )) == -1 ) {
- return( ld->ld_errno );
- }
-
- if ( ldap_result( ld, msgid, 1, timeout, res ) == -1 ) {
- return( ld->ld_errno );
- }
-
- if ( ld->ld_errno == LDAP_TIMEOUT ) {
- (void) ldap_abandon( ld, msgid );
- ld->ld_errno = LDAP_TIMEOUT;
- return( ld->ld_errno );
- }
-
-#ifdef _REENTRANT
- LOCK_LDAP(ld);
-#endif
- retcode = ldap_parse_result(ld, *res, &ld->ld_errno, &ld->ld_matched, &ld->ld_error,
- &ld->ld_referrals, &ld->ld_ret_ctrls, 0);
- if (retcode == LDAP_SUCCESS)
- retcode = ld->ld_errno;
-#ifdef _REENTRANT
- UNLOCK_LDAP(ld);
-#endif
-
- return (retcode);
-}
-
-
-int
-ldap_url_search_s( LDAP *ld, char *url, int attrsonly, LDAPMessage **res )
-{
- int msgid;
- int retcode = LDAP_SUCCESS;
-
- if (( msgid = ldap_url_search( ld, url, attrsonly )) == -1 ) {
- return( ld->ld_errno );
- }
-
- if ( ldap_result( ld, msgid, 1, (struct timeval *)NULL, res ) == -1 ) {
- return( ld->ld_errno );
- }
-
-#ifdef _REENTRANT
- LOCK_LDAP(ld);
-#endif
- retcode = ldap_parse_result(ld, *res, &ld->ld_errno, &ld->ld_matched, &ld->ld_error,
- &ld->ld_referrals, &ld->ld_ret_ctrls, 0);
- if (retcode == LDAP_SUCCESS)
- retcode = ld->ld_errno;
-#ifdef _REENTRANT
- UNLOCK_LDAP(ld);
-#endif
-
- return (retcode);
-}
-
-
-static void
-hex_unescape( char *s )
-{
-/*
- * Remove URL hex escapes from s... done in place. The basic concept for
- * this routine is borrowed from the WWW library HTUnEscape() routine.
- */
- char *p;
-
- for ( p = s; *s != '\0'; ++s ) {
- if ( *s == '%' ) {
- if ( *++s != '\0' ) {
- *p = unhex( *s ) << 4;
- }
- if ( *++s != '\0' ) {
- *p++ += unhex( *s );
- }
- } else {
- *p++ = *s;
- }
- }
-
- *p = '\0';
-}
-
-
-static int
-unhex( char c )
-{
- return( c >= '0' && c <= '9' ? c - '0'
- : c >= 'A' && c <= 'F' ? c - 'A' + 10
- : c - 'a' + 10 );
-}
-
-
-/*
- * Locate the LDAP URL associated with a DNS domain name.
- *
- * The supplied DNS domain name is converted into a distinguished
- * name. The directory entry specified by that distinguished name
- * is searched for a labeledURI attribute. If successful then the
- * LDAP URL is returned. If unsuccessful then that entry's parent
- * is searched and so on until the target distinguished name is
- * reduced to only two nameparts.
- *
- * For example, if 'ny.eng.wiz.com' is the DNS domain then the
- * following entries are searched until one succeeds:
- * dc=ny,dc=eng,dc=wiz,dc=com
- * dc=eng,dc=wiz,dc=com
- * dc=wiz,dc=com
- *
- * If dns_name is NULL then the environment variable LOCALDOMAIN is used.
- * If attrs is not NULL then it is appended to the URL's attribute list.
- * If scope is not NULL then it overrides the URL's scope.
- * If filter is not NULL then it is merged with the URL's filter.
- *
- * If an error is encountered then zero is returned, otherwise a string
- * URL is returned. The caller should free the returned string if it is
- * non-zero.
- */
-
-char *
-ldap_dns_to_url(
- LDAP *ld,
- char *dns_name,
- char *attrs,
- char *scope,
- char *filter
-)
-{
- char *dn;
- char *url = 0;
- char *url2 = 0;
- LDAPURLDesc *urldesc;
- char *cp;
- char *cp2;
- size_t attrs_len = 0;
- size_t scope_len = 0;
- size_t filter_len = 0;
- int nameparts;
- int no_attrs = 0;
- int no_scope = 0;
-
- if (dns_name == 0) {
- dns_name = (char *)getenv("LOCALDOMAIN");
- }
-
- if ((ld == NULL) || ((dn = ldap_dns_to_dn(dns_name, &nameparts)) ==
- NULL))
- return (0);
-
- if ((url = ldap_dn_to_url(ld, dn, nameparts)) == NULL) {
- free(dn);
- return (0);
- }
- free(dn);
-
- /* merge filter and/or scope and/or attributes with URL */
- if (attrs || scope || filter) {
-
- if (attrs)
- attrs_len = strlen(attrs) + 2; /* for comma and NULL */
-
- if (scope)
- scope_len = strlen(scope) + 1; /* for NULL */
-
- if (filter)
- filter_len = strlen(filter) + 4;
- /* for ampersand, parentheses and NULL */
-
- if (ldap_is_ldap_url(url)) {
-
- if ((url2 = (char *)malloc(attrs_len + scope_len +
- filter_len + strlen(url) + 1)) == NULL) {
- return (0);
- }
- cp = url;
- cp2 = url2;
-
- /* copy URL scheme, hostname, port number and DN */
- while (*cp && (*cp != '?')) {
- *cp2++ = *cp++;
- }
-
- /* handle URL attributes */
-
- if (*cp == '?') { /* test first '?' */
- *cp2++ = *cp++; /* copy first '?' */
-
- if (*cp == '?') { /* test second '?' */
-
- /* insert supplied attributes */
- if (attrs) {
- while (*attrs) {
- *cp2++ = *attrs++;
- }
- } else {
- no_attrs = 1;
- }
-
- } else {
-
- /* copy URL attributes */
- while (*cp && (*cp != '?')) {
- *cp2++ = *cp++;
- }
-
- /* append supplied attributes */
- if (attrs) {
- *cp2++ = ',';
- while (*attrs) {
- *cp2++ = *attrs++;
- }
- }
- }
-
- } else {
- /* append supplied attributes */
- if (attrs) {
- *cp2++ = '?';
- while (*attrs) {
- *cp2++ = *attrs++;
- }
- } else {
- no_attrs = 1;
- }
- }
-
- /* handle URL scope */
-
- if (*cp == '?') { /* test second '?' */
- *cp2++ = *cp++; /* copy second '?' */
-
- if (*cp == '?') { /* test third '?' */
-
- /* insert supplied scope */
- if (scope) {
- while (*scope) {
- *cp2++ = *scope++;
- }
- } else {
- no_scope = 1;
- }
-
- } else {
-
- if (scope) {
- /* skip over URL scope */
- while (*cp && (*cp != '?')) {
- *cp++;
- }
- /* insert supplied scope */
- while (*scope) {
- *cp2++ = *scope++;
- }
- } else {
-
- /* copy URL scope */
- while (*cp && (*cp != '?')) {
- *cp2++ = *cp++;
- }
- }
- }
-
- } else {
- /* append supplied scope */
- if (scope) {
- if (no_attrs) {
- *cp2++ = '?';
- }
- *cp2++ = '?';
- while (*scope) {
- *cp2++ = *scope++;
- }
- } else {
- no_scope = 1;
- }
- }
-
- /* handle URL filter */
-
- if (*cp == '?') { /* test third '?' */
- *cp2++ = *cp++; /* copy third '?' */
-
- if (filter) {
-
- /* merge URL and supplied filters */
-
- *cp2++ = '(';
- *cp2++ = '&';
- /* copy URL filter */
- while (*cp) {
- *cp2++ = *cp++;
- }
- /* append supplied filter */
- while (*filter) {
- *cp2++ = *filter++;
- }
- *cp2++ = ')';
- } else {
-
- /* copy URL filter */
- while (*cp) {
- *cp2++ = *cp++;
- }
- }
-
- } else {
- /* append supplied filter */
- if (filter) {
- if (no_scope) {
- if (no_attrs) {
- *cp2++ = '?';
- }
- *cp2++ = '?';
- }
- *cp2++ = '?';
- while (*filter) {
- *cp2++ = *filter++;
- }
- }
- }
-
- *cp2++ = '\0';
- free (url);
- url = url2;
-
- } else {
- return (0); /* not an LDAP URL */
- }
- }
- return (url);
-}
-
-
-/*
- * Locate the LDAP URL associated with a distinguished name.
- *
- * The number of nameparts in the supplied distinguished name must be
- * provided. The specified directory entry is searched for a labeledURI
- * attribute. If successful then the LDAP URL is returned. If unsuccessful
- * then that entry's parent is searched and so on until the target
- * distinguished name is reduced to only two nameparts.
- *
- * For example, if 'l=ny,ou=eng,o=wiz,c=us' is the distinguished name
- * then the following entries are searched until one succeeds:
- * l=ny,ou=eng,o=wiz,c=us
- * ou=eng,o=wiz,c=us
- * o=wiz,c=us
- *
- * If an error is encountered then zero is returned, otherwise a string
- * URL is returned. The caller should free the returned string if it is
- * non-zero.
- */
-
-char *
-ldap_dn_to_url(
- LDAP *ld,
- char *dn,
- int nameparts
-)
-{
- char *next_dn = dn;
- char *url = 0;
- char *attrs[2] = {"labeledURI", 0};
- LDAPMessage *res, *e;
- char **vals;
-
- /*
- * Search for a URL in the named entry or its parent entry.
- * Continue until only 2 nameparts remain.
- */
- while (dn && (nameparts > 1) && (! url)) {
-
- /* search for the labeledURI attribute */
- if (ldap_search_s(ld, dn, LDAP_SCOPE_BASE,
- "(objectClass=*)", attrs, 0, &res) == LDAP_SUCCESS) {
-
- /* locate the first entry returned */
- if ((e = ldap_first_entry(ld, res)) != NULL) {
-
- /* locate the labeledURI attribute */
- if ((vals =
- ldap_get_values(ld, e, "labeledURI")) !=
- NULL) {
-
- /* copy the attribute value */
- if ((url = strdup((char *)vals[0])) !=
- NULL) {
- ldap_value_free(vals);
- }
- }
- }
- /* free the search results */
- ldap_msgfree(res);
- }
-
- if (! url) {
- /* advance along the DN by one namepart */
- if (next_dn = strchr(dn, ',')) {
- next_dn++;
- dn = next_dn;
- nameparts--;
- }
- }
- }
-
- return (url);
-}
diff --git a/usr/src/lib/libldap4/common/utils.c b/usr/src/lib/libldap4/common/utils.c
deleted file mode 100644
index 922e648ab7..0000000000
--- a/usr/src/lib/libldap4/common/utils.c
+++ /dev/null
@@ -1,28 +0,0 @@
-/*
- *
- * Copyright 1998 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- *
- *
- * Comments:
- *
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <ctype.h>
-#include <string.h>
-
-void free_strarray( char **sap )
-{
- int i;
-
- if ( sap != NULL ) {
- for ( i = 0; sap[ i ] != NULL; ++i ) {
- free( sap[ i ] );
- }
- free( (char *)sap );
- }
-}
diff --git a/usr/src/lib/libldap4/common/version.c b/usr/src/lib/libldap4/common/version.c
deleted file mode 100644
index de22e03f02..0000000000
--- a/usr/src/lib/libldap4/common/version.c
+++ /dev/null
@@ -1,20 +0,0 @@
-/*
- * Portions Copyright 1998 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*
- * Copyright (c) 1991 Regents of the University of Michigan.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms are permitted
- * provided that this notice is preserved and that due credit is given
- * to the University of Michigan at Ann Arbor. The name of the University
- * may not be used to endorse or promote products derived from this
- * software without specific prior written permission. This software
- * is provided ``as is'' without express or implied warranty.
- */
-
-static char Version[] = VERSIONNAME": libldap.a 4.0";
diff --git a/usr/src/lib/libldap4/common/vlistctrl.c b/usr/src/lib/libldap4/common/vlistctrl.c
deleted file mode 100644
index 779df251d0..0000000000
--- a/usr/src/lib/libldap4/common/vlistctrl.c
+++ /dev/null
@@ -1,124 +0,0 @@
-/*
- *
- * Copyright 1999 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- *
- *
- * Comments:
- *
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#include <stdio.h>
-#include <string.h>
-
-#include "lber.h"
-#include "ldap.h"
-#include "ldap-private.h"
-#include "ldap-int.h"
-
-
-int ldap_create_virtuallist_control(LDAP *ld, LDAPVirtualList *ldvlistp,
- LDAPControl **ctrlp)
-{
- BerElement *ber;
- int rc;
-
- if (NULL == ld)
- return (LDAP_PARAM_ERROR);
-
- if (NULL == ctrlp || NULL == ldvlistp)
- return (LDAP_PARAM_ERROR);
-
- if ((ber = alloc_ber_with_options(ld)) == NULLBER) {
- ld->ld_errno = LDAP_NO_MEMORY;
- return (LDAP_NO_MEMORY);
- }
-
- if (ber_printf(ber, "{ii", ldvlistp->ldvlist_before_count,
- ldvlistp->ldvlist_after_count) == -1) {
- ld->ld_errno = LDAP_ENCODING_ERROR;
- ber_free(ber, 1);
- return (LDAP_ENCODING_ERROR);
- }
-
- if (NULL == ldvlistp->ldvlist_attrvalue) {
- if (ber_printf(ber, "t{ii}}", LDAP_TAG_VLV_BY_INDEX,
- ldvlistp->ldvlist_index,
- ldvlistp->ldvlist_size) == -1) {
- ld->ld_errno = LDAP_ENCODING_ERROR;
- ber_free(ber, 1);
- return (LDAP_ENCODING_ERROR);
- }
- } else {
- if (ber_printf(ber, "to}", LDAP_TAG_VLV_BY_VALUE,
- ldvlistp->ldvlist_attrvalue,
- strlen(ldvlistp->ldvlist_attrvalue)) == -1) {
- ld->ld_errno = LDAP_ENCODING_ERROR;
- ber_free(ber, 1);
- return (LDAP_ENCODING_ERROR);
- }
- }
-
- rc = ldap_build_control(LDAP_CONTROL_VLVREQUEST, ber, 1, 1, ctrlp);
- ld->ld_errno = rc;
- return (rc);
-}
-
-
-int ldap_parse_virtuallist_control(LDAP *ld, LDAPControl **ctrls,
- unsigned long *target_posp, unsigned long *list_sizep, int *errcodep)
-{
- BerElement *ber;
- int i, foundListControl;
- LDAPControl *listCtrlp;
-
- if (NULL == ld)
- return (LDAP_PARAM_ERROR);
-
- /* only ldapv3 or higher can do virtual lists. */
- if (ld->ld_version != LDAP_VERSION3) {
- ld->ld_errno = LDAP_NOT_SUPPORTED;
- return (LDAP_NOT_SUPPORTED);
- }
-
- /* find the listControl in the list of controls if it exists */
- if (ctrls == NULL) {
- ld->ld_errno = LDAP_NOT_SUPPORTED;
- return (LDAP_NOT_SUPPORTED);
- }
-
- foundListControl = 0;
- for (i = 0; ((ctrls[i] != NULL) && (!foundListControl)); i++) {
- foundListControl = !(strcmp(ctrls[i]->ldctl_oid,
- LDAP_CONTROL_VLVRESPONSE));
- }
- if (!foundListControl) {
- ld->ld_errno = LDAP_CONTROL_NOT_FOUND;
- return (LDAP_CONTROL_NOT_FOUND);
- } else {
- /* let local var point to the listControl */
- listCtrlp = ctrls[i-1];
- }
-
- /* allocate a Ber element with the contents of the list_control's */
- /* struct berval */
- if ((ber = ber_init(&listCtrlp->ldctl_value)) == NULL) {
- ld->ld_errno = LDAP_NO_MEMORY;
- return (LDAP_NO_MEMORY);
- }
-
- /* decode the result from the Berelement */
- if (LBER_ERROR == ber_scanf(ber, "{iie}", target_posp, list_sizep,
- errcodep)) {
- ld->ld_errno = LDAP_DECODING_ERROR;
- ber_free(ber, 1);
- return (LDAP_DECODING_ERROR);
- }
-
- /* the ber encoding is no longer needed */
- ber_free(ber, 1);
-
- return (LDAP_SUCCESS);
-}
diff --git a/usr/src/lib/libldap4/include/avl.h b/usr/src/lib/libldap4/include/avl.h
deleted file mode 100644
index b7487c5d61..0000000000
--- a/usr/src/lib/libldap4/include/avl.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- *
- * Portions Copyright 1998 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- *
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/* avl.h - avl tree definitions */
-/*
- * Copyright (c) 1993 Regents of the University of Michigan.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms are permitted
- * provided that this notice is preserved and that due credit is given
- * to the University of Michigan at Ann Arbor. The name of the University
- * may not be used to endorse or promote products derived from this
- * software without specific prior written permission. This software
- * is provided ``as is'' without express or implied warranty.
- */
-
-
-#ifndef _AVL
-#define _AVL
-
-/*
- * this structure represents a generic avl tree node.
- */
-
-typedef struct avlnode {
- caddr_t avl_data;
- char avl_bf;
- struct avlnode *avl_left;
- struct avlnode *avl_right;
-} Avlnode;
-
-#define NULLAVL ((Avlnode *) NULL)
-
-/* balance factor values */
-#define LH -1
-#define EH 0
-#define RH 1
-
-/* avl routines */
-#define avl_getone(x) (x == 0 ? 0 : (x)->avl_data)
-#define avl_onenode(x) (x == 0 || ((x)->avl_left == 0 && (x)->avl_right == 0))
-extern int avl_insert();
-extern caddr_t avl_delete();
-extern caddr_t avl_find();
-extern caddr_t avl_getfirst();
-extern caddr_t avl_getnext();
-extern int avl_dup_error();
-extern int avl_apply();
-
-/* apply traversal types */
-#define AVL_PREORDER 1
-#define AVL_INORDER 2
-#define AVL_POSTORDER 3
-/* what apply returns if it ran out of nodes */
-#define AVL_NOMORE -6
-
-typedef int (*IFP)();
-
-#endif /* _AVL */
diff --git a/usr/src/lib/libldap4/include/cdefs.h b/usr/src/lib/libldap4/include/cdefs.h
deleted file mode 100644
index 34b6b955d8..0000000000
--- a/usr/src/lib/libldap4/include/cdefs.h
+++ /dev/null
@@ -1,129 +0,0 @@
-/*
- * Portions Copyright 1998 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*
- * Copyright (c) 1991, 1993
- * The Regents of the University of California. All rights reserved.
- *
- * This code is derived from software contributed to Berkeley by
- * Berkeley Software Design, Inc.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions
- * are met:
- * 1. Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * 2. Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * 3. All advertising materials mentioning features or use of this software
- * must display the following acknowledgement:
- * This product includes software developed by the University of
- * California, Berkeley and its contributors.
- * 4. Neither the name of the University nor the names of its contributors
- * may be used to endorse or promote products derived from this software
- * without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE
- * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
- * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
- * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
- * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
- * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
- * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
- * SUCH DAMAGE.
- *
- * @(#)cdefs.h 8.7 (Berkeley) 1/21/94
- */
-
-#ifndef _CDEFS_H_
-#define _CDEFS_H_
-
-#if defined(__cplusplus)
-#define __BEGIN_DECLS extern "C" {
-#define __END_DECLS };
-#else
-#define __BEGIN_DECLS
-#define __END_DECLS
-#endif
-
-/*
- * The __CONCAT macro is used to concatenate parts of symbol names, e.g.
- * with "#define OLD(foo) __CONCAT(old,foo)", OLD(foo) produces oldfoo.
- * The __CONCAT macro is a bit tricky -- make sure you don't put spaces
- * in between its arguments. __CONCAT can also concatenate double-quoted
- * strings produced by the __STRING macro, but this only works with ANSI C.
- */
-#if defined(__STDC__) || defined(__cplusplus)
-#define __P(protos) protos /* full-blown ANSI C */
-#define __CONCAT(x,y) x ## y
-#define __STRING(x) #x
-
-#define __const const /* define reserved names to standard */
-#define __signed signed
-#define __volatile volatile
-#if defined(__cplusplus)
-#define __inline inline /* convert to C++ keyword */
-#else
-#ifndef __GNUC__
-#define __inline /* delete GCC keyword */
-#endif /* !__GNUC__ */
-#endif /* !__cplusplus */
-
-#else /* !(__STDC__ || __cplusplus) */
-#define __P(protos) () /* traditional C preprocessor */
-#define __CONCAT(x,y) x/**/y
-#define __STRING(x) "x"
-
-#ifndef __GNUC__
-#define __const /* delete pseudo-ANSI C keywords */
-#define __inline
-#define __signed
-#define __volatile
-/*
- * In non-ANSI C environments, new programs will want ANSI-only C keywords
- * deleted from the program and old programs will want them left alone.
- * When using a compiler other than gcc, programs using the ANSI C keywords
- * const, inline etc. as normal identifiers should define -DNO_ANSI_KEYWORDS.
- * When using "gcc -traditional", we assume that this is the intent; if
- * __GNUC__ is defined but __STDC__ is not, we leave the new keywords alone.
- */
-#ifndef NO_ANSI_KEYWORDS
-#define const /* delete ANSI C keywords */
-#define inline
-#define signed
-#define volatile
-#endif
-#endif /* !__GNUC__ */
-#endif /* !(__STDC__ || __cplusplus) */
-
-/*
- * GCC1 and some versions of GCC2 declare dead (non-returning) and
- * pure (no side effects) functions using "volatile" and "const";
- * unfortunately, these then cause warnings under "-ansi -pedantic".
- * GCC2 uses a new, peculiar __attribute__((attrs)) style. All of
- * these work for GNU C++ (modulo a slight glitch in the C++ grammar
- * in the distribution version of 2.5.5).
- */
-#if !defined(__GNUC__) || __GNUC__ < 2 || __GNUC_MINOR__ < 5
-#define __attribute__(x) /* delete __attribute__ if non-gcc or gcc1 */
-#if defined(__GNUC__) && !defined(__STRICT_ANSI__)
-#define __dead __volatile
-#define __pure __const
-#endif
-#endif
-
-/* Delete pseudo-keywords wherever they are not available or needed. */
-#ifndef __dead
-#define __dead
-#define __pure
-#endif
-
-#endif /* !_CDEFS_H_ */
diff --git a/usr/src/lib/libldap4/include/ch_malloc.h b/usr/src/lib/libldap4/include/ch_malloc.h
deleted file mode 100644
index 3f955511b5..0000000000
--- a/usr/src/lib/libldap4/include/ch_malloc.h
+++ /dev/null
@@ -1,12 +0,0 @@
-/*
- * Copyright 1998 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-char * ch_malloc( unsigned long size );
-char * ch_realloc( char *block, unsigned long size );
-char * ch_calloc( unsigned long nelem, unsigned long size );
-char * ch_strdup( char *s1 );
-void ch_free(void *ptr);
diff --git a/usr/src/lib/libldap4/include/charray.h b/usr/src/lib/libldap4/include/charray.h
deleted file mode 100644
index 4ec4088719..0000000000
--- a/usr/src/lib/libldap4/include/charray.h
+++ /dev/null
@@ -1,23 +0,0 @@
-/*
- * Copyright 1998 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-extern void charray_add(char ***a, char *s);
-extern void charray_add_uniq(char ***a, char *s);
-extern void charray_add_case_uniq(char ***a, char *s);
-extern void charray_merge(char ***a, char **s);
-extern void charray_free( char **array );
-extern int charray_inlist( char **a, char *s);
-extern char ** charray_dup( char **a );
-extern int charray_count( char **a);
-extern char ** str2charray( char *str, char *brkstr );
-extern char ** str2charray2( char *str, char *brkstr, int *NbItems );
-extern char * ch_strdup( char *s1 );
-extern void charray_sort(char **a, int (*comp_func)(const char *, const char *));
-extern int charray_pos(char **a, char *s);
-
-
-
diff --git a/usr/src/lib/libldap4/include/client_door.h b/usr/src/lib/libldap4/include/client_door.h
deleted file mode 100644
index e1ac925fa1..0000000000
--- a/usr/src/lib/libldap4/include/client_door.h
+++ /dev/null
@@ -1,15 +0,0 @@
-/*
- *
- * Copyright 1998 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- *
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-extern int connect_dsserv(int pid, int cid, void ** scid,
- struct in_addr * addr);
-extern int disconnect_dsserv(int pid, int cid, void * scid, int reas);
-extern int operation_buf_dsserv(int pid, int cid, void * scid,
- char * buf,int bufsize, char **rbuf, int * rsize);
-extern int operation_fd_dsserv(int pid, int cid, void * scid, int fd);
diff --git a/usr/src/lib/libldap4/include/entry.h b/usr/src/lib/libldap4/include/entry.h
deleted file mode 100644
index 81320b9bd1..0000000000
--- a/usr/src/lib/libldap4/include/entry.h
+++ /dev/null
@@ -1,271 +0,0 @@
-/*
- *
- * Copyright 1998 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- *
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*
- * structs for storing and updating entries
- */
-
-#if !defined(_ENTRY_H_) && !defined(_PROTO_SLAP)
-#define _ENTRY_H_
-
-#ifndef _SLDAPD_H_
-
-/*
- * represents an attribute (type + values + syntax + oid)
- */
-typedef struct attr {
- char *a_type;
- struct berval **a_vals;
- int a_syntax;
- struct attr *a_next;
-} Attribute;
-
-/*
- * the attr_syntax() routine returns one of these values
- * telling what kind of syntax an attribute supports.
- *
- * NOTE: The syntax may not be available in libentry unless you have
- * read the slapd.conf config file.
- */
-#define SYNTAX_CIS 0x01 /* case insensitive string */
-#define SYNTAX_CES 0x02 /* case sensitive string */
-#define SYNTAX_BIN 0x04 /* binary data */
-#define SYNTAX_TEL 0x08 /* telephone number string */
-#define SYNTAX_DN 0x10 /* dn string */
-#define SYNTAX_LONG 0x20 /* integer */
-#define SYNTAX_ULONG 0x40 /* integer */
-#define SYNTAX_CRYPT 0x80 /* crypted password */
-#define SYNTAX_UTCTIME 0x0100 /* Utctime string YYMMDDhhmm[ss]Z */
-#define SYNTAX_GENTIME 0x0200 /* gentime string YYYYMMDDhhmm[ss]Z */
-
-/* These next two are used by libentry. They are overloaded into a_syntax
- * because there's no extra room and we didn't want to enlarge the structure
- * because of the performance hit.
- */
-#define ATTRIBUTE_FOUND 0x1000 /* Set if attribute was found */
-#define ATTRIBUTE_ADD 0x2000 /* Set if values are to be added instead of replaced */
-
-#define DEFAULT_SYNTAX SYNTAX_CIS
-
-typedef struct asyntaxinfo {
- char **asi_names;
- char *asi_oid;
- int asi_options;
-#define ATTR_OPT_SINGLE 0x01 /* Single Valued attr */
-#define ATTR_OPT_OPERATIONAL 0x02 /* Operational attr */
-#define ATTR_OPT_NAMING 0x10 /* Naming Attribute */
- char *asi_default_oc;
- int asi_maxlen;
- int asi_syntax;
-} AttrSyntaxInfo;
-
-/*
- * the id used in the indexes to refer to an entry
- */
-typedef unsigned int ID;
-#define NOID ((unsigned int)-1)
-
-/*
- * represents an entry in core
- */
-typedef struct entry {
- char *e_dn; /* DN of this entry */
- Attribute *e_attrs; /* list of attributes + values */
-
- ID e_id; /* not used in libentry */
- char e_state; /* only ENTRY_FOUND is used below */
-#define ENTRY_STATE_DELETED 0x01 /* value not used in libentry */
-#define ENTRY_STATE_CREATING 0x02 /* value not used in libentry */
- int e_refcnt; /* # threads ref'ing this entry */
- pthread_mutex_t e_mutex; /* to lock for add/modify */
- struct entry *e_lrunext;
- struct entry *e_lruprev; /* not used in libentry, (could be added) */
-} Entry;
-
-/* This next #define is used by libentry. It is overloaded into e_state.
- * It is used to mark entries as found/not found so that they can be deleted
- * if they are not found (for example on a remote replica).
- */
-#define ENTRY_FOUND 0x80
-
-#endif _SLDAPD_H_
-
-/* entry.c */
-
-/* output_ldif takes a modlist structure and prints out ldif. Since there are 3 ways
- * you can use a modlist structure, you need to tell this routine what you're doing.
- * The three choices are:
- * LDAP_MODIFY_ENTRY
- * LDAP_ADD_ENTRY
- * LDAP_DELETE_ENTRY
- * ldif suitable for feeding to ldapmodify will be produced.
- */
-
-/* op arg to output_ldif() */
-#define LDAP_MODIFY_ENTRY 1
-#define LDAP_ADD_ENTRY 2
-#define LDAP_DELETE_ENTRY 3
-
-void output_ldif(char *dn, int op, LDAPMod **modlist, FILE *out);
-
-/* Checks that base exist. If not, create it.
- * ld - ldap context, you must supply it because it's used in ldap_search
- * out - file to output ldif to. If supplied, ldif will be printed here,
- * if not supplied, ldap_mod will be called for you (using ld).
- *
- * returns number of entries created if all is ok, -1 if an error occured.
- *
- * mutex locks: if you are outputting to out from other threads, you need
- * to lock output_mutex. output_ldif locks this mutex before outputting.
- */
-
-int make_base(LDAP *ld, FILE *out, char *base);
-
-/* Add an entry to ldap. You supply an Entry struct. Will either add entry
- * to ldap or output ldif to an open file (stdout for example).
- *
- * ld - ldap context. Must be valid if you want entry_add to add entries to ldap
- * for you.
- * out - open file where to send ldif output. One of ld or out should be valid.
- * new_entry is an Entry which you want added to ldap
- *
- * returns number of entries created or -1 if an error occured in ldap_add()
- */
-
-int entry_add(LDAP *ld, FILE *out, Entry *new_entry);
-
-/* Compares two entries and issue changes to make old look like new.
- *
- * ld - ldap context. Must be valid if you want entry_update to add entries to ldap
- * for you.
- * out - open file where to send ldif output. One of ld or out should be valid.
- * new_entry is an Entry which you want old_entry to look like
- *
- * returns number of entries modified or -1 if an error occured in ldap_modify()
- */
-
-int entry_update(LDAP *ld, FILE *out, Entry *old_entry, Entry *new_entry);
-
-/* Deletes an entry.
- * ld - ldap context. Must be valid if you want delete_entry to call ldap
- * for you.
- * out - open file where to send ldif output. One of ld or out should be valid.
- * ldap_entry is an Entry which you want to delete
- *
- * returns number of entries deleted or -1 if an error occured in ldap_modify()
- * usually one, but for future it might delete more than one.
- */
-
-int entry_delete(LDAP *ld, FILE *out, Entry *ldap_entry);
-
-/* attr.c */
-void attr_free( Attribute *a );
-int attr_merge_fast(
- Entry *e,
- char *type,
- struct berval **vals,
- int nvals,
- int naddvals,
- int *maxvals,
- Attribute ***a
-);
-int attr_merge(
- Entry *e,
- char *type,
- struct berval **vals
-);
-
-Attribute *attr_find(
- Attribute *a,
- char *type,
- int ignoreOpt
-);
-int attr_delete(
- Attribute **attrs,
- char *type
-);
-int attr_syntax( char *type );
-int attr_syntax_by_oid( char *oid );
-void attr_syntax_config(
- char *fname,
- int lineno,
- int argc,
- char **argv
-);
-char * attr_normalize( char *s );
-char * alias_normalize( char *s );
-int type_compare(char * t1, char *t2);
-int type_list_compare(
- char **a,
- char *s
-);
-
-int attr_cmp(Attribute *attr1, Attribute *attr2);
-char * get_type_from_list(char **a, char *s);
-int attr_single_valued_check(char *type, struct berval **vals);
-AttrSyntaxInfo *get_attrSyntaxInfo(char *type);
-char * attr_syntax2oid(int aSyntax);
-
-/* value.c */
-int value_add_fast(
- struct berval ***vals,
- struct berval **addvals,
- int nvals,
- int naddvals,
- int *maxvals
-);
-int value_delete(
- struct berval ***vals,
- struct berval *v,
- int syntax,
- int normalize
-);
-int value_add_one(
- struct berval ***vals,
- struct berval *v,
- int syntax,
- int normalize
-);
-time_t utc2seconds(char * utctime);
-int value_add(
- struct berval ***vals,
- struct berval **addvals
-);
-void value_normalize(
- char *s,
- int syntax
-);
-int value_cmp(
- struct berval *v1,
- struct berval *v2,
- int syntax,
- int normalize /* 1 => arg 1; 2 => arg 2; 3 => both */
-);
-int value_ncmp(
- struct berval *v1,
- struct berval *v2,
- int syntax,
- int len,
- int normalize
-);
-int value_find(
- struct berval **vals,
- struct berval *v,
- int syntax,
- int normalize
-);
-int value_cnt(struct berval **vals);
-
-/* dn.c */
-char *dn_normalize( char *dn );
-char *dn_normalize_case( char *dn );
-int dn_issuffix(char *dn, char *suffix);
-char *dn_upcase( char *dn );
-
-#endif _ENTRY_H_
diff --git a/usr/src/lib/libldap4/include/fe.h b/usr/src/lib/libldap4/include/fe.h
deleted file mode 100644
index 1842a77352..0000000000
--- a/usr/src/lib/libldap4/include/fe.h
+++ /dev/null
@@ -1,420 +0,0 @@
-/*
- *
- * Copyright 1999 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- *
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#ifndef _FE_H
-#define _FE_H
-
-/*
- * Get context const . Used to retreive info in context : fe_get_ctx
- * Return values depend on requested info :
- */
-#define CTX_FENAME 1 /* To get the Front End name */
- /* return value is (char *) */
-#define CTX_NBTABLE 2 /* To get the number of sub-section */
- /* return value is (int *) */
-#define CTX_TABLENAME 3 /* To get name(s) of sub section */
- /* return value is (char **) */
-#define CTX_TABLEPTR 4 /* To get the ptr to a sub section definition */
- /* return value is (FE_Table *) */
- /* !! This is not a copy */
-#define CTX_CUSTOMS 5 /* get customs attributes */
- /* third parameter is the variable name (char *) */
-
-/*
- * Get Tables const
- */
-#define TABLE_NAME 1 /* table or subsection name, return value is (char *) */
- /* third parms is null */
-#define TABLE_OBJ_LST 2 /* object class list, return value is (char **) */
- /* third parms is null */
-#define TABLE_COM_HLD 3 /* stored ldap, connection return value is (LDAP *) */
-#define TABLE_CUSTOMS 4 /* get customs attributes */
- /* third parameter is the variable name (char *) */
- /* return value is an array of string (char **) */
-#define TABLE_FEATTR 5 /* to get the attribute definition. If no attribute name */
- /* is provided to get the list of attributes */
- /* third parms is the attribute name */
- /* return a FE_Attr * if attribute name provided */
- /* return a char ** (null term) if no attribute name provided */
-
-#define TABLE_SUNDSATTR 6 /* idem TABLE_FEATTR but for SunDS definition */
-
-/*
- * Tokens/Attributes
- */
-#define FETABLE 0
-#define SUNDSTABLE 1
-#define SUNDSATTRLIST 2
-#define SUNDSTOKENLIST 3
-#define FEATTRLIST 4
-#define FETOKENLIST 5
-#define FEBUILDLIST 6
-#define SUNDSBUILDLIST 7
-
-/*
- * Errors consts
- */
-#define NOERROR 0
-#define INVALID_PARMS 1
-#define VALUE_NOT_FOUND 2
-#define CREATE_FAILED 3
-#define SYNTAX_ERROR 4
-
-/*
- * SPLIT way
- */
-#define LEFT2RIGHT 0
-#define RIGHT2LEFT 1
-/*
- * Data structures
- */
-
-/*
- * This struct is used to run regex with "reg_expression"
- * and assigned values (braelist) with "token" links
- * Functional schema :
- * step(input,reg_expression)
- * => token[0] = braslist[0]..braelist[0]
- * => token[1] = braslist[1]..braelist[1]
- * => ...
- * => token[i] = braslist[i]..braelist[i]
- */
-typedef struct _reg_mapp {
- char *reg_expression; /* Compiled regular expression */
- int Nbra; /* nbra result */
- int NbToken_Defined; /* Nb tokens defined in reg_expression */
- int *Token_ID; /* Tokens place (index) in input value */
-} Reg_Map;
-
-/*
- * Tokens definition, including input attribute and number of expressions
- * and link to each rule.
- */
-typedef struct _tokens_def {
- int attr_ID; /* Attributes ID (in SD or FE Table) */
- /* Used as input in regular expression */
- int NbRules; /* Number of expressions seperated by | */
- Reg_Map **TokenRules; /* Array of tokens rules */
-} Token_Def;
-
-/*
- * Attribute mapping definition. SD attributes are composed of FE attributes and
- * SD tokens.
- */
-typedef struct _attr_mapping {
- char *AttrName; /* Attribute Name */
- char *Expr; /* Value expression */
- int AttrStatus; /* Store several attr's info such as */
- /* Key || Exist || Frozen */
- /* Key is used to generate wizard filter */
- /* Exist is used to generate wizard filter */
- /* Frozen is used control access on attribute */
- int NbItem; /* Nb Attributes & Tokens need to build val */
- int *AttrID; /* Set of attributes including tokens */
-} Attr_Mapping;
-
-/*
- * Builder_map : defined builder expression
- */
-typedef struct _builder_map {
- char *build_exp; /* the sentence to build */
- int NbInput;
- int *Input_ID; /* List of attr ID to used as input in semtence */
-}Builder_map;
-
-/*
- * Data used for split/string2instances/instances2string/exclude functions
- */
-typedef struct _builder_fct {
- int Input_ID;
- char *value; /* input data */
- char *prefix; /* string2instances and reverse : prefix */
- /* exclude : val 2 exclude */
- int Parm_ID; /* only for exclude funct : ID of val 2 exclude */
- char *suffix;
- char *separator;
- int readIndicator;
-} Builder_fct;
-
-/*
- * Builder tokens : used to build special value (named builder token) from other tokens
- * or input value. They look like ouput attributes, but they allow to apply rules, if
- * input value does exist. They also permit to split input sentence into attribute instances
- */
-typedef struct _builder {
- char *builder_name;
- int builder_ID;
- int NbRules;
- int BuilderType;
- Builder_map *Mapp;
- Builder_fct *Fct;
-} Build_def;
-
-
-/*
- * Full definition of table mapping.
- */
-typedef struct _table_mapping {
- int NbTokens; /* Nb extract tokens defined */
- int NbAttributes; /* Nb attributes in the entry */
- int NbBuilder; /* Nb builder tokens defined */
- Token_Def **Tokens_list; /* Array of tokens needed for translation */
- Build_def *Build_list; /* Array of builder tokens */
- Attr_Mapping **Attr_list; /* Array of Attributes defined in an entry */
-} Table_Mapping;
-
-typedef struct _custo_info {
- char *InfoName;
- int NbValues;
- char **Values; /* Null terminated array of instance */
-} Cust_Info;
-
-typedef struct _sds_com {
- LDAP *lhd; /* LDAP communication handle */
- char **fe_object_list; /* Array of ObjectClasses (null term list) */
-} SDS_Com;
-
-typedef struct _dynrule {
- char *ResName; /* Result (or Rule) name */
- int opType; /* Extrac, Cond, split, str2ins, ins2str, */
- /* getrdn, exclude */
- int NbExpr; /* Nb rules found use only in extract & cond */
- int *NbItems; /* Nb variable in expression, usefull for */
- /* extract and cond. IT's a null terminated */
- /* array which contains the Number of var in */
- char **Expression; /* The sentence (make sense only in cond) */
- char **ConstVal; /* use when funct parm are const not used for */
- /* extract and cond cases */
- char **VarName; /* Var can be 1)DynRule 2)InputData 3)Common */
-} DynRule;
-
-typedef struct _fe_table {
- char *fe_section; /* Section table name */
- int nb_fe_attr; /* Nb FE attributes defined */
- int nb_sds_attr; /* Nb SDS attributes defined */
- int nb_fe_tokens; /* Nb tokens defined in FE section */
- int nb_sds_tokens; /* Nb tokens defined in SunDS section */
- int nb_cust; /* Nb custom attributes in common section */
- int nb_fe_build; /* Nb tokens build in FE section */
- int nb_sds_build; /* Nb tokens build in SUNDS section */
- int nb_dyn_rules; /* Nb dynamic rules in Dynamic section */
- char **fe_token_list; /* Array of FE token */
- char **sds_token_list; /* List of SunDS token */
- char **fe_attr_list; /* Array of attributes (null term list) */
- char **sds_attr_list; /* Array of attributes (null term list) */
- char **fe_build_list; /* Array of FE build */
- char **sds_build_list; /* List of SunDS build */
- Table_Mapping *sds_schema; /* SDS attributes definition */
- Table_Mapping *fe_schema; /* FE attributes definition */
- SDS_Com *comm_items; /* Communication attributes */
- Cust_Info **custo_info; /* Customs info */
- DynRule *dyn_rules; /* Ordered dynamic rules */
-} FE_Table;
-
-typedef struct _fe_context {
- char *fe_name; /* Is it really usefull ?? */
- int NbSection; /* Nb section */
- int NbGlobals; /* Nb global customs info */
- Cust_Info **globals; /* Customs info */
- FE_Table **fe_section_list; /* All sub-section in mapping file */
-} FE_Context;
-
-/* Entries values definition */
-/* Instance values definition */
-typedef struct _fe_values {
- int Length;
- void *Val;
-} FE_Values;
-
-/* Attribute value definition */
-typedef struct _fe_attr {
- char *AttrType;
- int NbInstance;
- FE_Values **ValInstances;
-} FE_Attr;
-
-/* Full entry definition */
-typedef struct _fe_entry {
- char *DN;
- int Nb_items;
- FE_Attr **AttributesArray;
-} FE_Entry;
-
-typedef struct _fe_couple {
- char *Value2Subst;
- char *SubstValue;
-} FE_Couple;
-
-/*
- * libfe.a exported functions
- */
-
-/*
- * Read config file and create "fe_name" context
- * NB : This init read all tables mapping
- * libldap context use : before all action
- */
-extern FE_Context *fe_ctx_init(char *config_path, char *fe_name);
-
-/*
- * Free All fe context all tables ...
- * libldap context usage : ldap_close
- */
-extern int fe_ctx_free(FE_Context **Ctx);
-
-/*
- * Return the pointer to requested item in context
- * libldap context usage : before all action
- */
-extern void *fe_ctx_get(FE_Context *Ctx, int FieldID, void *Value);
-
-/*
- * Search for information from Subsection/Table ?
- * You can check also Get/Table/Paragraph
- * libldap context usage : ldap_*
- */
-extern void *fe_table_get(FE_Table *MapTable, int FieldID, void *Void);
-
-/*
- * Set tables item is mainly used for communication items. other information
- * sets will be forbid
- * libldap context usage : after ldap_open or ldap_bind
- */
-/*
-extern int fe_table_set(FE_Table *MapTable, int FieldID, void *Void);
-*/
-/*
- * You have the attribute name ?! fe_ent_get_attr returns pointer to the requested
- * attributes with instances, status... from a specific entry
- * libldap context usage : after ldap_search
- */
-extern FE_Attr *fe_ent_get_attr(FE_Table *MapTable, FE_Entry *fe_item, char *AttrName);
-
-/*
- * Create the entry according to the "schema" defined in mapping file for a specific table
- * libladp context usage : before ldap_add
- */
-extern FE_Entry *fe_ent_create(FE_Table *MapTable, int TableType);
-
-/*
- * Add new attributes in a new entry
- * libladp context usage : before ldap_add
- */
-extern FE_Attr *fe_ent_get_attr(FE_Table *MapTable,FE_Entry *Entry, char *AttrName);
-
-/*
- * Add new instance value
- * libladp context usage : before ldap_add
- */
-extern int fe_ent_add_val(FE_Table *MapTable, FE_Attr *attr, int ValLength, void *Val);
-extern FE_Attr *fe_ent_add_attr_val(FE_Table *MapTable, FE_Entry *Entry, char *AttrName, int ValLength, void *Val);
-
-/*
- * explode DN into an attributes array
- * libladp context usage : after ldap_search
- */
-extern FE_Attr **fe_ent_show_dn(FE_Table *MapTable, FE_Entry *Entry);
-
-/*
- * free entry (including attributes)
- */
-extern void fe_ent_free(FE_Entry **Entry);
-
-/*
- * Substitute all vars defined in inputString (with syntax ${varName}) by values found in
- * fe_couple array. For errors returned check the errors consts upper
- */
-extern int fe_subst(char *inputString, char **outputString, FE_Couple **fe_couple);
-
-/*
- * Split a sentence, add prefix (for each token) and suffix (exept for the last)
- */
-extern char *fe_split(char *inputData, char *Separator, char *Prefix, char *Suffix, int way );
-
-/*
- * Dynamic translation, use only definition in dynamic section
- */
-extern char **fe_dynamic(FE_Table *MapTable, char *Var2stop, char **DynVal);
-
-/*
- * Return the translated attribute. TableType is the original table of AttrName.
- * if translation rules is one to one translation, the function return a copy of translated
- * attribute name.
- * else the function return a copy of the rules
- */
-extern char **fe_trans_attrName(FE_Table *MapTable, char *AttrName, int TableType);
-extern int *fe_trans_attrID(FE_Table *MapTable, char *AttrName, int TableType);
-
-/*
- * Return the translated SD entry
- * libladp context usage : after ldap_search
- */
-extern FE_Entry *fe_trans_all_sds2fe(FE_Table *MapTable, LDAP *ld, LDAPMessage *sd_entry);
-
-/*
- * Return the translated FE entry
- * libladp context usage : after ldap_search
- */
-extern LDAPMod **fe_trans_all_fe2sds(FE_Table *MapTable, LDAP *ld, FE_Entry *fe_entry);
-
-/*
- * Close to "fe_trans_all_sds2fe" but output is Entry pointer as defined in SunDS server
- */
-extern FE_Entry *fe_trans_all_sunds2fe(FE_Table *MapTable, Entry *sd_entry);
-extern Entry *fe_trans_all_fe2sunds(FE_Table *MapTable, FE_Entry *fe_entry);
-
-/* An example an example ....
- * Translation from fe to sunds
- *
- * FE_Context *MyContext = NULL;
- * FE_Table *HostTable = NULL;
- * FE_Entry *fe_entry = NULL;
- * FE_Attr *fe_attr = NULL;
- * Entry *lentry = NULL;
- *
- * if((MyContext = fe_ctx_init("..../sunds_map.conf","NIS")) == NULL){
- * ldaplog(LDAP_DEBUG_CONFIG,"Can't load mapping file\n", 0, 0, 0);
- * exit(1);
- * }
- * if((HostTable = fe_ctx_get(MyContext,CTX_TABLEPTR,"dummy")) == NULL)
- * {
- * ldaplog(LDAP_DEBUG_CONFIG,"Can't retreive HOSTS table\n", 0, 0, 0);
- * exit(1);
- * }
- * if((fe_entry = fe_ent_create(HostTable, FETABLE))==NULL)
- * {
- * ldaplog(LDAP_DEBUG_CONFIG,"Can't create entry\n", 0, 0, 0);
- * exit(1);
- * }
- * if ((fe_attr = fe_ent_add_attr_val(HostTable, fe_entry, "niskey", 16, "109.107.179.131")) == NULL)
- * {
- * ldaplog(LDAP_DEBUG_CONFIG,"Can't add attr=%s, val=%s\n", "niskey", "109.107.179.131", 0);
- * exit(1);
- * }
- * if((fe_attr = fe_ent_add_attr_val(HostTable,
- * fe_entry,
- * "NISVALUE",
- * strlen("olivaw OLIVAW oLiVaW # regis Host") +1,
- * "olivaw OLIVAW oLiVaW # regis Host")) == NULL)
- * {
- * ldaplog(...);
- * exit(1);
- * }
- * if((lentry = fe_trans_all_fe2sunds(HostTable, fe_entry)) ==NULL)
- * {
- * ldaplog(LDAP_DEBUG_CONFIG,".... \n", 0);
- * }
- *
- */
-
-#endif /* _FE_H */
-
-
-
-
diff --git a/usr/src/lib/libldap4/include/hsearch.h b/usr/src/lib/libldap4/include/hsearch.h
deleted file mode 100644
index 32721aedca..0000000000
--- a/usr/src/lib/libldap4/include/hsearch.h
+++ /dev/null
@@ -1,53 +0,0 @@
-/*
- * Copyright 1998 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#include <sys/types.h>
-
-#ident "@(#)hsearch.h 1.3 07/23/97 SMI"
-typedef struct { /* Hash table entry */
- char * key;
- char * data;
- int dsize;
- int modified;
- time_t timestamp;
-} HASH_ENTRY;
-
-typedef struct node { /* Part of the linked list of entries */
- HASH_ENTRY item;
- struct node *next;
-} NODE;
-
-typedef enum {
- FIND, /* Find, if present */
- ENTER, /* Find; enter if not present */
- REPLACE, /* replace */
- DELETE, /* delete */
-} ACTION;
-
-/* define everything that a hash table needs to drag around */
-typedef struct hash_table {
- NODE **table; /* The address of the hash table */
- unsigned int length; /* Size of the hash table */
- unsigned int m; /* Log base 2 of length */
- unsigned int count; /* nb entries in the hash table */
- mutex_t table_lock; /* currently not used */
- int alloc_data; /* true if data is allocated and copied in the hast table */
- int clean; /* to force cleanup of the hash table */
- int size; /* Max size of the hast table, defaulted 5000 */
-} HASH_TABLE;
-
-void hdestroy_s(HASH_TABLE **hash_table);
-HASH_ENTRY *hsearch_s(HASH_TABLE *hash_table, HASH_ENTRY item, ACTION action);
-HASH_ENTRY *hlist_s(HASH_TABLE *hash_table, int * i, NODE ** a);
-HASH_TABLE *hcreate_s(size_t size, int alloc_data);
-
-/* convenience functions for adding and find things */
-int hadd_s(HASH_TABLE **hash_table, char *key, void *data, int size);
-int hreplace_s(HASH_TABLE **hash_table, char *key, void *data, int size);
-char *hfind_s(HASH_TABLE *hash_table, char *key);
-int hdelete_s( HASH_TABLE *hash_table, char * key);
diff --git a/usr/src/lib/libldap4/include/lber.h b/usr/src/lib/libldap4/include/lber.h
deleted file mode 100644
index 094c04ab8b..0000000000
--- a/usr/src/lib/libldap4/include/lber.h
+++ /dev/null
@@ -1,240 +0,0 @@
-/*
- * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-/*
- * Copyright (c) 1990 Regents of the University of Michigan.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms are permitted
- * provided that this notice is preserved and that due credit is given
- * to the University of Michigan at Ann Arbor. The name of the University
- * may not be used to endorse or promote products derived from this
- * software without specific prior written permission. This software
- * is provided ``as is'' without express or implied warranty.
- */
-
-#ifndef _LBER_H
-#define _LBER_H
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#if !defined(NEEDPROTOS) && defined(__STDC__)
-#define NEEDPROTOS 1
-#endif
-
-/* BER classes and mask */
-#define LBER_CLASS_UNIVERSAL 0x00
-#define LBER_CLASS_APPLICATION 0x40
-#define LBER_CLASS_CONTEXT 0x80
-#define LBER_CLASS_PRIVATE 0xc0
-#define LBER_CLASS_MASK 0xc0
-
-/* BER encoding type and mask */
-#define LBER_PRIMITIVE 0x00
-#define LBER_CONSTRUCTED 0x20
-#define LBER_ENCODING_MASK 0x20
-
-#define LBER_BIG_TAG_MASK 0x1f
-#define LBER_MORE_TAG_MASK 0x80
-
-/*
- * Note that LBER_ERROR and LBER_DEFAULT are values that can never appear
- * as valid BER tags, and so it is safe to use them to report errors. In
- * fact, any tag for which the following is true is invalid:
- * (( tag & 0x00000080 ) != 0 ) && (( tag & 0xFFFFFF00 ) != 0 )
- */
-#define LBER_ERROR 0xffffffff
-#define LBER_DEFAULT 0xffffffff
-
-/* general BER types we know about */
-#define LBER_BOOLEAN 0x01
-#define LBER_INTEGER 0x02
-#define LBER_BITSTRING 0x03
-#define LBER_OCTETSTRING 0x04
-#define LBER_NULL 0x05
-#define LBER_ENUMERATED 0x0a
-#define LBER_SEQUENCE 0x30 /* constructed */
-#define LBER_SET 0x31 /* constructed */
-
-#define OLD_LBER_SEQUENCE 0x10 /* w/o constructed bit - broken */
-#define OLD_LBER_SET 0x11 /* w/o constructed bit - broken */
-
-#ifdef NEEDPROTOS
-typedef int (*BERTranslateProc)(char **bufp, unsigned int *buflenp,
- int free_input);
-#else /* NEEDPROTOS */
-typedef int (*BERTranslateProc)();
-#endif /* NEEDPROTOS */
-
-typedef struct berelement BerElement; /* Opaque BerElement structure */
-#define NULLBER ((BerElement *) 0)
-
-#ifdef LDAP_SSL
-#include <security/ssl.h>
-#endif /* LDAP_SSL */
-
-/*
- * Structure Sockbuf which used to be defined in this header file, is
- * removed since the c-api draft does not define the structure and it
- * is only used internal to the library
- */
-
-typedef struct seqorset {
- BerElement *sos_ber;
- unsigned int sos_clen;
- unsigned int sos_tag;
- char *sos_first;
- char *sos_ptr;
- struct seqorset *sos_next;
-} Seqorset;
-#define NULLSEQORSET ((Seqorset *) 0)
-
-typedef unsigned int ber_len_t; /* for BER len */
-typedef unsigned int ber_tag_t; /* for BER tags */
-typedef int ber_int_t; /* for BER ints, enums, and Booleans */
-typedef unsigned int ber_uint_t; /* unsigned equivalent of ber_int_t */
-typedef int ber_slen_t; /* signed equivalent of ber_len_t */
-
-/* structure for returning a sequence of octet strings + length */
-typedef struct berval {
- ber_len_t bv_len;
- char *bv_val;
-} BerValue;
-
-#ifndef NEEDPROTOS
-extern BerElement *ber_alloc();
-extern BerElement *der_alloc();
-extern BerElement *ber_alloc_t();
-extern BerElement *ber_dup();
-extern BerElement *ber_init();
-extern int lber_debug;
-extern void ber_bvfree();
-extern void ber_bvecfree();
-extern struct berval *ber_bvdup();
-extern void ber_dump();
-extern void ber_sos_dump();
-extern void lber_bprint();
-extern void ber_reset();
-extern void ber_zero_init();
-#else /* NEEDPROTOS */
-
-/*
- * in bprint.c:
- */
-void lber_bprint(char *data, int len);
-
-/*
- * in decode.c:
- */
-ber_tag_t ber_get_tag(BerElement *ber);
-ber_tag_t ber_skip_tag(BerElement *ber, ber_len_t *len);
-ber_tag_t ber_peek_tag(BerElement *ber, ber_len_t *len);
-unsigned int ber_get_int(BerElement *ber, int *num);
-unsigned int ber_get_stringb(BerElement *ber, char *buf,
- ber_len_t *len);
-unsigned int ber_get_stringa(BerElement *ber, char **buf);
-unsigned int ber_get_stringal(BerElement *ber, struct berval **bv);
-unsigned int ber_get_bitstringa(BerElement *ber, char **buf,
- ber_len_t *len);
-unsigned int ber_get_null(BerElement *ber);
-unsigned int ber_get_boolean(BerElement *ber, int *boolval);
-ber_tag_t ber_first_element(BerElement *ber, ber_len_t *len,
- char **last);
-ber_tag_t ber_next_element(BerElement *ber, ber_len_t *len,
- char *last);
-#if defined(MACOS) || defined(BC31) || defined(_WIN32) || defined(__sun)
-ber_tag_t ber_scanf(BerElement *ber, char *fmt, ...);
-#else
-ber_tag_t ber_scanf();
-#endif
-void ber_bvfree(struct berval *bv);
-void ber_bvecfree(struct berval **bv);
-struct berval *ber_bvdup(struct berval *bv);
-#ifdef STR_TRANSLATION
-void ber_set_string_translators(BerElement *ber,
- BERTranslateProc encode_proc, BERTranslateProc decode_proc);
-#endif /* STR_TRANSLATION */
-int ber_flatten(BerElement *ber, struct berval **bvPtr);
-
-/*
- * in encode.c
- */
-int ber_put_enum(BerElement *ber, int num, ber_tag_t tag);
-int ber_put_int(BerElement *ber, int num, ber_tag_t tag);
-int ber_put_ostring(BerElement *ber, char *str, ber_len_t len, ber_tag_t tag);
-int ber_put_string(BerElement *ber, char *str, ber_tag_t tag);
-int ber_put_bitstring(BerElement *ber, char *str,
- unsigned int bitlen, ber_tag_t tag);
-int ber_put_null(BerElement *ber, ber_tag_t tag);
-int ber_put_boolean(BerElement *ber, int boolval, ber_tag_t tag);
-int ber_start_seq(BerElement *ber, ber_tag_t tag);
-int ber_start_set(BerElement *ber, ber_tag_t tag);
-int ber_put_seq(BerElement *ber);
-int ber_put_set(BerElement *ber);
-#if defined(MACOS) || defined(BC31) || defined(_WIN32) || defined(__sun)
-int ber_printf(BerElement *ber, char *fmt, ...);
-#else
-int ber_printf();
-#endif
-
-/*
- * in io.c:
- *
- * ber_flush() and ber_get_next() functions are obsolete and removed
- * from this library/header file
- */
-int ber_read(BerElement *ber, char *buf, ber_len_t len);
-int ber_write(BerElement *ber, char *buf, ber_len_t len, int nosos);
-void ber_free(BerElement *ber, int freebuf);
-BerElement *ber_alloc(void);
-BerElement *der_alloc(void);
-BerElement *ber_alloc_t(int options);
-BerElement *ber_dup(BerElement *ber);
-BerElement *ber_init(struct berval *bv);
-void ber_dump(BerElement *ber, int inout);
-void ber_sos_dump(Seqorset *sos);
-void ber_zero_init(BerElement *ber, int options);
-void ber_reset(BerElement *ber, int was_writing);
-
-#ifdef NEEDGETOPT
-/*
- * in getopt.c
- */
-int getopt(int nargc, char **nargv, char *ostr);
-#endif /* NEEDGETOPT */
-#endif /* NEEDPROTOS */
-
-#define LBER_HTONL(l) htonl(l)
-#define LBER_NTOHL(l) ntohl(l)
-
-/*
- * SAFEMEMCPY is an overlap-safe copy from s to d of n bytes
- */
-#ifdef sunos4
-#define SAFEMEMCPY(d, s, n) bcopy(s, d, n)
-#else /* sunos4 */
-#define SAFEMEMCPY(d, s, n) memmove(d, s, n)
-#endif /* sunos4 */
-
-#ifdef SUN
-
-/* I18N support */
-#include <locale.h>
-#include <nl_types.h>
-
-extern nl_catd slapdcat; /* for I18N support */
-extern void i18n_catopen(char *);
-
-#endif
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _LBER_H */
diff --git a/usr/src/lib/libldap4/include/ldap-int.h b/usr/src/lib/libldap4/include/ldap-int.h
deleted file mode 100644
index 12454463cb..0000000000
--- a/usr/src/lib/libldap4/include/ldap-int.h
+++ /dev/null
@@ -1,343 +0,0 @@
-/*
- * Copyright 1995-2002 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*
- * Copyright (c) 1995 Regents of the University of Michigan.
- * All rights reserved.
- *
- * ldap-int.h - defines & prototypes internal to the LDAP library
- */
-
-#include <stdlib.h> /* rri */
-#include <pthread.h> /* rri */
-#include <netinet/in.h>
-
-#define LDAP_URL_PREFIX "ldap://"
-#define LDAP_URL_PREFIX_LEN 7
-#define LDAP_URL_URLCOLON "URL:"
-#define LDAP_URL_URLCOLON_LEN 4
-
-#ifdef LDAP_REFERRALS
-#define LDAP_REF_STR "Referral:\n"
-#define LDAP_REF_STR_LEN 10
-#define LDAP_LDAP_REF_STR LDAP_URL_PREFIX
-#define LDAP_LDAP_REF_STR_LEN LDAP_URL_PREFIX_LEN
-#ifdef LDAP_DNS
-#define LDAP_DX_REF_STR "dx://"
-#define LDAP_DX_REF_STR_LEN 5
-#endif /* LDAP_DNS */
-#endif /* LDAP_REFERRALS */
-
-
-/*
- * in cache.c
- */
-#ifdef NEEDPROTOS
-void add_request_to_cache( LDAP *ld, unsigned int msgtype,
- BerElement *request );
-void add_result_to_cache( LDAP *ld, LDAPMessage *result );
-int check_cache( LDAP *ld, unsigned int msgtype, BerElement *request );
-#else /* NEEDPROTOS */
-void add_request_to_cache();
-void add_result_to_cache();
-int check_cache();
-#endif /* NEEDPROTOS */
-
-
-#ifdef KERBEROS
-/*
- * in kerberos.c
- */
-#ifdef NEEDPROTOS
-char *get_kerberosv4_credentials( LDAP *ld, char *who, char *service,
- int *len );
-#else /* NEEDPROTOS */
-char *get_kerberosv4_credentials();
-#endif /* NEEDPROTOS */
-
-#endif /* KERBEROS */
-
-/*
- * in notif.c
- */
-int ldap_insert_notif(LDAP *ld, LDAPMessage *notif);
-int ldap_add_notif(LDAP *ld, LDAPMessage *notif);
-
-
-/*
- * in open.c
- */
-int ldap_thr_index(); /* rri */
-#ifdef NEEDPROTOS
-int open_default_ldap_connection(LDAP *ld);
-int open_ldap_connection( LDAP *ld, Sockbuf *sb, char *host, int defport,
- char **krbinstancep, int async );
-#else /* NEEDPROTOS */
-int open_default_ldap_connection();
-int open_ldap_connection();
-#endif /* NEEDPROTOS */
-
-/*
- * in options.c
- */
-
-int ldap_get_option (LDAP *ld, int option, void *outvalue);
-
-/*
- * in os-ip.c
- */
-void close_ldap_connection( Sockbuf *sb ); /* rri */
-#ifdef NEEDPROTOS
-int connect_to_host(Sockbuf *sb, char *host, in_addr_t address, int port,
- int async, int bindTimeout);
-void close_connection( Sockbuf *sb );
-#else /* NEEDPROTOS */
-int connect_to_host();
-void close_connection();
-#endif /* NEEDPROTOS */
-
-#ifdef KERBEROS
-#ifdef NEEDPROTOS
-char *host_connected_to( Sockbuf *sb );
-#else /* NEEDPROTOS */
-char *host_connected_to();
-#endif /* NEEDPROTOS */
-#endif /* KERBEROS */
-
-#ifdef LDAP_REFERRALS
-#ifdef NEEDPROTOS
-int do_ldap_select( LDAP *ld, struct timeval *timeout );
-void *new_select_info( void );
-void free_select_info( void *sip );
-void mark_select_write( LDAP *ld, Sockbuf *sb );
-void mark_select_read( LDAP *ld, Sockbuf *sb );
-void mark_select_clear( LDAP *ld, Sockbuf *sb );
-long is_read_ready( LDAP *ld, Sockbuf *sb );
-long is_write_ready( LDAP *ld, Sockbuf *sb );
-#else /* NEEDPROTOS */
-int do_ldap_select();
-void *new_select_info();
-void free_select_info();
-void mark_select_write();
-void mark_select_read();
-void mark_select_clear();
-long is_read_ready();
-long is_write_ready();
-#endif /* NEEDPROTOS */
-#endif /* LDAP_REFERRALS */
-
-/*
- * in regex.c (rri)
- */
-int re_exec( char *lp );
-
-/*
- * in request.c
- */
-#ifdef NEEDPROTOS
-int send_initial_request( LDAP *ld, unsigned int msgtype,
- char *dn, BerElement *ber );
-BerElement *alloc_ber_with_options( LDAP *ld );
-void set_ber_options( LDAP *ld, BerElement *ber );
-#else /* NEEDPROTOS */
-int send_initial_request();
-BerElement *alloc_ber_with_options();
-void set_ber_options();
-#endif /* NEEDPROTOS */
-
-#if defined( LDAP_REFERRALS ) || defined( LDAP_DNS )
-#ifdef NEEDPROTOS
-int send_server_request( LDAP *ld, BerElement *ber, int msgid,
- LDAPRequest *parentreq, LDAPServer *srvlist, LDAPConn *lc,
- int bind );
-LDAPConn *new_connection( LDAP *ld, LDAPServer **srvlistp, int use_ldsb,
- int connect, int bind );
-LDAPRequest *find_request_by_msgid( LDAP *ld, int msgid );
-void free_request( LDAP *ld, LDAPRequest *lr );
-void free_connection( LDAP *ld, LDAPConn *lc, int force, int unbind );
-void dump_connection( LDAP *ld, LDAPConn *lconns, int all );
-void dump_requests_and_responses( LDAP *ld );
-#else /* NEEDPROTOS */
-int send_server_request();
-LDAPConn *new_connection();
-LDAPRequest *find_request_by_msgid();
-void free_request();
-void free_connection();
-void dump_connection();
-void dump_requests_and_responses();
-#endif /* NEEDPROTOS */
-#endif /* LDAP_REFERRALS || LDAP_DNS */
-
-#ifdef LDAP_REFERRALS
-#ifdef NEEDPROTOS
-int chase_referrals( LDAP *ld, LDAPRequest *lr, char **refs, int *count, int samerequest );
-char ** ldap_errormsg2referrals(char *errmsg);
-char *ldap_referral2error_msg(char ** refs);
-int append_referral( LDAP *ld, char **referralsp, char *s );
-#else /* NEEDPROTOS */
-int chase_referrals();
-char ** ldap_errormsg2referrals();
-char *ldap_referral2error_msg();
-int append_referral();
-#endif /* NEEDPROTOS */
-#endif /* LDAP_REFERRALS */
-
-void nsldapi_connection_lost_nolock( LDAP *ld, Sockbuf *sb );
-
-/*
- * in search.c
- */
-#ifdef NEEDPROTOS
-BerElement *ldap_build_search_req( LDAP *ld, char *base, int scope,
- char *filter, char **attrs, int attrsonly, LDAPControl ** serverctrls,
- struct timeval *timeoutp, int sizelimit );
-#else /* NEEDPROTOS */
-BerElement *ldap_build_search_req();
-#endif /* NEEDPROTOS */
-
-static int put_extensible_filter( BerElement *ber, char *type, char *val );
-
-/*
- * in unbind.c
- */
-#ifdef NEEDPROTOS
-int ldap_ld_free( LDAP *ld, int close );
-int send_unbind( LDAP *ld, Sockbuf *sb );
-#else /* NEEDPROTOS */
-int ldap_ld_free();
-int send_unbind();
-#endif /* NEEDPROTOS */
-
-
-#ifdef LDAP_DNS
-/*
- * in getdxbyname.c
- */
-#ifdef NEEDPROTOS
-char **getdxbyname( char *domain );
-#else /* NEEDPROTOS */
-char **getdxbyname();
-#endif /* NEEDPROTOS */
-#endif /* LDAP_DNS */
-
-/*
- * abandon.c
- */
-#ifdef NEEDPROTOS
-BerElement * ldap_build_abandon_req( LDAP *ld, int msgid, LDAPControl ** serverctrls);
-#else
-BerElement * ldap_build_abandon_req();
-#endif
-
-/* add.c */
-#ifdef NEEDPROTOS
-BerElement * ldap_build_add_req(LDAP *ld, char *dn, LDAPMod **attrs, LDAPControl ** serverctrls);
-#else
-BerElement * ldap_build_add_req();
-#endif
-
-/*
- * compare.c
- */
-#ifdef NEEDPROTOS
-BerElement * ldap_build_compare_req(LDAP *ld, char *dn, char *attr, struct berval *bvalue, LDAPControl **serverctrls);
-#else
-BerElement * ldap_build_compare_req();
-#endif
-
-/*
- * delete.c
- */
-#ifdef NEEDPROTOS
-BerElement * ldap_build_delete_req(LDAP *ld, char *dn, LDAPControl **serverctrls);
-#else
-BerElement * ldap_build_delete_req();
-#endif
-
-/*
- * extop.c
- */
-#ifdef NEEDPROTOS
-BerElement * ldap_build_extended_operation_req(LDAP *ld, char *exoid, struct berval *exdata, LDAPControl ** serverctrls);
-#else
-BerElement * ldap_build_extended_operation_req();
-#endif
-
-/*
- * modify.c
- */
-#ifdef NEEDPROTOS
-BerElement * ldap_build_modify_req(LDAP *ld, char *dn, LDAPMod ** mods, LDAPControl **serverctrls);
-#else
-BerElement * ldap_build_modify_req();
-#endif
-
-/*
- * rename.c
- */
-#ifdef NEEDPROTOS
-BerElement * ldap_build_rename_req ( LDAP *ld, char *dn, char *newrdn, char *newparent, int deleteoldrdn, LDAPControl **serverctrls);
-#else
-BerElement * ldap_build_rename_req ();
-#endif
-
-/*
- * saslbind.c
- */
-#ifdef NEEDPROTOS
-BerElement * ldap_build_sasl_bind_req( LDAP *ld, char *dn, char *mechanism, struct berval *creds, LDAPControl ** serverctrls);
-#else
-BerElement * ldap_build_sasl_bind_req();
-#endif
-/*
- * sbind.c
- */
-#ifdef NEEDPROTOS
-BerElement * ldap_build_simple_bind_req(LDAP *ld, char *dn, char *passwd, LDAPControl **serverctrls);
-#else
-BerElement * ldap_build_simple_bind_req();
-#endif
-
-/*
- * utils.c
- */
-
-#ifdef NEEDPROTOS
-void free_strarray(char **sap);
-#else
-void free_strarray();
-#endif
-
-/*
- * Controls.c
- */
-#ifdef NEEDPROTOS
-LDAPControl * ldap_control_dup(LDAPControl *ctrl);
-LDAPControl ** ldap_controls_dup(LDAPControl ** ctrls);
-int ldap_controls_code (BerElement *ber, LDAPControl **ctrls);
-LDAPControl ** ldap_controls_decode(BerElement *ber, int *errcode);
-int ldap_build_control(char *oid, BerElement *ber, int freeber,
- char iscritical, LDAPControl **ctrlp);
-#else
-LDAPControl * ldap_control_dup();
-LDAPControl ** ldap_controls_dup();
-int ldap_controls_code ();
-LDAPControl ** ldap_controls_decode();
-int ldap_build_control();
-#endif
-
-/*
- * ber/io.c
- */
-#ifdef NEEDPROTOS
-int ber_flush(Sockbuf *sb, BerElement *ber, int freeit);
-unsigned int ber_get_next(Sockbuf *sb, unsigned int *len, BerElement *ber);
-#else
-int ber_flush();
-unsigned int ber_get_next();
-#endif
-
diff --git a/usr/src/lib/libldap4/include/ldap-private.h b/usr/src/lib/libldap4/include/ldap-private.h
deleted file mode 100644
index 8cddace292..0000000000
--- a/usr/src/lib/libldap4/include/ldap-private.h
+++ /dev/null
@@ -1,360 +0,0 @@
-/*
- * Copyright 2008 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#ifndef _LDAP_PRIVATE_H
-#define _LDAP_PRIVATE_H
-
-#include <signal.h>
-#include <pthread.h> /* rri */
-
-#define pthread_self thr_self
-#define thr_self thr_self
-#define pthread_kill thr_kill
-#define thr_kill thr_kill
-
-#ifdef _REENTRANT
-#ifndef MAX_THREAD_ID
-#define MAX_THREAD_ID 500
-#endif /* MAX_THREAD_ID */
-#else /* _REENTRANT */
-#ifndef MAX_THREAD_ID
-#define MAX_THREAD_ID 1
-#endif /* MAX_THREAD_ID */
-#endif /* _REENTRANT */
-
-#define COMPAT20
-#define COMPAT30
-#if defined(COMPAT20) || defined(COMPAT30)
-#define COMPAT
-#endif
-
-#ifdef LDAP_DNS
-#define LDAP_OPT_DNS 0x00000001 /* use DN & DNS */
-#endif /* LDAP_DNS */
-
-/*
-#define DBG_LOCK1(st) printf("%d> %s %d:%s\n", thr_self(), st, __LINE__, __FILE__);
-#define DBG_LOCK2(ld,st) printf("%d> %s ld_lockcount=%d %d:%s\n", thr_self(), st, (ld)->ld_lockcount, __LINE__, __FILE__);
-*/
-#define DBG_LOCK1(st)
-#define DBG_LOCK2(ld,st)
-
-extern pthread_t thr_self();
-#define LOCK_RESPONSE(ld) \
- if ((ld)->ld_response_lockthread != thr_self()) { \
- DBG_LOCK1("waiting for response lock") \
- pthread_mutex_lock( &((ld)->ld_response_mutex) ); \
- DBG_LOCK1("got response lock") \
- (ld)->ld_response_lockthread = thr_self(); \
- } else { \
- (ld)->ld_response_lockcount++; \
- DBG_LOCK2(ld, "fake ldap lock") \
- }
-
-#define UNLOCK_RESPONSE(ld) \
- if ((ld)->ld_response_lockcount==0) { \
- (ld)->ld_response_lockthread = 0; \
- pthread_mutex_unlock( &((ld)->ld_response_mutex) ); \
- DBG_LOCK1("freed response lock") \
- } else { \
- (ld)->ld_response_lockcount--; \
- DBG_LOCK2(ld, "fake ldap unlock") \
- }
-
-#define LOCK_LDAP(ld) \
- if ((ld)->ld_lockthread != thr_self()) { \
- DBG_LOCK1("waiting for ldap lock") \
- pthread_mutex_lock( &((ld)->ld_ldap_mutex) ); \
- DBG_LOCK1("got ldap lock") \
- (ld)->ld_lockthread = thr_self(); \
- } else { \
- (ld)->ld_lockcount++; \
- DBG_LOCK2(ld, "fake ldap lock") \
- }
-
-#define UNLOCK_LDAP(ld) \
- if ((ld)->ld_lockcount==0) { \
- (ld)->ld_lockthread = 0; \
- pthread_mutex_unlock( &((ld)->ld_ldap_mutex) ); \
- DBG_LOCK1("freed ldap lock") \
- } else { \
- (ld)->ld_lockcount--; \
- DBG_LOCK2(ld, "fake ldap unlock") \
- }
-
-#define LOCK_POLL(ld) pthread_mutex_lock( &ld->ld_poll_mutex )
-#define UNLOCK_POLL(ld) pthread_mutex_unlock( &ld->ld_poll_mutex )
-
-
-/*
- * structure representing a Ber Element
- */
-typedef struct berelement {
- char *ber_buf;
- char *ber_ptr;
- char *ber_end;
- struct seqorset *ber_sos;
- unsigned int ber_tag;
- unsigned int ber_len;
- int ber_usertag;
- char ber_options;
-#define LBER_USE_DER 0x01
-#define LBER_USE_INDEFINITE_LEN 0x02
-#define LBER_TRANSLATE_STRINGS 0x04
- char *ber_rwptr;
- BERTranslateProc ber_encode_translate_proc;
- BERTranslateProc ber_decode_translate_proc;
-} _struct_BerElement;
-
-
-/*
- * This structure represents both ldap messages and ldap responses.
- * These are really the same, except in the case of search responses,
- * where a response has multiple messages.
- */
-typedef struct ldapmsg {
- int lm_msgid; /* the message id */
- int lm_msgtype; /* the message type */
- BerElement *lm_ber; /* the ber encoded message contents */
- struct ldapmsg *lm_chain; /* for search - next msg in the resp */
- struct ldapmsg *lm_next; /* next response */
- unsigned long lm_time; /* used to maintain cache */
-} _struct_LDAPMessage;
-
-typedef struct ldap_filt_list {
- char *lfl_tag;
- char *lfl_pattern;
- char *lfl_delims;
- LDAPFiltInfo *lfl_ilist;
- struct ldap_filt_list *lfl_next;
-} _struct_FiltList;
-
-typedef struct ldap_filt_desc {
- LDAPFiltList *lfd_filtlist;
- LDAPFiltInfo *lfd_curfip;
- LDAPFiltInfo lfd_retfi;
- char lfd_filter[ LDAP_FILT_MAXSIZ ];
- char *lfd_curval;
- char *lfd_curvalcopy;
- char **lfd_curvalwords;
- char *lfd_filtprefix;
- char *lfd_filtsuffix;
-} _struct_FiltDesc;
-
-/*
- * structure for tracking LDAP server host, ports, DNs, etc.
- */
-typedef struct ldap_server {
- char *lsrv_host;
- char *lsrv_dn; /* if NULL, use default */
- int lsrv_port;
- struct ldap_server *lsrv_next;
-} LDAPServer;
-
-
-/*
- * structure representing a Socket buffer
- */
-typedef struct sockbuf {
-#ifndef MACOS
- int sb_sd;
-#else /* MACOS */
- void *sb_sd;
-#endif /* MACOS */
- BerElement sb_ber;
-
- int sb_naddr; /* > 0 implies using CLDAP (UDP) */
- void *sb_useaddr; /* pointer to sockaddr to use next */
- void *sb_fromaddr; /* pointer to message source sockaddr */
- void **sb_addrs; /* actually an array of pointers to */
- /* sockaddrs */
-
- int sb_options; /* to support copying ber elements */
-#define LBER_TO_FILE 0x01 /* to a file referenced by sb_fd */
-#define LBER_TO_FILE_ONLY 0x02 /* only write to file, not network */
-#define LBER_MAX_INCOMING_SIZE 0x04 /* impose limit on incoming stuff */
-#define LBER_NO_READ_AHEAD 0x08 /* read only as much as requested */
- int sb_fd;
- int sb_max_incoming;
-#ifdef LDAP_SSL
- int sb_ssl_tls;
- SSL *sb_ssl; /* to support ldap over ssl */
-#endif /* LDAP_SSL */
-} Sockbuf;
-#define READBUFSIZ 8192
-
-
-/*
- * structure for representing an LDAP server connection
- */
-typedef struct ldap_conn {
- Sockbuf *lconn_sb;
- int lconn_refcnt;
- unsigned long lconn_lastused; /* time */
- int lconn_status;
-#define LDAP_CONNST_NEEDSOCKET 1
-#define LDAP_CONNST_CONNECTING 2
-#define LDAP_CONNST_CONNECTED 3
-#define LDAP_CONNST_DEAD 4
- LDAPServer *lconn_server;
- char *lconn_krbinstance;
- struct ldap_conn *lconn_next;
-} LDAPConn;
-
-/*
- * Structure used to keep track of search references
- */
-typedef struct ldap_reference {
- char ** lref_refs;
- struct ldap_reference *lref_next;
-} LDAPRef;
-
-
-
-/*
- * structure used to track outstanding requests
- */
-typedef struct ldapreq {
- int lr_msgid; /* the message id */
- int lr_status; /* status of request */
-#define LDAP_REQST_INPROGRESS 1
-#define LDAP_REQST_CHASINGREFS 2
-#define LDAP_REQST_NOTCONNECTED 3
-#define LDAP_REQST_WRITING 4
-#define LDAP_REQST_CONNDEAD 5
- int lr_outrefcnt; /* count of outstanding referrals */
- int lr_origid; /* original request's message id */
- int lr_parentcnt; /* count of parent requests */
- int lr_res_msgtype; /* result message type */
- int lr_res_errno; /* result LDAP errno */
- char *lr_res_error; /* result error string */
- char *lr_res_matched;/* result matched DN string */
- BerElement *lr_ber; /* ber encoded request contents */
- LDAPConn *lr_conn; /* connection used to send request */
- LDAPRef *lr_references;
- char **lr_ref_followed; /* referral being followed */
- char **lr_ref_unfollowed; /* Not being followed */
- char **lr_ref_tofollow; /* referral to follow if the one being
- followed fails. */
- struct ldapreq *lr_parent; /* request that spawned this referral */
- struct ldapreq *lr_refnext; /* next referral spawned */
- struct ldapreq *lr_prev; /* previous request */
- struct ldapreq *lr_next; /* next request */
-} LDAPRequest;
-
-/*
- * structure for client cache
- */
-#define LDAP_CACHE_BUCKETS 31 /* cache hash table size */
-typedef struct ldapcache {
- LDAPMessage *lc_buckets[LDAP_CACHE_BUCKETS];/* hash table */
- LDAPMessage *lc_requests; /* unfulfilled reqs */
- time_t lc_timeout; /* request timeout */
- ssize_t lc_maxmem; /* memory to use */
- ssize_t lc_memused; /* memory in use */
- int lc_enabled; /* enabled? */
- unsigned int lc_options; /* options */
-#define LDAP_CACHE_OPT_CACHENOERRS 0x00000001
-#define LDAP_CACHE_OPT_CACHEALLERRS 0x00000002
-} LDAPCache;
-#define NULLLDCACHE ((LDAPCache *)NULL)
-
-/*
- * structure representing an ldap connection
- */
-typedef struct ldap {
- Sockbuf ld_sb; /* socket descriptor & buffer */
- char *ld_host;
- int ld_version;
- char ld_lberoptions;
- int ld_deref;
-
- int ld_timelimit;
- int ld_sizelimit;
-
- LDAPFiltDesc *ld_filtd; /* from getfilter for ufn searches */
- char *ld_ufnprefix; /* for incomplete ufn's */
-
- int ld_errno[MAX_THREAD_ID]; /* thread-specific */
-#define ld_errno ld_errno[ldap_thr_index()]
- char *ld_error[MAX_THREAD_ID]; /* thread-specific */
-#define ld_error ld_error[ldap_thr_index()]
- char *ld_matched[MAX_THREAD_ID]; /* thread-specific */
-#define ld_matched ld_matched[ldap_thr_index()]
- char **ld_referrals[MAX_THREAD_ID]; /* thread-specific */
-#define ld_referrals ld_referrals[ldap_thr_index()]
- LDAPControl **ld_ret_ctrls[MAX_THREAD_ID]; /* thread-specific */
-#define ld_ret_ctrls ld_ret_ctrls[ldap_thr_index()]
- int ld_msgid;
-
- int ld_follow_referral; /* flag set to true if lib follow referrals */
- LDAPRequest *ld_requests; /* list of outstanding requests -- referrals*/
-
- LDAPMessage *ld_responses; /* list of outstanding responses */
- int *ld_abandoned; /* array of abandoned requests */
-
- pthread_mutex_t ld_response_mutex; /* mutex for responses part of structure */
- pthread_t ld_response_lockthread; /* thread which currently holds the response lock */
- int ld_response_lockcount; /* response lock depth */
-
- char *ld_attrbuffer[MAX_THREAD_ID];
-#define ld_attrbuffer ld_attrbuffer[ldap_thr_index()]
- LDAPCache *ld_cache; /* non-null if cache is initialized */
- char *ld_cldapdn; /* DN used in connectionless search */
-
- /* it is OK to change these next four values directly */
- int ld_cldaptries; /* connectionless search retry count */
- int ld_cldaptimeout;/* time between retries */
- int ld_refhoplimit; /* limit on referral nesting */
-/* LP TO CHANGE */
- char ld_restart;
-#ifdef LDAP_SSL
- int ld_use_ssl;
- char *ld_ssl_key;
-#endif
- unsigned int ld_options; /* boolean options */
-
- /* do not mess with the rest though */
- char *ld_defhost; /* full name of default server */
- int ld_defport; /* port of default server */
- BERTranslateProc ld_lber_encode_translate_proc;
- BERTranslateProc ld_lber_decode_translate_proc;
-
- LDAPConn *ld_defconn; /* default connection */
- LDAPConn *ld_conns; /* list of server connections */
- void *ld_selectinfo; /* platform specifics for select */
-
- LDAP_REBIND_FUNCTION *ld_rebindproc;
- void *ld_rebind_extra_arg;
-/* int (*ld_rebindproc)( struct ldap *ld, char **dnp, */
-/* char **passwdp, int *authmethodp, int freeit ); */
- /* routine to get info needed for re-bind */
-
- pthread_mutex_t ld_ldap_mutex; /* mutex for thread dependent part of struct */
- pthread_t ld_lockthread; /* thread which currently holds the lock */
- int ld_lockcount; /* lock depth */
- pthread_mutex_t ld_poll_mutex; /* a seperate lock for polling */
-
- LDAPControl **ld_srvctrls; /* Controls used by ldap and server */
- LDAPControl **ld_cltctrls; /* Client side controls */
-
-/* KE: Lists of unsolicited notifications */
- LDAPMessage *ld_notifs[MAX_THREAD_ID];
-
- /* How long to wait for while connecting to a server */
- int ld_connect_timeout;
-#define ld_notifs ld_notifs[ldap_thr_index()]
-} _struct_LDAP;
-
-
-/*
- * handy macro to check whether LDAP struct is set up for CLDAP or not
- */
-#define LDAP_IS_CLDAP( ld ) ( ld->ld_sb.sb_naddr > 0 )
-
-
-#endif /* _LDAP_PRIVATE_H */
diff --git a/usr/src/lib/libldap4/include/ldap.h b/usr/src/lib/libldap4/include/ldap.h
deleted file mode 100644
index a5a0a61534..0000000000
--- a/usr/src/lib/libldap4/include/ldap.h
+++ /dev/null
@@ -1,1375 +0,0 @@
-/*
- * Copyright (c) 2001 by Sun Microsystems, Inc.
- * All rights reserved.
- */
-
-/*
- * Copyright (c) 1990 Regents of the University of Michigan.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms are permitted
- * provided that this notice is preserved and that due credit is given
- * to the University of Michigan at Ann Arbor. The name of the University
- * may not be used to endorse or promote products derived from this
- * software without specific prior written permission. This software
- * is provided ``as is'' without express or implied warranty.
- */
-
-#ifndef _LDAP_H
-#define _LDAP_H
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#ifdef LDAP_SSL
-#include <security/ssl.h>
-#endif /* LDAP_SSL */
-
-
-#include <pthread.h>
-
-#ifdef LDAP_SSL
-#define SSL_LDAP_PORT 636
-#endif
-
-#if !defined(NEEDPROTOS) && defined(__STDC__)
-#define NEEDPROTOS 1
-#endif
-
-#define LDAP_API_VERSION 2004
-#define LDAP_VERSION_MIN 2
-#define LDAP_VERSION_MAX 3
-#define LDAP_VENDOR_NAME "Sun Microsystems Inc."
-#define LDAP_VENDOR_VERSION 400
-
-#define LDAP_PORT 389
-#define LDAP_VERSION1 1
-#define LDAP_VERSION2 2
-#define LDAP_VERSION3 3
-#define LDAP_VERSION LDAP_VERSION2
-
-/* OPTIONS to use with ldap_set_option and ldap_get_option */
-#define LDAP_OPT_API_INFO 0x00
-#define LDAP_OPT_DESC 0x01 /* Use of this option is depricated */
-/* int, control how aliases are handled during search */
-#define LDAP_OPT_DEREF 0x02
-/* Deref values */
-#define LDAP_DEREF_NEVER 0x00
-#define LDAP_DEREF_SEARCHING 0x01
-#define LDAP_DEREF_FINDING 0x02
-#define LDAP_DEREF_ALWAYS 0x03
-
-#define LDAP_OPT_SIZELIMIT 0x03 /* int, size limit of a search */
-#define LDAP_OPT_TIMELIMIT 0x04 /* int, time limit of a search */
-#define LDAP_OPT_REBIND_FN 0x06 /* Use of this options is depricated */
-#define LDAP_OPT_REBIND_ARG 0x07 /* Use of this options is depricated */
-#define LDAP_OPT_REFERRALS 0x08 /* ON/OFF, chase referrals */
-#define LDAP_OPT_RESTART 0x09 /* ON/OFF, restart if EINTR occurs */
-/* int, protocol version, default 2 */
-#define LDAP_OPT_PROTOCOL_VERSION 0x11
-/* List of ldap controls to be sent with each request */
-#define LDAP_OPT_SERVER_CONTROLS 0x12
-/* List of ldap controls that affect the session */
-#define LDAP_OPT_CLIENT_CONTROLS 0x13
-#define LDAP_OPT_API_FEATURE_INFO 0x15
-/* The hostname of the default ldap server */
-#define LDAP_OPT_HOST_NAME 0x30
-/* The code of the most recent ldap error that occured for this session */
-#define LDAP_OPT_ERROR_NUMBER 0x31
-/* The message returned with the most recent ldap error */
-#define LDAP_OPT_ERROR_STRING 0x32
-/* The Matching DN in case of a naming error */
-#define LDAP_OPT_MATCHED_DN 0x33
-#define LDAP_OPT_ERROR_MATCHED 0x33 /* Use of this options is depricated */
-
-/* The timeout while trying to connect to a server */
-#define LDAP_X_OPT_CONNECT_TIMEOUT 0x4F01
-#define LDAP_X_IO_TIMEOUT_NO_WAIT 0
-#define LDAP_X_IO_TIMEOUT_NO_TIMEOUT -1
-
-/* The Filter List Desc used by UFN functions */
-/* #define LDAP_OPT_FILTERDESC 0x80 */
-/* For on/off options */
-#define LDAP_OPT_ON ((void *)1)
-#define LDAP_OPT_OFF ((void *)0)
-
-/* Used for NO limitation is TIMELIMIT or SIZELIMIT */
-#define LDAP_NO_LIMIT 0
-
-#define LDAP_MAX_ATTR_LEN 100
-#define LDAP_RETURN_NO_ATTR "1.1"
-#define LDAP_RETURN_ALL_ATTR ""
-#define LDAP_RETURN_ALL_ATTR_OPS "*"
-
-/* Begin LDAP Display Template Definitions */
-#define LDAP_TEMPLATE_VERSION 1
-
-/*
- * general types of items (confined to most significant byte)
- */
-#define LDAP_SYN_TYPE_TEXT 0x01000000
-#define LDAP_SYN_TYPE_IMAGE 0x02000000
-#define LDAP_SYN_TYPE_BOOLEAN 0x04000000
-#define LDAP_SYN_TYPE_BUTTON 0x08000000
-#define LDAP_SYN_TYPE_ACTION 0x10000000
-
-/*
- * syntax options (confined to second most significant byte)
- */
-#define LDAP_SYN_OPT_DEFER 0x00010000
-
-
-/*
- * display template item syntax ids (defined by common agreement)
- * these are the valid values for the ti_syntaxid of the tmplitem
- * struct (defined below). A general type is encoded in the
- * most-significant 8 bits, and some options are encoded in the next
- * 8 bits. The lower 16 bits are reserved for the distinct types.
- */
-#define LDAP_SYN_CASEIGNORESTR (1 | LDAP_SYN_TYPE_TEXT)
-#define LDAP_SYN_MULTILINESTR (2 | LDAP_SYN_TYPE_TEXT)
-#define LDAP_SYN_DN (3 | LDAP_SYN_TYPE_TEXT)
-#define LDAP_SYN_BOOLEAN (4 | LDAP_SYN_TYPE_BOOLEAN)
-#define LDAP_SYN_JPEGIMAGE (5 | LDAP_SYN_TYPE_IMAGE)
-#define LDAP_SYN_JPEGBUTTON (6 | LDAP_SYN_TYPE_BUTTON | \
- LDAP_SYN_OPT_DEFER)
-#define LDAP_SYN_FAXIMAGE (7 | LDAP_SYN_TYPE_IMAGE)
-#define LDAP_SYN_FAXBUTTON (8 | LDAP_SYN_TYPE_BUTTON | \
- LDAP_SYN_OPT_DEFER)
-#define LDAP_SYN_AUDIOBUTTON (9 | LDAP_SYN_TYPE_BUTTON | \
- LDAP_SYN_OPT_DEFER)
-#define LDAP_SYN_TIME (10 | LDAP_SYN_TYPE_TEXT)
-#define LDAP_SYN_DATE (11 | LDAP_SYN_TYPE_TEXT)
-#define LDAP_SYN_LABELEDURL (12 | LDAP_SYN_TYPE_TEXT)
-#define LDAP_SYN_SEARCHACTION (13 | LDAP_SYN_TYPE_ACTION)
-#define LDAP_SYN_LINKACTION (14 | LDAP_SYN_TYPE_ACTION)
-#define LDAP_SYN_ADDDNACTION (15 | LDAP_SYN_TYPE_ACTION)
-#define LDAP_SYN_VERIFYDNACTION (16 | LDAP_SYN_TYPE_ACTION)
-#define LDAP_SYN_RFC822ADDR (17 | LDAP_SYN_TYPE_TEXT)
-#ifdef SUN
-#define LDAP_SYN_PROTECTED (18 | LDAP_SYN_TYPE_TEXT)
-#endif
-
-/*
- * handy macros
- */
-#define LDAP_GET_SYN_TYPE(syid) ((syid) & 0xFF000000)
-#define LDAP_GET_SYN_OPTIONS(syid) ((syid) & 0x00FF0000)
-
-/*
- * display options for output routines (used by entry2text and friends)
- */
-/*
- * use calculated label width (based on length of longest label in
- * template) instead of contant width
- */
-#define LDAP_DISP_OPT_AUTOLABELWIDTH 0x00000001
-#define LDAP_DISP_OPT_HTMLBODYONLY 0x00000002
-
-/*
- * perform search actions (applies to ldap_entry2text_search only)
- */
-#define LDAP_DISP_OPT_DOSEARCHACTIONS 0x00000002
-
-/*
- * include additional info. relevant to "non leaf" entries only
- * used by ldap_entry2html and ldap_entry2html_search to include "Browse"
- * and "Move Up" HREFs
- */
-#define LDAP_DISP_OPT_NONLEAF 0x00000004
-
-
-/*
- * display template item options (may not apply to all types)
- * if this bit is set in ti_options, it applies.
- */
-#define LDAP_DITEM_OPT_READONLY 0x00000001
-#define LDAP_DITEM_OPT_SORTVALUES 0x00000002
-#define LDAP_DITEM_OPT_SINGLEVALUED 0x00000004
-#define LDAP_DITEM_OPT_HIDEIFEMPTY 0x00000008
-#define LDAP_DITEM_OPT_VALUEREQUIRED 0x00000010
-#define LDAP_DITEM_OPT_HIDEIFFALSE 0x00000020 /* booleans only */
-
-
-/*
- * LDAP API Information structure
- */
-typedef struct ldapapiinfo {
- int ldapai_info_version; /* version of this struct (1) */
- int ldapai_api_version; /* revision of API supported */
- int ldapai_protocol_version; /* highest LDAP version supported */
- char **ldapai_extensions; /* names of API extensions */
- char *ldapai_vendor_name; /* name of supplier */
- int ldapai_vendor_version; /* supplier-specific version * 100 */
-} LDAPAPIInfo;
-#define LDAP_API_INFO_VERSION 1
-
-
-/*
- * LDAP API Feature Information
- */
-typedef struct ldap_apifeature_info {
- int ldapaif_info_version; /* version of this struct (1) */
- char *ldapaif_name; /* name of supported feature */
- int ldapaif_version; /* revision of supported feature */
-} LDAPAPIFeatureInfo;
-#define LDAP_FEATURE_INFO_VERSION 1
-
-
-/*
- * display template item structure
- */
-struct ldap_tmplitem {
- unsigned int ti_syntaxid;
- unsigned int ti_options;
- char *ti_attrname;
- char *ti_label;
- char **ti_args;
- struct ldap_tmplitem *ti_next_in_row;
- struct ldap_tmplitem *ti_next_in_col;
- void *ti_appdata;
-};
-
-
-#define NULLTMPLITEM ((struct ldap_tmplitem *)0)
-
-#define LDAP_SET_TMPLITEM_APPDATA(ti, datap) \
- (ti)->ti_appdata = (void *)(datap)
-
-#define LDAP_GET_TMPLITEM_APPDATA(ti, type) \
- (type)((ti)->ti_appdata)
-
-
-#define LDAP_IS_TMPLITEM_OPTION_SET(ti, option) \
- (((ti)->ti_options & option) != 0)
-
-
-/*
- * object class array structure
- */
-struct ldap_oclist {
- char **oc_objclasses;
- struct ldap_oclist *oc_next;
-};
-
-#define NULLOCLIST ((struct ldap_oclist *)0)
-
-
-/*
- * add defaults list
- */
-struct ldap_adddeflist {
- int ad_source;
-#define LDAP_ADSRC_CONSTANTVALUE 1
-#define LDAP_ADSRC_ADDERSDN 2
- char *ad_attrname;
- char *ad_value;
- struct ldap_adddeflist *ad_next;
-};
-
-#define NULLADLIST ((struct ldap_adddeflist *)0)
-
-
-/*
- * display template global options
- * if this bit is set in dt_options, it applies.
- */
-/*
- * users should be allowed to try to add objects of these entries
- */
-#define LDAP_DTMPL_OPT_ADDABLE 0x00000001
-
-/*
- * users should be allowed to do "modify RDN" operation of these entries
- */
-#define LDAP_DTMPL_OPT_ALLOWMODRDN 0x00000002
-
-/*
- * this template is an alternate view, not a primary view
- */
-#define LDAP_DTMPL_OPT_ALTVIEW 0x00000004
-
-
-/*
- * display template structure
- */
-struct ldap_disptmpl {
- char *dt_name;
- char *dt_pluralname;
- char *dt_iconname;
- unsigned int dt_options;
- char *dt_authattrname;
- char *dt_defrdnattrname;
- char *dt_defaddlocation;
- struct ldap_oclist *dt_oclist;
- struct ldap_adddeflist *dt_adddeflist;
- struct ldap_tmplitem *dt_items;
- void *dt_appdata;
- struct ldap_disptmpl *dt_next;
-};
-
-#define NULLDISPTMPL ((struct ldap_disptmpl *)0)
-
-#define LDAP_SET_DISPTMPL_APPDATA(dt, datap) \
- (dt)->dt_appdata = (void *)(datap)
-
-#define LDAP_GET_DISPTMPL_APPDATA(dt, type) \
- (type)((dt)->dt_appdata)
-
-#define LDAP_IS_DISPTMPL_OPTION_SET(dt, option) \
- (((dt)->dt_options & option) != 0)
-
-#define LDAP_TMPL_ERR_VERSION 1
-#define LDAP_TMPL_ERR_MEM 2
-#define LDAP_TMPL_ERR_SYNTAX 3
-#define LDAP_TMPL_ERR_FILE 4
-
-/*
- * buffer size needed for entry2text and vals2text
- */
-#define LDAP_DTMPL_BUFSIZ 8192
-
-/* END Display Template Definitions */
-
-/* BEGIN Search Prefrences Definitions */
-
-struct ldap_searchattr {
- char *sa_attrlabel;
- char *sa_attr;
- /* max 32 matchtypes for now */
- unsigned int sa_matchtypebitmap;
- char *sa_selectattr;
- char *sa_selecttext;
- struct ldap_searchattr *sa_next;
-};
-
-struct ldap_searchmatch {
- char *sm_matchprompt;
- char *sm_filter;
- struct ldap_searchmatch *sm_next;
-};
-
-struct ldap_searchobj {
- char *so_objtypeprompt;
- unsigned int so_options;
- char *so_prompt;
- short so_defaultscope;
- char *so_filterprefix;
- char *so_filtertag;
- char *so_defaultselectattr;
- char *so_defaultselecttext;
- struct ldap_searchattr *so_salist;
- struct ldap_searchmatch *so_smlist;
- struct ldap_searchobj *so_next;
-};
-
-#define NULLSEARCHOBJ ((struct ldap_searchobj *)0)
-
-/*
- * global search object options
- */
-#define LDAP_SEARCHOBJ_OPT_INTERNAL 0x00000001
-
-#define LDAP_IS_SEARCHOBJ_OPTION_SET(so, option) \
- (((so)->so_options & option) != 0)
-
-#define LDAP_SEARCHPREF_VERSION_ZERO 0
-#define LDAP_SEARCHPREF_VERSION 1
-
-#define LDAP_SEARCHPREF_ERR_VERSION 1
-#define LDAP_SEARCHPREF_ERR_MEM 2
-#define LDAP_SEARCHPREF_ERR_SYNTAX 3
-#define LDAP_SEARCHPREF_ERR_FILE 4
-
-
-/* END Search Prefrences Definitions */
-
-/*
- * Structure for LDAP modifications
- */
-typedef struct ldapmod {
- int mod_op;
-#define LDAP_MOD_ADD 0x00
-#define LDAP_MOD_DELETE 0x01
-#define LDAP_MOD_REPLACE 0x02
-#define LDAP_MOD_BVALUES 0x80
- char *mod_type;
- union {
- char **modv_strvals;
- struct berval **modv_bvals;
- } mod_vals;
-#define mod_values mod_vals.modv_strvals
-#define mod_bvalues mod_vals.modv_bvals
-/*
- * The following field is commented out since no functions use it in
- * the library and also not part of c-api draft.
- */
-/* struct ldapmod *mod_next */
-} LDAPMod;
-
-typedef struct ldap LDAP; /* Opaque LDAP connection handle */
-
-typedef struct ldapmsg LDAPMessage; /* Opaque Result / Entry handle */
-
-#define NULLMSG ((LDAPMessage *) NULL)
-
-/* Call back to get info needed for re-bind */
-typedef int (LDAP_REBIND_FUNCTION)(LDAP *ld, char **dn, char **passwd,
- int *authmethod, int freeit, void *extraArg);
-
-/*
- * structures for ldap getfilter routines
- */
-
-typedef struct ldap_filt_info {
- char *lfi_filter;
- char *lfi_desc;
- int lfi_scope; /* LDAP_SCOPE_BASE, etc */
- int lfi_isexact; /* exact match filter? */
- struct ldap_filt_info *lfi_next;
-} LDAPFiltInfo;
-
-
-#define LDAP_FILT_MAXSIZ 1024
-
-typedef struct ldap_filt_list LDAPFiltList;
-typedef struct ldap_filt_desc LDAPFiltDesc;
-
-
-/*
- * Simple Page control OID
- */
-#define LDAP_CONTROL_SIMPLE_PAGE "1.2.840.113556.1.4.319"
-
-/*
- * Server Sort Control
- */
-#define LDAP_CONTROL_SORTREQUEST "1.2.840.113556.1.4.473"
-#define LDAP_CONTROL_SORTRESPONSE "1.2.840.113556.1.4.474"
-/*
- * structure for a sort-key
- */
-typedef struct LDAPsortkey {
- char *sk_attrtype;
- char *sk_matchruleoid;
- int sk_reverseorder;
-} LDAPsortkey;
-
-/*
- * Virtual List View (vlv) control
- */
-#define LDAP_CONTROL_VLVREQUEST "2.16.840.1.113730.3.4.9"
-#define LDAP_CONTROL_VLVRESPONSE "2.16.840.1.113730.3.4.10"
-/*
- * structure that describes a VirtualListViewRequest control.
- * note that ldvlist_index and ldvlist_size are only relevant to
- * ldap_create_virtuallist_control() if ldvlist_attrvalue is NULL.
- */
-typedef struct ldapvirtuallist {
- unsigned long ldvlist_before_count; /* # entries before target */
- unsigned long ldvlist_after_count; /* # entries after target */
- char *ldvlist_attrvalue; /* jump to this value */
- unsigned long ldvlist_index; /* list offset */
- unsigned long ldvlist_size; /* number of items in vlist */
- void *ldvlist_extradata; /* for use by application */
-} LDAPVirtualList;
-
-/*
- * ldapv3 LDAPControl
- */
-typedef struct ldapcontrol
-{
- char *ldctl_oid;
-/*
- * the "ldctl_value" field of this structure used to be a pointer to
- * struct berval. To make this structure compliant to the latest c-api
- * draft, it is changed to "struct berval ldctl_value"
- */
- struct berval ldctl_value;
- char ldctl_iscritical;
-} LDAPControl, *PLDAPControl;
-
-/*
- * specific LDAP instantiations of BER types we know about
- */
-
-/* general stuff */
-#define LDAP_TAG_MESSAGE 0x30 /* tag is 16 + constructed bit */
-#define LDAP_TAG_MSGID 0x02
-#define LDAP_TAG_CONTROL_LIST 0xA0 /* Context 0 + constructed */
-#define LDAP_TAG_REFERRAL 0xA3 /* Context 3 + constructed */
-#define LDAP_TAG_SASLCREDS 0x87 /* Context 7 + primitive */
-#define LDAP_TAG_AUTH_SIMPLE 0x80 /* Context 0 + primitive */
-#define LDAP_TAG_AUTH_SASL 0xA3 /* Context 3 + constructed */
-/* Tag for modrdn request */
-#define LDAP_TAG_NEWPARENT 0x80 /* Context 0 + primitive */
-/* Tags for Extensible filter match */
-#define LDAP_TAG_FEXT_RULE 0x81 /* Context 1 + primitive */
-#define LDAP_TAG_FEXT_TYPE 0x82 /* Context 2 + primitive */
-#define LDAP_TAG_FEXT_VAL 0x83 /* Context 3 + primitive */
-#define LDAP_TAG_FEXT_DN 0x84 /* Context 4 + primitive */
-/* tags for EXTENDED OPERATIONS */
-#define LDAP_TAG_EXT_NAME 0x80 /* Context 0 + primitive */
-#define LDAP_TAG_EXT_VAL 0x81 /* Context 1 + primitive */
-#define LDAP_TAG_EXT_RESPNAME 0x8a /* Context 10 + primitive */
-#define LDAP_TAG_EXT_RESPONSE 0x8b /* Context 11 + primitive */
-/* tags for Virtual List View control */
-#define LDAP_TAG_VLV_BY_INDEX 0xa0 /* context specific + constructed + 0 */
-#define LDAP_TAG_VLV_BY_VALUE 0x81 /* context specific + primitive + 1 */
-/* tag for sort control */
-#define LDAP_TAG_SK_MATCHRULE 0x80L /* context specific + primitive */
-#define LDAP_TAG_SK_REVERSE 0x81L /* context specific + primitive */
-#define LDAP_TAG_SR_ATTRTYPE 0x80L /* context specific + primitive */
-
-/* possible operations a client can invoke */
-#define LDAP_REQ_BIND 0x60 /* application + constructed */
-#define LDAP_REQ_UNBIND 0x42 /* application + primitive */
-#define LDAP_REQ_SEARCH 0x63 /* application + constructed */
-#define LDAP_REQ_MODIFY 0x66 /* application + constructed */
-#define LDAP_REQ_ADD 0x68 /* application + constructed */
-#define LDAP_REQ_DELETE 0x4a /* application + primitive */
-#define LDAP_REQ_MODRDN 0x6c /* application + constructed */
-#define LDAP_REQ_COMPARE 0x6e /* application + constructed */
-#define LDAP_REQ_ABANDON 0x50 /* application + primitive */
-/* New in ldapv3 application + constructed */
-#define LDAP_REQ_EXTENDED 0x77
-/* version 3.0 compatibility stuff */
-#define LDAP_REQ_UNBIND_30 0x62
-#define LDAP_REQ_DELETE_30 0x6a
-#define LDAP_REQ_ABANDON_30 0x70
-
-/* possible result types a server can return */
-#define LDAP_RES_BIND 0x61 /* application + constructed */
-#define LDAP_RES_SEARCH_ENTRY 0x64 /* application + constructed */
-/* new in ldapv3, application + constructed */
-#define LDAP_RES_SEARCH_REFERENCE 0x73
-#define LDAP_RES_SEARCH_RESULT 0x65 /* application + constructed */
-#define LDAP_RES_MODIFY 0x67 /* application + constructed */
-#define LDAP_RES_ADD 0x69 /* application + constructed */
-#define LDAP_RES_DELETE 0x6b /* application + constructed */
-#define LDAP_RES_MODRDN 0x6d /* application + constructed */
-#define LDAP_RES_COMPARE 0x6f /* application + constructed */
-/* new in ldapv3, application + constructed */
-#define LDAP_RES_EXTENDED 0x78
-#define LDAP_RES_ANY (-1)
-
-/* authentication methods available */
-#define LDAP_AUTH_NONE 0x00 /* no authentication */
-#define LDAP_AUTH_SIMPLE 0x80 /* context specific + primitive */
-#define LDAP_AUTH_KRBV4 0xff /* means do both of the following */
-#define LDAP_AUTH_KRBV41 0x81 /* context specific + primitive */
-#define LDAP_AUTH_KRBV42 0x82 /* context specific + primitive */
-/* New with ldapv3 */
-#define LDAP_AUTH_SASL 0xa3 /* context specific + constructed */
-
-/* 3.0 compatibility auth methods */
-#define LDAP_AUTH_SIMPLE_30 0xa0 /* context specific + constructed */
-#define LDAP_AUTH_KRBV41_30 0xa1 /* context specific + constructed */
-#define LDAP_AUTH_KRBV42_30 0xa2 /* context specific + constructed */
-
-/* filter types */
-#define LDAP_FILTER_AND 0xa0 /* context specific + constructed */
-#define LDAP_FILTER_OR 0xa1 /* context specific + constructed */
-#define LDAP_FILTER_NOT 0xa2 /* context specific + constructed */
-#define LDAP_FILTER_EQUALITY 0xa3 /* context specific + constructed */
-#define LDAP_FILTER_SUBSTRINGS 0xa4 /* context specific + constructed */
-#define LDAP_FILTER_GE 0xa5 /* context specific + constructed */
-#define LDAP_FILTER_LE 0xa6 /* context specific + constructed */
-#define LDAP_FILTER_PRESENT 0x87 /* context specific + primitive */
-#define LDAP_FILTER_APPROX 0xa8 /* context specific + constructed */
-#define LDAP_FILTER_EXTENSIBLE 0xa9 /* context specific + constructed */
-
-/* 3.0 compatibility filter types */
-#define LDAP_FILTER_PRESENT_30 0xa7 /* context specific + constructed */
-
-/* substring filter component types */
-#define LDAP_SUBSTRING_INITIAL 0x80 /* context specific */
-#define LDAP_SUBSTRING_ANY 0x81 /* context specific */
-#define LDAP_SUBSTRING_FINAL 0x82 /* context specific */
-
-/* 3.0 compatibility substring filter component types */
-#define LDAP_SUBSTRING_INITIAL_30 0xa0 /* context specific */
-#define LDAP_SUBSTRING_ANY_30 0xa1 /* context specific */
-#define LDAP_SUBSTRING_FINAL_30 0xa2 /* context specific */
-
-/* search scopes */
-#define LDAP_SCOPE_BASE 0x00
-#define LDAP_SCOPE_ONELEVEL 0x01
-#define LDAP_SCOPE_SUBTREE 0x02
-/* Used when parsing URL, if scope not found. *LDAP_SCOPE_BASE is to use then */
-#define LDAP_SCOPE_UNKNOWN 0xFF
-
-/* ldap_result number of messages that should be returned */
-#define LDAP_MSG_ONE 0x00
-#define LDAP_MSG_ALL 0x01
-#define LDAP_MSG_RECEIVED 0x02
-
-
-/* default limit on nesting of referrals */
-#define LDAP_DEFAULT_REFHOPLIMIT 5
-
-
-/* SASL mechanisms */
-#define LDAP_SASL_SIMPLE ""
-#define LDAP_SASL_CRAM_MD5 "CRAM-MD5"
-#define LDAP_SASL_EXTERNAL "EXTERNAL"
-/* Next ones are not supported so far by SunDS 2.0 */
-#define LDAP_SASL_X511_PROTECTED "X.511-Protected"
-#define LDAP_SASL_X511_STRONG "X.511-Strong"
-#define LDAP_SASL_KERBEROS_V4 "KERBEROS_V4"
-#define LDAP_SASL_GSSAPI "GSSAPI"
-#define LDAP_SASL_SKEY "SKEY"
-
-/*
- * structure for ldap friendly mapping routines
- */
-
-typedef struct friendly {
- char *f_unfriendly;
- char *f_friendly;
-} FriendlyMap;
-
-
-/*
- * Structures for URL handling
- */
-typedef struct ldap_url_extension {
- char *lue_type;
- char *lue_value;
- int lue_iscritical;
-} LDAPURLExt;
-
-typedef struct ldap_url_desc {
- char *lud_host;
- int lud_port;
- char *lud_dn;
- char **lud_attrs;
- int lud_scope;
- char *lud_filter;
- LDAPURLExt **lud_extensions;
- char *lud_string; /* for internal use only */
-} LDAPURLDesc;
-
-#define NULLLDAPURLDESC ((LDAPURLDesc *)NULL)
-
-#define LDAP_URL_ERR_NOTLDAP 1 /* URL doesn't begin with "ldap://" */
-#define LDAP_URL_ERR_NODN 2 /* URL has no DN (required) */
-#define LDAP_URL_ERR_BADSCOPE 3 /* URL scope string is invalid */
-#define LDAP_URL_ERR_MEM 4 /* can't allocate memory space */
-
-
-/*
- * possible error codes we can return
- */
-
-#define LDAP_SUCCESS 0x00
-#define LDAP_OPERATIONS_ERROR 0x01
-#define LDAP_PROTOCOL_ERROR 0x02
-#define LDAP_TIMELIMIT_EXCEEDED 0x03
-#define LDAP_SIZELIMIT_EXCEEDED 0x04
-#define LDAP_COMPARE_FALSE 0x05
-#define LDAP_COMPARE_TRUE 0x06
-#define LDAP_AUTH_METHOD_NOT_SUPPORTED 0x07
-#define LDAP_STRONG_AUTH_REQUIRED 0x08
-/* Not used in ldapv3 */
-#define LDAP_PARTIAL_RESULTS 0x09
-
-/* New in ldapv3 */
-#define LDAP_REFERRAL 0x0a
-#define LDAP_ADMINLIMIT_EXCEEDED 0x0b
-#define LDAP_UNAVAILABLE_CRITICAL_EXTENSION 0x0c
-#define LDAP_CONFIDENTIALITY_REQUIRED 0x0d
-#define LDAP_SASL_BIND_INPROGRESS 0x0e
-/* End of new */
-
-#define LDAP_NO_SUCH_ATTRIBUTE 0x10
-#define LDAP_UNDEFINED_TYPE 0x11
-#define LDAP_INAPPROPRIATE_MATCHING 0x12
-#define LDAP_CONSTRAINT_VIOLATION 0x13
-#define LDAP_TYPE_OR_VALUE_EXISTS 0x14
-#define LDAP_INVALID_SYNTAX 0x15
-
-#define ATTRIBUTE_ERROR(n) ((n & 0xf0) == 0x10)
-
-#define LDAP_NO_SUCH_OBJECT 0x20
-#define LDAP_ALIAS_PROBLEM 0x21
-#define LDAP_INVALID_DN_SYNTAX 0x22
-/* Following in not used in ldapv3 */
-#define LDAP_IS_LEAF 0x23
-#define LDAP_ALIAS_DEREF_PROBLEM 0x24
-
-#define NAME_ERROR(n) ((n & 0xf0) == 0x20)
-
-#define LDAP_INAPPROPRIATE_AUTH 0x30
-#define LDAP_INVALID_CREDENTIALS 0x31
-#define LDAP_INSUFFICIENT_ACCESS 0x32
-#define LDAP_BUSY 0x33
-#define LDAP_UNAVAILABLE 0x34
-#define LDAP_UNWILLING_TO_PERFORM 0x35
-#define LDAP_LOOP_DETECT 0x36
-
-#define LDAP_SORT_CONTROL_MISSING 0x3C /* 60 */
-#define LDAP_INDEX_RANGE_ERROR 0x3D /* 61 */
-
-#define LDAP_NAMING_VIOLATION 0x40
-#define LDAP_OBJECT_CLASS_VIOLATION 0x41
-#define LDAP_NOT_ALLOWED_ON_NONLEAF 0x42
-#define LDAP_NOT_ALLOWED_ON_RDN 0x43
-#define LDAP_ALREADY_EXISTS 0x44
-#define LDAP_NO_OBJECT_CLASS_MODS 0x45
-#define LDAP_RESULTS_TOO_LARGE 0x46
-/* Following is new in ldapv3 */
-#define LDAP_AFFECTS_MULTIPLE_DSAS 0x47
-#define LDAP_OTHER 0x50
-
-/* Reserved for API */
-#define LDAP_SERVER_DOWN 0x51
-#define LDAP_LOCAL_ERROR 0x52
-#define LDAP_ENCODING_ERROR 0x53
-#define LDAP_DECODING_ERROR 0x54
-#define LDAP_TIMEOUT 0x55
-#define LDAP_AUTH_UNKNOWN 0x56
-#define LDAP_FILTER_ERROR 0x57
-#define LDAP_USER_CANCELLED 0x58
-#define LDAP_PARAM_ERROR 0x59
-#define LDAP_NO_MEMORY 0x5a
-
-/* New code with ldapv3 ? */
-#define LDAP_CONNECT_ERROR 0x5b
-#define LDAP_NOT_SUPPORTED 0x5c
-#define LDAP_CONTROL_NOT_FOUND 0x5d
-#define LDAP_NO_RESULTS_RETURNED 0x5e
-#define LDAP_MORE_RESULTS_TO_RETURN 0x5f
-#define LDAP_CLIENT_LOOP 0x60
-#define LDAP_REFERRAL_LIMIT_EXCEEDED 0x61
-
-/* debugging stuff */
-#ifdef LDAP_DEBUG
-extern int ldap_debug;
-#ifdef LDAP_SYSLOG
-extern int ldap_syslog;
-extern int ldap_syslog_level;
-#endif
-#define LDAP_DEBUG_TRACE 0x001
-#define LDAP_DEBUG_PACKETS 0x002
-#define LDAP_DEBUG_ARGS 0x004
-#define LDAP_DEBUG_CONNS 0x008
-#define LDAP_DEBUG_BER 0x010
-#define LDAP_DEBUG_FILTER 0x020
-#define LDAP_DEBUG_CONFIG 0x040
-#define LDAP_DEBUG_ACL 0x080
-#define LDAP_DEBUG_STATS 0x100
-#define LDAP_DEBUG_STATS2 0x200
-#define LDAP_DEBUG_SHELL 0x400
-#define LDAP_DEBUG_PARSE 0x800
-/* More values for http gateway */
-#define LDAP_DEBUG_GWAY 0x1000
-#define LDAP_DEBUG_GWAYMORE 0x2000
-
-#define LDAP_DEBUG_ANY 0xffff
-
-#ifdef LDAP_SYSLOG
-/* ldaplog is a general logging function that is defined in liblber/i18n.c */
-#define Debug(level, fmt, arg1, arg2, arg3) \
- { \
- if (ldap_debug & level) \
- fprintf(stderr, fmt, arg1, arg2, arg3); \
- if (ldap_syslog & level) \
- ldaplog(level, fmt, arg1, arg2, arg3); \
- }
-#else /* LDAP_SYSLOG */
-#ifndef WINSOCK
-#define Debug(level, fmt, arg1, arg2, arg3) \
- if (ldap_debug & level) \
- fprintf(stderr, fmt, arg1, arg2, arg3);
-#else /* !WINSOCK */
-extern void Debug(int level, char *fmt, ...);
-#endif /* !WINSOCK */
-#endif /* LDAP_SYSLOG */
-#else /* LDAP_DEBUG */
-#define Debug(level, fmt, arg1, arg2, arg3)
-#endif /* LDAP_DEBUG */
-
-
-#ifndef NEEDPROTOS
-extern LDAP *ldap_open();
-#ifdef LDAP_SSL
-extern LDAP *ldap_ssl_open();
-#endif /* LDAP_SSL */
-extern LDAP *ldap_init();
-#ifdef STR_TRANSLATION
-extern void ldap_set_string_translators();
-#ifdef LDAP_CHARSET_8859
-extern int ldap_t61_to_8859();
-extern int ldap_8859_to_t61();
-#endif /* LDAP_CHARSET_8859 */
-#endif /* STR_TRANSLATION */
-extern LDAPMessage *ldap_first_entry();
-extern LDAPMessage *ldap_next_entry();
-extern char *ldap_get_dn();
-extern char *ldap_dn2ufn();
-extern char **ldap_explode_dn();
-extern char *ldap_first_attribute();
-extern char *ldap_next_attribute();
-extern char **ldap_get_values();
-extern struct berval **ldap_get_values_len();
-extern void ldap_value_free();
-extern void ldap_value_free_len();
-extern int ldap_count_values();
-extern int ldap_count_values_len();
-extern char *ldap_err2string();
-extern void ldap_getfilter_free();
-extern LDAPFiltDesc *ldap_init_getfilter();
-extern LDAPFiltDesc *ldap_init_getfilter_buf();
-extern LDAPFiltInfo *ldap_getfirstfilter();
-extern LDAPFiltInfo *ldap_getnextfilter();
-extern void ldap_setfilteraffixes();
-extern void ldap_build_filter();
-extern void ldap_flush_cache();
-extern void ldap_set_cache_options();
-extern void ldap_uncache_entry();
-extern void ldap_uncache_request();
-extern char *ldap_friendly_name();
-extern void ldap_free_friendlymap();
-extern LDAP *cldap_open();
-extern void cldap_setretryinfo();
-extern void cldap_close();
-extern LDAPFiltDesc *ldap_ufn_setfilter();
-extern int ldap_ufn_timeout();
-extern int ldap_sort_entries();
-extern int ldap_sort_values();
-extern int ldap_sort_strcasecmp();
-void ldap_free_urldesc();
-void ldap_free_urlexts();
-void ldap_set_rebind_proc();
-void ldap_enable_translation();
-/* Begin Display Template Prototypes */
-typedef int (*writeptype)();
-
-int ldap_init_templates();
-int ldap_init_templates_buf();
-void ldap_free_templates();
-struct ldap_disptmpl *ldap_first_disptmpl();
-struct ldap_disptmpl *ldap_next_disptmpl();
-struct ldap_disptmpl *ldap_name2template();
-struct ldap_disptmpl *ldap_oc2template();
-char **ldap_tmplattrs();
-struct ldap_tmplitem *ldap_first_tmplrow();
-struct ldap_tmplitem *ldap_next_tmplrow();
-struct ldap_tmplitem *ldap_first_tmplcol();
-struct ldap_tmplitem *ldap_next_tmplcol();
-int ldap_entry2text_search();
-int ldap_entry2text();
-int ldap_vals2text();
-int ldap_entry2html_search();
-int ldap_entry2html();
-int ldap_vals2html();
-
-int ldap_init_searchprefs();
-int ldap_init_searchprefs_buf();
-void ldap_free_searchprefs();
-struct ldap_searchobj *ldap_first_searchobj();
-struct ldap_searchobj *ldap_next_searchobj();
-
-#else /* NEEDPROTOS */
-#if !defined(MACOS) && !defined(DOS) && !defined(_WIN32) && !defined(WINSOCK)
-#include <sys/time.h>
-#endif
-
-
-/*
- * Abandon functions
- */
-int ldap_abandon_ext(LDAP *ld, int msgid, LDAPControl **serverctrls,
- LDAPControl ** clientctrls);
-int ldap_abandon(LDAP *ld, int msgid);
-
-/*
- * Add functions
- */
-int ldap_add_ext(LDAP *ld, char *dn, LDAPMod **attrs,
- LDAPControl ** serverctrls, LDAPControl **clientctrls, int *msgidp);
-int ldap_add_ext_s(LDAP *ld, char *dn, LDAPMod **attrs,
- LDAPControl ** serverctrls, LDAPControl **clientctrls);
-int ldap_add(LDAP *ld, char *dn, LDAPMod **attrs);
-int ldap_add_s(LDAP *ld, char *dn, LDAPMod **attrs);
-
-/*
- * Bind functions
- */
-/* DEPRECATED */
-int ldap_bind(LDAP *ld, char *who, char *passwd, int authmethod);
-/* DEPRECATED */
-int ldap_bind_s(LDAP *ld, char *who, char *cred, int method);
-#ifdef LDAP_REFERRALS
-/* DEPRECATED */
-void ldap_set_rebind_proc(LDAP *ld, LDAP_REBIND_FUNCTION *rebindproc,
- void *extra_arg);
-#endif /* LDAP_REFERRALS */
-
-/*
- * Simple bind functions
- */
-int ldap_simple_bind(LDAP *ld, char *who, char *passwd);
-int ldap_simple_bind_s(LDAP *ld, char *who, char *passwd);
-
-/*
- * SASL functions
- */
-int ldap_sasl_bind(LDAP *ld, char *dn, char *mechanism, struct berval *cred,
- LDAPControl **serverctrls, LDAPControl **clientctrls, int *msgidp);
-int ldap_sasl_bind_s(LDAP *ld, char *dn, char *mechanism, struct berval *cred,
- LDAPControl **serverctrls, LDAPControl **clientctrls,
- struct berval **servercredp);
-
-/*
- * Kerberos functions
- */
-/* DEPRECATED */
-int ldap_kerberos_bind_s(LDAP *ld, char *who);
-/* DEPRECATED */
-int ldap_kerberos_bind1(LDAP *ld, char *who);
-/* DEPRECATED */
-int ldap_kerberos_bind1_s(LDAP *ld, char *who);
-/* DEPRECATED */
-int ldap_kerberos_bind2(LDAP *ld, char *who);
-/* DEPRECATED */
-int ldap_kerberos_bind2_s(LDAP *ld, char *who);
-
-#ifndef NO_CACHE
-/*
- * Cache functions
- */
-int ldap_enable_cache(LDAP *ld, time_t timeout, ssize_t maxmem);
-void ldap_disable_cache(LDAP *ld);
-void ldap_set_cache_options(LDAP *ld, unsigned int opts);
-void ldap_destroy_cache(LDAP *ld);
-void ldap_flush_cache(LDAP *ld);
-void ldap_uncache_entry(LDAP *ld, char *dn);
-void ldap_uncache_request(LDAP *ld, int msgid);
-#endif /* !NO_CACHE */
-
-/*
- * Compare functions
- */
-int ldap_compare_ext(LDAP *ld, char *dn, char *attr, struct berval *bvalue,
- LDAPControl ** serverctrls, LDAPControl **clientctrls, int *msgidp);
-int ldap_compare_ext_s(LDAP *ld, char *dn, char *attr, struct berval *bvalue,
- LDAPControl ** serverctrls, LDAPControl **clientctrls);
-int ldap_compare(LDAP *ld, char *dn, char *attr, char *value);
-int ldap_compare_s(LDAP *ld, char *dn, char *attr, char *value);
-
-/*
- * Delete functions
- */
-int ldap_delete_ext(LDAP *ld, char *dn, LDAPControl **serverctrls,
- LDAPControl **clientctrls, int *msgidp);
-int ldap_delete_ext_s(LDAP *ld, char *dn, LDAPControl **serverctrls,
- LDAPControl **clientctrls);
-int ldap_delete(LDAP *ld, char *dn);
-int ldap_delete_s(LDAP *ld, char *dn);
-
-/*
- * Error functions
- */
-char *ldap_err2string(int err);
-
-/* DEPRECATED */
-int ldap_result2error(LDAP *ld, LDAPMessage *r, int freeit);
-/* DEPRECATED */
-void ldap_perror(LDAP *ld, char *s);
-
-/*
- * Modify functions
- */
-int ldap_modify_ext(LDAP *ld, char *dn, LDAPMod **mods,
- LDAPControl **serverctrls, LDAPControl **clientctrls, int *msgidp);
-int ldap_modify_ext_s(LDAP *ld, char *dn, LDAPMod **mods,
- LDAPControl **serverctrls, LDAPControl **clientctrls);
-int ldap_modify(LDAP *ld, char *dn, LDAPMod **mods);
-int ldap_modify_s(LDAP *ld, char *dn, LDAPMod **mods);
-
-/*
- * Modrdn functions
- */
-
-/* DEPRECATED : use ldap_rename instead */
-int ldap_modrdn0(LDAP *ld, char *dn, char *newrdn);
-/* DEPRECATED : use ldap_rename_s instead */
-int ldap_modrdn0_s(LDAP *ld, char *dn, char *newrdn);
-/* DEPRECATED : use ldap_rename instead */
-int ldap_modrdn(LDAP *ld, char *dn, char *newrdn,
- int deleteoldrdn);
-/* DEPRECATED : use ldap_rename_s instead */
-int ldap_modrdn_s(LDAP *ld, char *dn, char *newrdn,
- int deleteoldrdn);
-
-/*
- * Rename functions
- */
-int ldap_rename(LDAP *ld, char *dn, char *newrdn, char *newparent,
- int deleteoldrdn, LDAPControl ** serverctrls,
- LDAPControl **clientctrls, int *msgidp);
-int ldap_rename_s(LDAP *ld, char *dn, char *newrdn, char *newparent,
- int deleteoldrdn, LDAPControl ** serverctrls,
- LDAPControl **clientctrls);
-
-/*
- * Init/Open functions
- */
-LDAP *ldap_init(char *defhost, int defport);
-
-/* DEPRECATED : use ldap_init instead */
-LDAP *ldap_open(char *host, int port);
-
-#ifdef LDAP_SSL
-LDAP *ldap_ssl_init(char *defhost, int defport, char *keyname);
-
-/* DEPRECATED : use ldap_ssl_init instead */
-LDAP *ldap_ssl_open(char *host, int port, char *keyname);
-#endif
-
-/*
- * Entry functions
- */
-LDAPMessage *ldap_first_entry(LDAP *ld, LDAPMessage *res);
-LDAPMessage *ldap_next_entry(LDAP *ld, LDAPMessage *entry);
-int ldap_count_entries(LDAP *ld, LDAPMessage *res);
-
-/*
- * Message functions
- */
-LDAPMessage *ldap_first_message(LDAP *ld, LDAPMessage *res);
-LDAPMessage *ldap_next_message(LDAP *ld, LDAPMessage *msg);
-int ldap_count_messages(LDAP *ld, LDAPMessage *res);
-
-/*
- * Reference functions
- */
-LDAPMessage *ldap_first_reference(LDAP *ld, LDAPMessage *res);
-LDAPMessage *ldap_next_reference(LDAP *ld, LDAPMessage *msg);
-int ldap_count_references(LDAP *ld, LDAPMessage *res);
-char ** ldap_get_reference_urls(LDAP *ld, LDAPMessage *res);
-
-/*
- * Entry functions
- */
-LDAPMessage *ldap_delete_result_entry(LDAPMessage **list,
- LDAPMessage *e);
-void ldap_add_result_entry(LDAPMessage **list, LDAPMessage *e);
-
-/*
- * DN functions
- */
-char *ldap_get_dn(LDAP *ld, LDAPMessage *entry);
-char **ldap_explode_dn(char *dn, int notypes);
-char ** ldap_explode_rdn(char *rdn, int notypes);
-char *ldap_dn2ufn(char *dn);
-
-char **ldap_explode_dns(char *dn);
-int ldap_is_dns_dn(char *dn);
-char *ldap_dns_to_dn(char *dns_name, int *nameparts);
-
-/*
- * Attribute parsing functions
- */
-char *ldap_first_attribute(LDAP *ld, LDAPMessage *entry,
- BerElement **ber);
-char *ldap_next_attribute(LDAP *ld, LDAPMessage *entry,
- BerElement *ber);
-void ldap_memfree(char *mem);
-
-/*
- * Attribute Value functions
- */
-char **ldap_get_values(LDAP *ld, LDAPMessage *entry, char *target);
-struct berval **ldap_get_values_len(LDAP *ld, LDAPMessage *entry,
- char *target);
-int ldap_count_values(char **vals);
-int ldap_count_values_len(struct berval **vals);
-void ldap_value_free(char **vals);
-void ldap_value_free_len(struct berval **vals);
-
-/*
- * Result functions
- */
-int ldap_result(LDAP *ld, int msgid, int all,
- struct timeval *timeout, LDAPMessage **result);
-int ldap_msgdelete(LDAP *ld, int msgid);
-int ldap_msgfree(LDAPMessage *lm);
-int ldap_msgtype(LDAPMessage *res);
-int ldap_msgid(LDAPMessage *res);
-int ldap_parse_result(LDAP *ld, LDAPMessage *res, int *errcodep,
- char **matcheddnp, char **errmsgp, char ***referralsp,
- LDAPControl ***serverctrlsp, int freeit);
-int ldap_parse_sasl_bind_result(LDAP *ld, LDAPMessage *res,
- struct berval **servercredp, int freeit);
-int ldap_parse_extended_result(LDAP *ld, LDAPMessage *res,
- char **resultoidp, struct berval **resultdata, int freeit);
-int cldap_getmsg(LDAP *ld, struct timeval *timeout, BerElement *ber);
-
-
-/*
- * Search functions
- */
-int ldap_search_ext(LDAP *ld, char *base, int scope, char *filter,
- char **attrs, int attrsonly, LDAPControl **serverctrls,
- LDAPControl **clientctrls, struct timeval *timeoutp,
- int sizelimit, int *msgidp);
-int ldap_search_ext_s(LDAP *ld, char *base, int scope, char *filter,
- char **attrs, int attrsonly, LDAPControl **serverctrls,
- LDAPControl **clientctrls, struct timeval *timeoutp, int sizelimit,
- LDAPMessage **res);
-
-int ldap_search(LDAP *ld, char *base, int scope, char *filter,
- char **attrs, int attrsonly);
-int ldap_search_s(LDAP *ld, char *base, int scope, char *filter,
- char **attrs, int attrsonly, LDAPMessage **res);
-int ldap_search_st(LDAP *ld, char *base, int scope, char *filter,
- char **attrs, int attrsonly, struct timeval *timeout, LDAPMessage **res);
-
-/*
- * UFN functions
- */
-int ldap_ufn_search_c(LDAP *ld, char *ufn, char **attrs,
- int attrsonly, LDAPMessage **res, int (*cancelproc)(void *cl),
- void *cancelparm);
-int ldap_ufn_search_ct(LDAP *ld, char *ufn, char **attrs,
- int attrsonly, LDAPMessage **res, int (*cancelproc)(void *cl),
- void *cancelparm, char *tag1, char *tag2, char *tag3);
-int ldap_ufn_search_s(LDAP *ld, char *ufn, char **attrs,
- int attrsonly, LDAPMessage **res);
-LDAPFiltDesc *ldap_ufn_setfilter(LDAP *ld, char *fname);
-void ldap_ufn_setprefix(LDAP *ld, char *prefix);
-int ldap_ufn_timeout(void *tvparam);
-
-
-/*
- * Unbind functions
- */
-int ldap_unbind(LDAP *ld);
-int ldap_unbind_s(LDAP *ld);
-
-
-/*
- * Filter functions
- */
-LDAPFiltDesc *ldap_init_getfilter(char *fname);
-LDAPFiltDesc *ldap_init_getfilter_buf(char *buf, ssize_t buflen);
-LDAPFiltInfo *ldap_getfirstfilter(LDAPFiltDesc *lfdp, char *tagpat,
- char *value);
-LDAPFiltInfo *ldap_getnextfilter(LDAPFiltDesc *lfdp);
-void ldap_setfilteraffixes(LDAPFiltDesc *lfdp, char *prefix, char *suffix);
-void ldap_build_filter(char *buf, size_t buflen,
- char *pattern, char *prefix, char *suffix, char *attr,
- char *value, char **valwords);
-
-/*
- * Functions to free LDAPFiltDesc and LDAPmod
- */
-void ldap_getfilter_free(LDAPFiltDesc *lfdp);
-void ldap_mods_free(LDAPMod **mods, int freemods);
-
-/*
- * Friendly name functions
- */
-char *ldap_friendly_name(char *filename, char *uname,
- FriendlyMap **map);
-void ldap_free_friendlymap(FriendlyMap **map);
-
-
-/*
- * Connectionless LDAP functions
- */
-LDAP *cldap_open(char *host, int port);
-void cldap_close(LDAP *ld);
-int cldap_search_s(LDAP *ld, char *base, int scope, char *filter,
- char **attrs, int attrsonly, LDAPMessage **res, char *logdn);
-void cldap_setretryinfo(LDAP *ld, int tries, time_t timeout);
-
-
-/*
- * Sort functions
- */
-int ldap_sort_entries(LDAP *ld, LDAPMessage **chain, char *attr,
- int (*cmp)());
-int ldap_sort_values(LDAP *ld, char **vals, int (*cmp)());
-int ldap_sort_strcasecmp(char **a, char **b);
-
-
-/*
- * URL functions
- */
-int ldap_is_ldap_url(char *url);
-int ldap_url_parse(char *url, LDAPURLDesc **ludpp);
-void ldap_free_urlexts(LDAPURLExt **lues);
-void ldap_free_urldesc(LDAPURLDesc *ludp);
-int ldap_url_search(LDAP *ld, char *url, int attrsonly);
-int ldap_url_search_s(LDAP *ld, char *url, int attrsonly,
- LDAPMessage **res);
-int ldap_url_search_st(LDAP *ld, char *url, int attrsonly,
- struct timeval *timeout, LDAPMessage **res);
-char *ldap_dns_to_url(LDAP *ld, char *dns_name, char *attrs,
-char *scope, char *filter);
-char *ldap_dn_to_url(LDAP *ld, char *dn, int nameparts);
-
-
-/*
- * in Character Set functions
- */
-#ifdef STR_TRANSLATION
-void ldap_set_string_translators(LDAP *ld,
- BERTranslateProc encode_proc, BERTranslateProc decode_proc);
-int ldap_translate_from_t61(LDAP *ld, char **bufp,
- unsigned int *lenp, int free_input);
-int ldap_translate_to_t61(LDAP *ld, char **bufp,
- unsigned int *lenp, int free_input);
-void ldap_enable_translation(LDAP *ld, LDAPMessage *entry,
- int enable);
-
-#ifdef LDAP_CHARSET_8859
-int ldap_t61_to_8859(char **bufp, unsigned int *buflenp,
- int free_input);
-int ldap_8859_to_t61(char **bufp, unsigned int *buflenp,
- int free_input);
-#endif /* LDAP_CHARSET_8859 */
-#endif /* STR_TRANSLATION */
-
-/*
- * Diplay Template functions
- */
-typedef int (*writeptype)(void *writeparm, char *p, int len);
-
-int ldap_init_templates(char *file,
- struct ldap_disptmpl **tmpllistp);
-
-int ldap_init_templates_buf(char *buf, ssize_t buflen,
- struct ldap_disptmpl **tmpllistp);
-
-void ldap_free_templates(struct ldap_disptmpl *tmpllist);
-
-struct ldap_disptmpl *ldap_first_disptmpl(
- struct ldap_disptmpl *tmpllist);
-
-struct ldap_disptmpl *ldap_next_disptmpl(
- struct ldap_disptmpl *tmpllist, struct ldap_disptmpl *tmpl);
-
-struct ldap_disptmpl *ldap_name2template(char *name,
- struct ldap_disptmpl *tmpllist);
-
-struct ldap_disptmpl *ldap_oc2template(char **oclist,
- struct ldap_disptmpl *tmpllist);
-
-char **ldap_tmplattrs(struct ldap_disptmpl *tmpl,
- char **includeattrs, int exclude, unsigned int syntaxmask);
-
-struct ldap_tmplitem *ldap_first_tmplrow(struct ldap_disptmpl *tmpl);
-
-struct ldap_tmplitem *ldap_next_tmplrow(struct ldap_disptmpl *tmpl,
- struct ldap_tmplitem *row);
-
-struct ldap_tmplitem *ldap_first_tmplcol(struct ldap_disptmpl *tmpl,
- struct ldap_tmplitem *row);
-
-struct ldap_tmplitem *ldap_next_tmplcol(struct ldap_disptmpl *tmpl,
- struct ldap_tmplitem *row, struct ldap_tmplitem *col);
-
-int ldap_entry2text(LDAP *ld, char *buf, LDAPMessage *entry,
- struct ldap_disptmpl *tmpl, char **defattrs, char ***defvals,
- writeptype writeproc, void *writeparm, char *eol,
- int rdncount, unsigned int opts);
-
-int ldap_vals2text(LDAP *ld, char *buf, char **vals, char *label,
- int labelwidth, unsigned int syntaxid, writeptype writeproc,
- void *writeparm, char *eol, int rdncount);
-
-int ldap_entry2text_search(LDAP *ld, char *dn, char *base,
- LDAPMessage *entry, struct ldap_disptmpl *tmpllist,
- char **defattrs, char ***defvals, writeptype writeproc,
- void *writeparm, char *eol, int rdncount, unsigned int opts);
-
-int ldap_entry2html(LDAP *ld, char *buf, LDAPMessage *entry,
- struct ldap_disptmpl *tmpl, char **defattrs, char ***defvals,
- writeptype writeproc, void *writeparm, char *eol,
- int rdncount, unsigned int opts, char *urlprefix, char *base);
-
-int ldap_vals2html(LDAP *ld, char *buf, char **vals, char *label,
- int labelwidth, unsigned int syntaxid, writeptype writeproc,
- void *writeparm, char *eol, int rdncount, char *urlprefix);
-
-int ldap_entry2html_search(LDAP *ld, char *dn, char *base,
- LDAPMessage *entry, struct ldap_disptmpl *tmpllist,
- char **defattrs, char ***defvals, writeptype writeproc,
- void *writeparm, char *eol, int rdncount, unsigned int opts,
- char *urlprefix);
-
-
-/*
- * Search Preferences functions
- */
-int ldap_init_searchprefs(char *file,
- struct ldap_searchobj **solistp);
-
-int ldap_init_searchprefs_buf(char *buf, ssize_t buflen,
- struct ldap_searchobj **solistp);
-
-void ldap_free_searchprefs(struct ldap_searchobj *solist);
-
-struct ldap_searchobj *ldap_first_searchobj(
- struct ldap_searchobj *solist);
-
-struct ldap_searchobj *ldap_next_searchobj(
- struct ldap_searchobj *sollist, struct ldap_searchobj *so);
-
-
-/*
- * Option functions
- */
-int ldap_get_option(LDAP *ld, int option, void *outvalue);
-int ldap_set_option(LDAP *ld, int option, void *invalue);
-
-
-/*
- * Control functions
- */
-void ldap_control_free(LDAPControl *ctrl);
-void ldap_controls_free(LDAPControl **ctrls);
-
-
-/*
- * Simple Page Control functions
- */
-int ldap_create_page_control(LDAP *ld, unsigned int pagesize,
- struct berval *cookie, char isCritical, LDAPControl **output);
-int ldap_parse_page_control(LDAP *ld, LDAPControl **controls,
- unsigned int *totalcount, struct berval **cookie);
-
-/*
- * Server Side Sort control functions
- */
-int ldap_create_sort_control(LDAP *ld, LDAPsortkey **sortKeyList,
- const char ctl_iscritical, LDAPControl **ctrlp);
-int ldap_parse_sort_control(LDAP *ld, LDAPControl **ctrlp,
- unsigned long *result, char **attribute);
-int ldap_create_sort_keylist(LDAPsortkey ***sortKeyList, char *string_rep);
-void ldap_free_sort_keylist(LDAPsortkey **sortKeyList);
-
-/*
- * Virtual List View control functions
- */
-int ldap_create_virtuallist_control(LDAP *ld, LDAPVirtualList *ldvlistp,
- LDAPControl **ctrlp);
-int ldap_parse_virtuallist_control(LDAP *ld, LDAPControl **ctrls,
- unsigned long *target_posp, unsigned long *list_sizep,
- int *errcodep);
-
-#endif /* NEEDPROTOS */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _LDAP_H */
diff --git a/usr/src/lib/libldap4/include/ldapconfig.h b/usr/src/lib/libldap4/include/ldapconfig.h
deleted file mode 100644
index c197c3c33c..0000000000
--- a/usr/src/lib/libldap4/include/ldapconfig.h
+++ /dev/null
@@ -1,279 +0,0 @@
-/*
- *
- * Portions Copyright 1998 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- *
- * File chamged to fit with Sun Standards
- *
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*
- * Copyright (c) 1994 Regents of the University of Michigan.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms are permitted
- * provided that this notice is preserved and that due credit is given
- * to the University of Michigan at Ann Arbor. The name of the University
- * may not be used to endorse or promote products derived from this
- * software without specific prior written permission. This software
- * is provided ``as is'' without express or implied warranty.
- */
-
-#ifndef _CONFIG_H
-#define _CONFIG_H
-
-/*
- * config.h for LDAP -- edit this file to customize LDAP client behavior.
- * NO platform-specific definitions should be placed in this file.
- * Note that this is NOT used by the LDAP or LBER libraries.
- */
-
-/*
- * SHARED DEFINITIONS - things you should change
- */
- /* default ldap host */
-#define LDAPHOST "localhost"
- /* default place to start searching */
-#define DEFAULT_BASE "c=US"
-
-/*********************************************************************
- * *
- * You probably do not need to edit anything below this point *
- * *
- *********************************************************************/
-
-/*
- * SHARED DEFINITIONS - other things you can change
- */
- /* default attribute to use when sorting entries, NULL => sort by DN */
-#define SORT_ATTR NULL
- /* default count of DN components to show in entry displays */
-#define DEFAULT_RDNCOUNT 2
- /* default config file locations */
-#define FILTERFILE "/etc/opt/SUNWconn/ldap/current/ldapfilter.conf"
-#define TEMPLATEFILE "/etc/opt/SUNWconn/ldap/current/ldaptemplates.conf"
-#define SEARCHFILE "/etc/opt/SUNWconn/ldap/current/ldapsearchprefs.conf"
-#define FRIENDLYFILE "/etc/opt/SUNWconn/ldap/current/ldapfriendly"
-
-/*
- * FINGER DEFINITIONS
- */
- /* who to bind as */
-#define FINGER_BINDDN NULL
- /* where to search */
-#define FINGER_BASE DEFAULT_BASE
- /* banner to print */
-#define FINGER_BANNER "X.500 Finger Service...\r\n"
- /* who to report errors to */
-#define FINGER_ERRORS "your local system administrator"
- /* what to say if no matches are found */
-#define FINGER_NOMATCH "Search failed to find anything.\r\n"
- /* what to say if the service may be unavailable */
-#define FINGER_UNAVAILABLE \
-"The X.500 service may be temporarily unavailable.\r\n\
-Please try again later.\r\n"
- /* printed if a match has no email address - for disptmp default */
-#define FINGER_NOEMAIL1 "None registered in this service."
-#define FINGER_NOEMAIL2 NULL
-#define FINGER_NOEMAIL { FINGER_NOEMAIL1, FINGER_NOEMAIL2, NULL }
- /* maximum number of matches returned */
-#define FINGER_SIZELIMIT 50
- /* max number of hits displayed in full before a list is presented */
-#define FINGER_LISTLIMIT 1
- /* what to exec for "finger @host" */
-#define FINGER_CMD "/usr/ucb/finger"
- /* how to treat aliases when searching */
-#define FINGER_DEREF LDAP_DEREF_FINDING
- /* attribute to use when sorting results */
-#define FINGER_SORT_ATTR SORT_ATTR
- /* enable ufn support */
-#define FINGER_UFN
- /* timeout for searches */
-#define FINGER_TIMEOUT 60
- /* number of DN components to show in entry displays */
-#define FINGER_RDNCOUNT DEFAULT_RDNCOUNT
-
-/*
- * GO500 GOPHER GATEWAY DEFINITIONS
- */
- /* who to bind as */
-#define GO500_BINDDN NULL
- /* where to search */
-#define GO500_BASE DEFAULT_BASE
- /* port on which to listen */
-#define GO500_PORT 5555
- /* how to handle aliases */
-#define GO500_DEREF LDAP_DEREF_FINDING
- /* attribute to use when sorting results */
-#define GO500_SORT_ATTR SORT_ATTR
- /* timeout for searches */
-#define GO500_TIMEOUT 180
- /* enable ufn support */
-#define GO500_UFN
- /*
- * only set and uncomment this if your hostname() does not return
- * a fully qualified hostname
- */
-/* #define GO500_HOSTNAME "fully.qualified.hostname.here" */
- /* number of DN components to show in entry displays */
-#define GO500_RDNCOUNT DEFAULT_RDNCOUNT
-
-/*
- * GO500GW GOPHER GATEWAY DEFINITIONS
- */
- /* who to bind as */
-#define GO500GW_BINDDN NULL
- /* where the helpfile lives */
-#define GO500GW_HELPFILE "go500gw.help"
- /* port on which to listen */
-#define GO500GW_PORT 7777
- /* timeout on all searches */
-#define GO500GW_TIMEOUT 180
- /* enable ufn support */
-#define GO500GW_UFN
- /* attribute to use when sorting results */
-#define GO500GW_SORT_ATTR SORT_ATTR
- /*
- * only set and uncomment this if your hostname() does not return
- * a fully qualified hostname
- */
-/* #define GO500GW_HOSTNAME "fully.qualified.hostname.here" */
- /* number of DN components to show in entry displays */
-#define GO500GW_RDNCOUNT DEFAULT_RDNCOUNT
-
-/*
- * RCPT500 MAIL RESPONDER GATEWAY DEFINITIONS
- */
- /* who to bind as */
-#define RCPT500_BINDDN NULL
- /* where the helpfile lives */
-#define RCPT500_HELPFILE "rcpt500.help"
- /* maximum number of matches returned */
-#define RCPT500_SIZELIMIT 50
- /* address replies will appear to come from */
-#define RCPT500_FROM "\"X.500 Query Program\" <X500-Query>"
- /* command that will accept an RFC822 message text on standard
- input, and send it. sendmail -t does this nicely. */
-#define RCPT500_PIPEMAILCMD "/usr/lib/sendmail -t"
- /* where to search */
-#define RCPT500_BASE DEFAULT_BASE
- /* attribute to use when sorting results */
-#define RCPT500_SORT_ATTR SORT_ATTR
- /* max number of hits displayed in full before a list is presented */
-#define RCPT500_LISTLIMIT 1
- /* enable ufn support */
-#define RCPT500_UFN
- /* number of DN components to show in entry displays */
-#define RCPT500_RDNCOUNT DEFAULT_RDNCOUNT
-
-/*
- * LDAPSEARCH TOOL
- */
- /* who to bind as */
-#define LDAPSEARCH_BINDDN NULL
- /* search base */
-#define LDAPSEARCH_BASE DEFAULT_BASE
-
-/*
- * LDAPMODIFY TOOL
- */
- /* who to bind as */
-#define LDAPMODIFY_BINDDN NULL
- /* search base */
-#define LDAPMODIFY_BASE DEFAULT_BASE
-
-/*
- * LDAPDELETE TOOL
- */
- /* who to bind as */
-#define LDAPDELETE_BINDDN NULL
- /* search base */
-#define LDAPDELETE_BASE DEFAULT_BASE
-
-/*
- * LDAPMODRDN TOOL
- */
- /* who to bind as */
-#define LDAPMODRDN_BINDDN NULL
- /* search base */
-#define LDAPMODRDN_BASE DEFAULT_BASE
-
-/*
- * MAIL500 MAILER DEFINITIONS
- */
- /* who to bind as */
-#define MAIL500_BINDDN NULL
- /* max number of ambiguous matches reported */
-#define MAIL500_MAXAMBIGUOUS 10
- /* max subscribers allowed (size limit when searching for them ) */
-#define MAIL500_MAXGROUPMEMBERS LDAP_NO_LIMIT
- /* timeout for all searches */
-#define MAIL500_TIMEOUT 180
- /* sendmail location - mail500 needs to exec this */
-#define MAIL500_SENDMAIL "/usr/lib/sendmail"
-
-/*
- * UD DEFINITIONS
- */
- /* ud configuration file */
-#define UD_CONFIG_FILE "/etc/opt/SUNWconn/ldap/current/ud.conf"
- /* default editor */
-#define UD_DEFAULT_EDITOR "/usr/ucb/vi"
- /* default bbasename of user config file */
-#define UD_USER_CONFIG_FILE ".udrc"
- /* default user to bind as */
-#define UD_BINDDN NULL
- /* default password to bind with */
-#define UD_PASSWD NULL
- /* default search base */
-#define UD_BASE DEFAULT_BASE
- /* default base where groups are created */
-#define UD_WHERE_GROUPS_ARE_CREATED ""
- /* default base below which all groups live */
-#define UD_WHERE_ALL_GROUPS_LIVE ""
-
-/*
- * FAX500 DEFINITIONS
- */
- /* what to bind as */
-#define FAX_BINDDN NULL
- /* how long to wait for searches */
-#define FAX_TIMEOUT 180
- /* maximum number of ambiguous matches reported */
-#define FAX_MAXAMBIGUOUS 10
- /* maximum number of members allowed */
-#define FAX_MAXMEMBERS LDAP_NO_LIMIT
- /* program to send mail */
-#define FAX_SENDMAIL "/usr/lib/sendmail"
-
-/*
- * RP500 DEFINITIONS
- */
- /* what to bind as */
-#define RP_BINDDN NULL
- /* prefix to add to non-fully-qualified numbers */
-#define RP_PHONEPREFIX ""
-
-/*
- * SLAPD DEFINITIONS
- */
- /* location of the default slapd config file */
-#define SLAPD_DEFAULT_CONFIGFILE "/etc/opt/SUNWconn/ldap/current/slapd.conf"
- /* default sizelimit on number of entries from a search */
-#define SLAPD_DEFAULT_SIZELIMIT 10000
- /* default timelimit to spend on a search */
-#define SLAPD_DEFAULT_TIMELIMIT 3600
- /* location of the slapd pid file */
-#define SLAPD_PIDFILE "/var/opt/SUNWconn/ldap/log/slapd.pid"
- /* location of the slapd args file */
-#define SLAPD_ARGSFILE "/var/opt/SUNWconn/ldap/log/slapd.args"
- /* dn of the special "monitor" entry */
-#define SLAPD_MONITOR_DN "cn=monitor"
- /* dn of the special "config" entry */
-#define SLAPD_CONFIG_DN "cn=config"
- /* minimum max ids that a single index entry can map to in ldbm */
-#define SLAPD_LDBM_MIN_MAXIDS 4000
-
-#endif /* _CONFIG_H */
diff --git a/usr/src/lib/libldap4/include/ldif.h b/usr/src/lib/libldap4/include/ldif.h
deleted file mode 100644
index 4eddf63095..0000000000
--- a/usr/src/lib/libldap4/include/ldif.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- *
- * Portions Copyright 1998 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- *
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*
- * Copyright (c) 1996 Regents of the University of Michigan.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms are permitted
- * provided that this notice is preserved and that due credit is given
- * to the University of Michigan at Ann Arbor. The name of the University
- * may not be used to endorse or promote products derived from this
- * software without specific prior written permission. This software
- * is provided ``as is'' without express or implied warranty.
- */
-
-#ifndef _LDIF_H
-#define _LDIF_H
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#define LINE_WIDTH 76 /* maximum length of LDIF lines */
-
-/*
- * Macro to calculate maximum number of bytes that the base64 equivalent
- * of an item that is "vlen" bytes long will take up. Base64 encoding
- * uses one byte for every six bits in the value plus up to two pad bytes.
- */
-#define LDIF_BASE64_LEN(vlen) (((vlen) * 4 / 3 ) + 3)
-
-/*
- * Macro to calculate maximum size that an LDIF-encoded type (length
- * tlen) and value (length vlen) will take up: room for type + ":: " +
- * first newline + base64 value + continued lines. Each continued line
- * needs room for a newline and a leading space character.
- */
-#define LDIF_SIZE_NEEDED(tlen,vlen) \
- ((tlen) + 4 + LDIF_BASE64_LEN(vlen) \
- + ((LDIF_BASE64_LEN(vlen) + tlen + 3) / LINE_WIDTH * 2 ))
-
-
-#ifdef NEEDPROTOS
-int str_parse_line( char *line, char **type, char **value, int *vlen);
-char * str_getline( char **next );
-void put_type_and_value( char **out, char *t, char *val, int vlen );
-char *ldif_type_and_value( char *type, char *val, int vlen );
-#else /* NEEDPROTOS */
-int str_parse_line();
-char * str_getline();
-void put_type_and_value();
-char *ldif_type_and_value();
-#endif /* NEEDPROTOS */
-
-#ifdef __cplusplus
-}
-#endif
-
-#endif /* _LDIF_H */
diff --git a/usr/src/lib/libldap4/include/log.h b/usr/src/lib/libldap4/include/log.h
deleted file mode 100644
index 038f0564e3..0000000000
--- a/usr/src/lib/libldap4/include/log.h
+++ /dev/null
@@ -1,65 +0,0 @@
-/*
- *
- * Copyright 1998 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- *
- */
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#ifndef _LLOG_H
-#define _LLOG_H
-
-
-#include <stdio.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <nl_types.h>
-#include <limits.h>
-#include <syslog.h>
-#include <portable.h>
-
-
-
-/* Log levels */
-
-/* slapd values */
-#define LDAP_DEBUG_TRACE 0x001
-#define LDAP_DEBUG_PACKETS 0x002
-#define LDAP_DEBUG_ARGS 0x004
-#define LDAP_DEBUG_CONNS 0x008
-#define LDAP_DEBUG_BER 0x010
-#define LDAP_DEBUG_FILTER 0x020
-#define LDAP_DEBUG_CONFIG 0x040
-#define LDAP_DEBUG_ACL 0x080
-#define LDAP_DEBUG_STATS 0x100
-#define LDAP_DEBUG_STATS2 0x200
-#define LDAP_DEBUG_SHELL 0x400
-#define LDAP_DEBUG_PARSE 0x800
-/* More values for http gateway */
-#define LDAP_DEBUG_GWAY 0x1000
-#define LDAP_DEBUG_GWAYMORE 0x2000
-/* Generic values */
-#define LDAP_DEBUG_ANY 0xffff
-
-nl_catd sundscat;
-extern nl_catd slapdcat;
-extern void ldaplogconfig(char * logf, int size);
-extern void ldaplogconfigf(FILE *fd);
-extern void ldaploginit(char *name,
- int facility);
-extern void ldaploginitlevel(char *name,
- int facility,
- int log_level);
-extern void ldaplog(int level,char *fmt,...);
-
-#define Statslog( level, fmt, connid, opid, arg1, arg2, arg3 ) \
-{ \
- if ( log_debug & level ) \
- fprintf( stderr, fmt, connid, opid, arg1, arg2, arg3 );\
- if ( log_syslog & level ) \
- ldaplog( level, fmt, connid, opid, arg1, arg2, arg3 ); \
-}
-#endif /* _LLOG_H */
-
-
-
diff --git a/usr/src/lib/libldap4/include/lthread.h b/usr/src/lib/libldap4/include/lthread.h
deleted file mode 100644
index cbafb7fec8..0000000000
--- a/usr/src/lib/libldap4/include/lthread.h
+++ /dev/null
@@ -1,187 +0,0 @@
-/*
- *
- * Portions Copyright 1998 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- *
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/* lthread.h - ldap threads header file */
-
-#ifndef _LTHREAD_H
-#define _LTHREAD_H
-
-#if defined( THREAD_SUNOS4_LWP )
-/***********************************
- * *
- * thread definitions for sunos4 *
- * *
- ***********************************/
-
-#define _THREAD
-
-#include <lwp/lwp.h>
-#include <lwp/stackdep.h>
-
-typedef void *(*VFP)();
-
-/* thread attributes and thread type */
-typedef int pthread_attr_t;
-typedef thread_t pthread_t;
-
-/* default attr states */
-#define pthread_mutexattr_default NULL
-#define pthread_condattr_default NULL
-
-/* thread state - joinable or not */
-#define PTHREAD_CREATE_JOINABLE 0
-#define PTHREAD_CREATE_DETACHED 1
-/* thread scope - who is in scheduling pool */
-#define PTHREAD_SCOPE_PROCESS 0
-#define PTHREAD_SCOPE_SYSTEM 1
-
-/* mutex attributes and mutex type */
-typedef int pthread_mutexattr_t;
-typedef mon_t pthread_mutex_t;
-
-/* condition variable attributes and condition variable type */
-typedef int pthread_condattr_t;
-typedef struct lwpcv {
- int lcv_created;
- cv_t lcv_cv;
-} pthread_cond_t;
-
-/* mutex and condition variable scope - process or system */
-#define PTHREAD_SHARE_PRIVATE 0
-#define PTHREAD_SHARE_PROCESS 1
-
-#else /* end sunos4 */
-
-#if defined( THREAD_SUNOS5_LWP )
-/***********************************
- * *
- * thread definitions for sunos5 *
- * *
- ***********************************/
-
-#define _THREAD
-
-#include <thread.h>
-#include <synch.h>
-
-typedef void *(*VFP)();
-
-/* sunos5 threads are preemptive */
-#define PTHREAD_PREEMPTIVE 1
-
-#ifndef _PTHREAD_H
-
-/* thread attributes and thread type */
-typedef int pthread_attr_t;
-typedef thread_t pthread_t;
-
-/* thread state - joinable or not */
-#define PTHREAD_CREATE_JOINABLE 0
-#define PTHREAD_CREATE_DETACHED THR_DETACHED
-/* thread scope - who is in scheduling pool */
-#define PTHREAD_SCOPE_PROCESS 0
-#define PTHREAD_SCOPE_SYSTEM THR_BOUND
-
-/* mutex attributes and mutex type */
-typedef int pthread_mutexattr_t;
-typedef mutex_t pthread_mutex_t;
-
-/* condition variable attributes and condition variable type */
-typedef int pthread_condattr_t;
-typedef cond_t pthread_cond_t;
-
-#endif /* _PTHREAD_H */
-
-/* default attr states */
-#define pthread_mutexattr_default NULL
-#define pthread_condattr_default NULL
-
-/* mutex and condition variable scope - process or system */
-#define PTHREAD_SHARE_PRIVATE USYNC_THREAD
-#define PTHREAD_SHARE_PROCESS USYNC_PROCESS
-
-#else /* end sunos5 */
-
-#if defined( THREAD_MIT_PTHREADS )
-/***********************************
- * *
- * definitions for mit pthreads *
- * *
- ***********************************/
-
-#define _THREAD
-
-#include <pthread.h>
-
-#else /* end mit pthreads */
-
-#if defined( THREAD_DCE_PTHREADS )
-/***********************************
- * *
- * definitions for dce pthreads *
- * *
- ***********************************/
-
-#define _THREAD
-
-#include <pthread.h>
-
-/* dce threads are preemptive */
-#define PTHREAD_PREEMPTIVE 1
-
-#define pthread_attr_init( a ) pthread_attr_create( a )
-#define pthread_attr_destroy( a ) pthread_attr_delete( a )
-#define pthread_attr_setdetachstate( a, b ) \
- pthread_attr_setdetach_np( a, b )
-
-#endif /* dce pthreads */
-#endif /* mit pthreads */
-#endif /* sunos5 */
-#endif /* sunos4 */
-
-#ifndef _THREAD
-
-/***********************************
- * *
- * thread definitions for no *
- * underlying library support *
- * *
- ***********************************/
-
-typedef void *(*VFP)();
-
-/* thread attributes and thread type */
-typedef int pthread_attr_t;
-typedef int pthread_t;
-
-/* default attr states */
-#define pthread_mutexattr_default NULL
-#define pthread_condattr_default NULL
-
-/* thread state - joinable or not */
-#define PTHREAD_CREATE_JOINABLE 0
-#define PTHREAD_CREATE_DETACHED 0
-/* thread scope - who is in scheduling pool */
-#define PTHREAD_SCOPE_PROCESS 0
-#define PTHREAD_SCOPE_SYSTEM 0
-
-/* mutex attributes and mutex type */
-typedef int pthread_mutexattr_t;
-typedef int pthread_mutex_t;
-
-/* mutex and condition variable scope - process or system */
-#define PTHREAD_SHARE_PRIVATE 0
-#define PTHREAD_SHARE_PROCESS 0
-
-/* condition variable attributes and condition variable type */
-typedef int pthread_condattr_t;
-typedef int pthread_cond_t;
-
-#endif /* no threads support */
-#endif /* _LTHREAD_H */
diff --git a/usr/src/lib/libldap4/include/portable.h b/usr/src/lib/libldap4/include/portable.h
deleted file mode 100644
index 5405fa8765..0000000000
--- a/usr/src/lib/libldap4/include/portable.h
+++ /dev/null
@@ -1,224 +0,0 @@
-/*
- *
- * Portions Copyright 1998 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- *
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*
- * Copyright (c) 1994 Regents of the University of Michigan.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms are permitted
- * provided that this notice is preserved and that due credit is given
- * to the University of Michigan at Ann Arbor. The name of the University
- * may not be used to endorse or promote products derived from this
- * software without specific prior written permission. This software
- * is provided ``as is'' without express or implied warranty.
- */
-
-#ifndef _PORTABLE_H
-#define _PORTABLE_H
-
-/*
- * portable.h for LDAP -- this is where we define common stuff to make
- * life easier on various Unix systems.
- *
- * Unless you are porting LDAP to a new platform, you should not need to
- * edit this file.
- */
-
-
-#ifndef SYSV
-#if defined( hpux ) || defined( sunos5 ) || defined ( sgi ) || defined( SVR4 )
-#define SYSV
-#endif
-#endif
-
-
-/*
- * under System V, use sysconf() instead of getdtablesize
- */
-#if !defined( USE_SYSCONF ) && defined( SYSV )
-#define USE_SYSCONF
-#endif
-
-
-/*
- * under System V, daemons should use setsid() instead of detaching from their
- * tty themselves
- */
-#if !defined( USE_SETSID ) && defined( SYSV )
-#define USE_SETSID
-#endif
-
-
-/*
- * System V has socket options in filio.h
- */
-#if !defined( NEED_FILIO ) && defined( SYSV ) && !defined( hpux )
-#define NEED_FILIO
-#endif
-
-/*
- * use lockf() under System V
- */
-#if !defined( USE_LOCKF ) && ( defined( SYSV ) || defined( aix ))
-#define USE_LOCKF
-#endif
-
-/*
- * on many systems, we should use waitpid() instead of waitN()
- */
-#if !defined( USE_WAITPID ) && ( defined( SYSV ) || defined( sunos4 ) || defined( ultrix ) || defined( aix ))
-#define USE_WAITPID
-#endif
-
-
-/*
- * define the wait status argument type
- */
-#if ( defined( SunOS ) && SunOS < 40 ) || defined( nextstep )
-#define WAITSTATUSTYPE union wait
-#else
-#define WAITSTATUSTYPE int
-#endif
-
-/*
- * define the flags for wait
- */
-#ifdef sunos5
-#define WAIT_FLAGS ( WNOHANG | WUNTRACED | WCONTINUED )
-#else
-#define WAIT_FLAGS ( WNOHANG | WUNTRACED )
-#endif
-
-
-/*
- * defined the options for openlog (syslog)
- */
-#ifdef ultrix
-#define OPENLOG_OPTIONS LOG_PID
-#else
-#define OPENLOG_OPTIONS ( LOG_PID | LOG_NOWAIT )
-#endif
-
-
-/*
- * some systems don't have the BSD re_comp and re_exec routines
- */
-#ifndef NEED_BSDREGEX
-#if defined( SYSV ) || defined( VMS ) || defined( netbsd ) || defined( freebsd ) || defined( linux )
-#define NEED_BSDREGEX
-#endif
-#endif
-
-/*
- * many systems do not have the setpwfile() library routine... we just
- * enable use for those systems we know have it.
- */
-#ifndef HAVE_SETPWFILE
-#if defined( sunos4 ) || defined( ultrix ) || defined( __osf__ )
-#define HAVE_SETPWFILE
-#endif
-#endif
-
-/*
- * Are sys_errlist and sys_nerr declared in stdio.h?
- */
-#ifndef SYSERRLIST_IN_STDIO
-#if defined( freebsd )
-#define SYSERRLIST_IN_STDIO
-#endif
-#endif
-
-/*
- * for select()
- */
-#if !defined(FD_SET) && !defined(WINSOCK)
-#define NFDBITS 32
-#define FD_SETSIZE 32
-#define FD_SET(n, p) ((p)->fds_bits[(n)/NFDBITS] |= (1 << ((n) % NFDBITS)))
-#define FD_CLR(n, p) ((p)->fds_bits[(n)/NFDBITS] &= ~(1 << ((n) % NFDBITS)))
-#define FD_ISSET(n, p) ((p)->fds_bits[(n)/NFDBITS] & (1 << ((n) % NFDBITS)))
-#define FD_ZERO(p) bzero((char *)(p), sizeof(*(p)))
-#endif /* FD_SET */
-
-#if defined( hpux ) && defined( __STDC__ )
-/*
- * Under HP/UX, select seems to want (int *) instead of fd_set. Non-ANSI
- * compilers don't like recursive macros, so ignore the problem if __STDC__
- * is not defined.
- */
-#define select(a,b,c,d,e) select(a, (int *)b, (int *)c, (int *)d, e)
-#endif /* hpux && __STDC__ */
-
-
-/*
- * for signal() -- what do signal handling functions return?
- */
-#ifndef SIG_FN
-#ifdef sunos5
-# define SIG_FN void /* signal-catching functions return void */
-#else /* sunos5 */
-# ifdef BSD
-# if (BSD >= 199006) || defined(NeXT) || defined(__osf__) || defined(sun) || defined(ultrix) || defined(apollo) || defined(POSIX_SIGNALS)
-# define SIG_FN void /* signal-catching functions return void */
-# else
-# define SIG_FN int /* signal-catching functions return int */
-# endif
-# else /* BSD */
-# define SIG_FN void /* signal-catching functions return void */
-# endif /* BSD */
-#endif /* sunos5 */
-#endif /* SIG_FN */
-
-/*
- * call signal or sigset (signal does not block the signal while
- * in the handler on sys v and sigset does not exist on bsd)
- */
-#ifdef SYSV
-#define SIGNAL sigset
-#else
-#define SIGNAL signal
-#endif
-
-/*
- * toupper and tolower macros are different under bsd and sys v
- */
-#if defined( SYSV ) && !defined( hpux )
-#define TOUPPER(c) (isascii(c) && islower(c) ? _toupper(c) : c)
-#define TOLOWER(c) (isascii(c) && isupper(c) ? _tolower(c) : c)
-#else
-#define TOUPPER(c) (isascii(c) && islower(c) ? toupper(c) : c)
-#define TOLOWER(c) (isascii(c) && isupper(c) ? tolower(c) : c)
-#endif
-
-/*
- * put a cover on the tty-related ioctl calls we need to use
- */
-#if defined( NeXT ) || (defined(SunOS) && SunOS < 40)
-#define TERMIO_TYPE struct sgttyb
-#define TERMFLAG_TYPE int
-#define GETATTR( fd, tiop ) ioctl((fd), TIOCGETP, (caddr_t)(tiop))
-#define SETATTR( fd, tiop ) ioctl((fd), TIOCSETP, (caddr_t)(tiop))
-#define GETFLAGS( tio ) (tio).sg_flags
-#define SETFLAGS( tio, flags ) (tio).sg_flags = (flags)
-#else
-#define USE_TERMIOS
-#define TERMIO_TYPE struct termios
-#define TERMFLAG_TYPE tcflag_t
-#define GETATTR( fd, tiop ) tcgetattr((fd), (tiop))
-#define SETATTR( fd, tiop ) tcsetattr((fd), TCSANOW /* 0 */, (tiop))
-#define GETFLAGS( tio ) (tio).c_lflag
-#define SETFLAGS( tio, flags ) (tio).c_lflag = (flags)
-#endif
-
-
-#if defined( ultrix ) || defined( nextstep )
-extern char *strdup();
-#endif /* ultrix || nextstep */
-
-#endif /* _PORTABLE_H */
diff --git a/usr/src/lib/libldap4/include/regex.h b/usr/src/lib/libldap4/include/regex.h
deleted file mode 100644
index 175a851878..0000000000
--- a/usr/src/lib/libldap4/include/regex.h
+++ /dev/null
@@ -1,52 +0,0 @@
-/*
- *
- * Portions Copyright 1998 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- *
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#if defined( MACOS ) || defined( DOS ) || defined( _WIN32 ) || defined( NEED_BSDREGEX )
-/*
- * Copyright (c) 1993 Regents of the University of Michigan.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms are permitted
- * provided that this notice is preserved and that due credit is given
- * to the University of Michigan at Ann Arbor. The name of the University
- * may not be used to endorse or promote products derived from this
- * software without specific prior written permission. This software
- * is provided ``as is'' without express or implied warranty.
- */
-/*
- * regex.h -- includes for regular expression matching routines
- * 13 August 1993 Mark C Smith
- */
-
-#ifdef __cplusplus
-extern "C" {
-#endif
-
-#if !defined( NEEDPROTOS ) && defined( __STDC__ )
-#define NEEDPROTOS
-#endif
-
-#ifdef NEEDPROTOS
-char *re_comp( char *pat );
-int re_exec( char *lp );
-void re_modw( char *s );
-int re_subs( char *src, char *dst );
-#else /* NEEDPROTOS */
-char *re_comp();
-int re_exec();
-void re_modw();
-int re_subs();
-#endif /* NEEDPROTOS */
-
-#define re_fail( m, p )
-
-#ifdef __cplusplus
-}
-#endif
-#endif /* MACOS or DOS or NEED_BSDREGEX */
diff --git a/usr/src/lib/libldap4/include/sec.h b/usr/src/lib/libldap4/include/sec.h
deleted file mode 100644
index 11d94760cc..0000000000
--- a/usr/src/lib/libldap4/include/sec.h
+++ /dev/null
@@ -1,25 +0,0 @@
-/*
- *
- * Copyright 1999 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- *
- *
- * Comments:
- *
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#ifndef _SEC_H_
-#define _SEC_H_
-
-#include <sys/types.h>
-#include <md5.h>
-
-void hmac_md5(unsigned char *text, int text_len, unsigned char *key,
- int key_len, unsigned char *digest);
-
-char *hexa_print(unsigned char *aString, int aLen);
-char *hexa2str(char *anHexaStr, int *aResLen);
-
-#endif /* _SEC_H_ */
diff --git a/usr/src/lib/libldap4/include/ssl.h b/usr/src/lib/libldap4/include/ssl.h
deleted file mode 100644
index bd0c860a3a..0000000000
--- a/usr/src/lib/libldap4/include/ssl.h
+++ /dev/null
@@ -1,41 +0,0 @@
-/*
- *
- * Portions Copyright 1998 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- *
- *
- * This is a dummy header file for SSL
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#ifndef _SSL_H
-#define _SSL_H
-
-#include <sys/types.h>
-
-typedef void * SSL;
-
-SSL SSL_new();
-int SSL_connect(SSL s, int filedes);
-int SSL_accept(SSL s, int filedes);
-int SSL_read(SSL s, u_char *buf, u_int len);
-int SSL_write(SSL s, u_char *buf, u_int len);
-int SSL_fread(SSL s, u_char *buf, u_int len);
-int SSL_fwrite(SSL s, u_char *buf, u_int len);
-int SSL_flush(SSL s);
-int SSL_close(SSL s);
-int SSL_delete(SSL s);
-char **SSL_get_supported_ciphers();
-int SSL_get_cipher(SSL s, char **cipher);
-int SSL_set_cipher(SSL s, char **cipher);
-int SSL_set_verification(SSL s, char **root_ca_list, int *certificate_type_list);
-int SSL_set_userid(SSL s, char *name, char *id);
-int SSL_save_session(SSL s, u_char **id, int *len);
-int SSL_set_session(SSL s, u_char *id, int len);
-int SSL_delete_session(u_char *id, int len);
-int SSL_errno(SSL s);
-char *SSL_strerr(int err);
-int SSL_get_fd(SSL s);
-
-#endif _SSL_H
diff --git a/usr/src/lib/libldap4/include/sysexits-compat.h b/usr/src/lib/libldap4/include/sysexits-compat.h
deleted file mode 100644
index 0e5e37e3d7..0000000000
--- a/usr/src/lib/libldap4/include/sysexits-compat.h
+++ /dev/null
@@ -1,111 +0,0 @@
-/*
- *
- * Portions Copyright 1998 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- *
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-/*
- * Copyright (c) 1987 Regents of the University of California.
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms are permitted
- * provided that the above copyright notice and this paragraph are
- * duplicated in all such forms and that any documentation,
- * advertising materials, and other materials related to such
- * distribution and use acknowledge that the software was developed
- * by the University of California, Berkeley. The name of the
- * University may not be used to endorse or promote products derived
- * from this software without specific prior written permission.
- * THIS SOFTWARE IS PROVIDED ``AS IS'' AND WITHOUT ANY EXPRESS OR
- * IMPLIED WARRANTIES, INCLUDING, WITHOUT LIMITATION, THE IMPLIED
- * WARRANTIES OF MERCHANTIBILITY AND FITNESS FOR A PARTICULAR PURPOSE.
- *
- * @(#)sysexits.h 4.5 (Berkeley) 7/6/88
- */
-
-/*
-** SYSEXITS.H -- Exit status codes for system programs.
-**
-** This include file attempts to categorize possible error
-** exit statuses for system programs, notably delivermail
-** and the Berkeley network.
-**
-** Error numbers begin at EX__BASE to reduce the possibility of
-** clashing with other exit statuses that random programs may
-** already return. The meaning of the codes is approximately
-** as follows:
-**
-** EX_USAGE -- The command was used incorrectly, e.g., with
-** the wrong number of arguments, a bad flag, a bad
-** syntax in a parameter, or whatever.
-** EX_DATAERR -- The input data was incorrect in some way.
-** This should only be used for user's data & not
-** system files.
-** EX_NOINPUT -- An input file (not a system file) did not
-** exist or was not readable. This could also include
-** errors like "No message" to a mailer (if it cared
-** to catch it).
-** EX_NOUSER -- The user specified did not exist. This might
-** be used for mail addresses or remote logins.
-** EX_NOHOST -- The host specified did not exist. This is used
-** in mail addresses or network requests.
-** EX_UNAVAILABLE -- A service is unavailable. This can occur
-** if a support program or file does not exist. This
-** can also be used as a catchall message when something
-** you wanted to do doesn't work, but you don't know
-** why.
-** EX_SOFTWARE -- An internal software error has been detected.
-** This should be limited to non-operating system related
-** errors as possible.
-** EX_OSERR -- An operating system error has been detected.
-** This is intended to be used for such things as "cannot
-** fork", "cannot create pipe", or the like. It includes
-** things like getuid returning a user that does not
-** exist in the passwd file.
-** EX_OSFILE -- Some system file (e.g., /etc/passwd, /etc/utmp,
-** etc.) does not exist, cannot be opened, or has some
-** sort of error (e.g., syntax error).
-** EX_CANTCREAT -- A (user specified) output file cannot be
-** created.
-** EX_IOERR -- An error occurred while doing I/O on some file.
-** EX_TEMPFAIL -- temporary failure, indicating something that
-** is not really an error. In sendmail, this means
-** that a mailer (e.g.) could not create a connection,
-** and the request should be reattempted later.
-** EX_PROTOCOL -- the remote system returned something that
-** was "not possible" during a protocol exchange.
-** EX_NOPERM -- You did not have sufficient permission to
-** perform the operation. This is not intended for
-** file system problems, which should use NOINPUT or
-** CANTCREAT, but rather for higher level permissions.
-** For example, kre uses this to restrict who students
-** can send mail to.
-**
-** Maintained by Eric Allman (eric@berkeley, ucbvax!eric) --
-** please mail changes to me.
-**
-** @(#)sysexits.h 4.5 7/6/88
-*/
-
-# define EX_OK 0 /* successful termination */
-
-# define EX__BASE 64 /* base value for error messages */
-
-# define EX_USAGE 64 /* command line usage error */
-# define EX_DATAERR 65 /* data format error */
-# define EX_NOINPUT 66 /* cannot open input */
-# define EX_NOUSER 67 /* addressee unknown */
-# define EX_NOHOST 68 /* host name unknown */
-# define EX_UNAVAILABLE 69 /* service unavailable */
-# define EX_SOFTWARE 70 /* internal software error */
-# define EX_OSERR 71 /* system error (e.g., can't fork) */
-# define EX_OSFILE 72 /* critical OS file missing */
-# define EX_CANTCREAT 73 /* can't create (user) output file */
-# define EX_IOERR 74 /* input/output error */
-# define EX_TEMPFAIL 75 /* temp failure; user is invited to retry */
-# define EX_PROTOCOL 76 /* remote error in protocol */
-# define EX_NOPERM 77 /* permission denied */
-# define EX_CONFIG 78 /* configuration error */
diff --git a/usr/src/lib/libldap4/include/thq.h b/usr/src/lib/libldap4/include/thq.h
deleted file mode 100644
index d503a8a3c8..0000000000
--- a/usr/src/lib/libldap4/include/thq.h
+++ /dev/null
@@ -1,75 +0,0 @@
-/*
- *
- * Copyright 1998 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- *
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#include <pthread.h>
-
-typedef void * (*PFP)(void *);
-
-typedef void * (*PFP2)(void *, void *);
-
-typedef struct tq_listS {
- void * arg;
- struct tq_listS * next;
-} tq_listT, * tq_listTp;
-
-typedef struct {
- tq_listTp first; /* first element in the queue */
- tq_listTp last; /* last element in the queue */
- pthread_mutex_t lock; /* queue mutex */
- pthread_cond_t cond; /* queue condition to signal new elements */
- int * shutdown; /* variable to test to see shutdown condition*/
- int shutalloc; /* is the shutdown variable allocated locally*/
- int stopping; /* queue is currently stopping */
- int queue_size; /* current size of the queue */
- int nb_thr; /* current nb of threads pocessing the queue */
- int thr_waiting; /* current nb of threads waiting */
- int max_thr; /* max allowed threads to process the queue */
- int min_thr; /* min nb of threads to keep alive */
- PFP doit; /* function to call to process the queue */
- PFP2 endit; /* function called before to end the thread */
- void * arg; /* argument to pass to the doit/endit func. */
- pthread_t * tids; /* array of thread ids for watchdog */
-} tqT, * tqTp;
-
-extern tqTp tq_alloc(PFP process_func, /* function to process the queue */
- PFP2 shutdown_func, /* function called before to end */
- void * func_arg, /* arg passed to both functions */
- int * shutdown, /* shutdown variable to test */
- int max, /* max allowed threads */
- int min); /* min allowed threads */
-
-extern int tq_queue(tqTp queue, /* pointer to the queue */
- void * arg); /* element to be queued */
-
-/* tq_dequeue returns the first "arg" passed to tq_queue */
-extern void * tq_dequeue(tqTp queue, /* pointer to the queue */
- void * endit_arg); /* pointer to "shutdown" arguments */
-/*
- * tq_end_thread terminates the current
- * thread and restarts a new one if necessary
- */
-extern void tq_end_thread (tqTp queue, /* pointer to the queue */
- void * endit_arg); /* pointer to "shutdown" arguments */
-
-/*
- * tq_shutdown, shutdown the queue (alternate way to shutdown if you don't
- * have a global shutdown integer
- *
- * shutdown can be immediate (1) or delayed until there is nothing more
- * in the queue (immadiate = 0)
- *
- * when you call this function, no more argument can be queued using
- * tq_queue.
- *
- * when tq_dequeue returns, the queue pointer is not allocated anymore
- *
- */
-extern void tq_shutdown(tqTp queue, /* pointer to the queue */
- int immediate); /* 1: don't wait, 0: wait for queue */
- /* to be empty */
diff --git a/usr/src/lib/libldap4/misc/ldapfilter.conf b/usr/src/lib/libldap4/misc/ldapfilter.conf
deleted file mode 100644
index b4ff650125..0000000000
--- a/usr/src/lib/libldap4/misc/ldapfilter.conf
+++ /dev/null
@@ -1,112 +0,0 @@
-/*
- *
- * Portions Copyright 1998 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- *
- */
-#pragma ident "%Z%%M% %I% %E% SMI"
-# ldap filter file
-#
-# lines like this that start with # or empty lines are ignored
-#
-# syntax:
-#
-# <tag>
-# <pattern1> <delimiters> <filter1-1> <desc1-1> [<scope>]
-# <filter1-2> <desc1-2> [<scope>]
-#
-# <pattern2> <delimiters> <filter2-1> <desc2-1> [<scope>] ...
-#
-# The "desc" should describe the filter and it should correctly complete
-# both of the following phrases:
-#
-# One <desc> match was found for...
-# Three <desc> matches were found for...
-#
-# The scope is optional, and should be one of:
-# "base"
-# "onelevel"
-# "subtree"
-# if it is included.
-#
-
-"finger and ud and go500 and go500gw subtree and web500gw subtree and rp500 and rcpt500 and ufn last"
- "=" " " "%v" "arbitrary filter"
-
- "^[0-9][0-9-]*$" " " "(telephoneNumber=*%v)" "phone number"
-
- "@" " " "(mail=%v)" "email address"
- "(mail=%v*)" "start of email address"
-
- "^.[. _].*" ". _" "(cn=%v1* %v2-)" "first initial"
-
- ".*[. _].$" ". _" "(cn=%v1-*)" "last initial"
-
- "[. _]" ". _" "(|(sn=%v1-)(cn=%v1-))" "exact"
- "(|(sn~=%v1-)(cn~=%v1-))" "approximate"
-
- ".*" ". " "(|(cn=%v1)(sn=%v1)(uid=%v1))" "exact"
- "(|(cn~=%v1)(sn~=%v1))" "approximate"
-
-"go500gw onelevel and web500gw onelevel and ufn first and ufn intermediate"
- "=" " " "%v" "arbitrary filter"
-
- "^..$" " " "(|(o=%v)(c=%v)(l=%v)(co=%v))" "exact"
- "(|(o~=%v)(c~=%v)(l~=%v)(co~=%v))" "approximate"
-
- " " " " "(|(o=%v)(l=%v)(co=%v)(ou=%v))" "exact"
- "(|(o~=%v)(l~=%v)(co~=%v)(ou~=%v))" "approximate"
-
- "\." " " "(associatedDomain=%v)" "exact"
-
- ".*" " " "(|(o=%v)(l=%v)(co=%v)(ou=%v))" "exact"
- "(|(o~=%v)(l~=%v)(co~=%v)(ou~=%v))" "approximate"
-
-
-#
-# xax500
-#
-
-"xax500"
- "=" " " "(%v)" "arbitrary filter"
-
- "^[0-9][0-9-]*$" " " "(telephoneNumber=*%v)" "phone number"
-
- "@" " " "(mail=%v)" "email address"
- "(mail=%v*)" "start of email address"
-
- "^.[. _].*" ". _" "(cn=%v1* %v2-)" "first initial"
-
- ".*[. _].$" ". _" "(cn=%v1-*)" "last initial"
-
- "[. _]" ". _" "(|(sn=%v1-)(cn=%v1-))" "exact"
- "(|(sn~=%v1-)(cn~=%v1-))" "approximate"
-
- ".*" ". " "(|(cn=%v1)(sn=%v1)(uid=%v1))" "exact"
- "(|(cn=%v1)(sn~=%v1))" "approximate"
-
-
-"xax500-auth"
- "=" " " "(%v)" "arbitrary filter"
-
- "^[0-9][0-9-]*$" " " "(telephoneNumber=*%v)" "phone number"
-
- "@" " " "(mail=%v)" "email address"
- "(mail=%v*)" "start of email address"
-
- "^.[. _].*" ". _" "(cn=%v1* %v2-)" "first initial"
-
- ".*[. _].$" ". _" "(cn=%v1-*)" "last initial"
-
- "[. _]" ". _" "(|(sn=%v1-)(cn=%v1-))" "exact"
- "(|(sn~=%v1-)(cn~=%v1-))" "approximate"
-
- ".*" ". " "(|(cn=%v1)(sn=%v1)(uid=%v1))" "exact"
- "(|(cn=%v1)(sn~=%v1))" "approximate"
-
-"list500"
- "[. _]" ". _" "(|(sn=%v1-)(cn=%v1-))" "exact"
- "(|(sn~=%v1-)(cn~=%v1-))" "approximate"
-
- ".*" ". " "(|(cn=%v1)(sn=%v1)(uid=%v1))" "exact"
- "(|(cn~=%v1)(sn~=%v1))" "approximate"
diff --git a/usr/src/lib/libldap4/misc/ldapfriendly b/usr/src/lib/libldap4/misc/ldapfriendly
deleted file mode 100644
index ab99342985..0000000000
--- a/usr/src/lib/libldap4/misc/ldapfriendly
+++ /dev/null
@@ -1,249 +0,0 @@
-#
-#
-# Portions Copyright 1998 Sun Microsystems, Inc. All rights reserved.
-# Use is subject to license terms.
-#
-#
-#pragma ident "%Z%%M% %I% %E% SMI"
-AD Andorra
-AE United Arab Emirates
-AF Afghanistan
-AG Antigua and Barbuda
-AI Anguilla
-AL Albania
-AM Armenia
-AN Netherlands Antilles
-AO Angola
-AQ Antarctica
-AR Argentina
-AS American Samoa
-AT Austria
-AU Australia
-AW Aruba
-AZ Azerbaijan
-BA Bosnia and Herzegowina
-BB Barbados
-BD Bangladesh
-BE Belgium
-BF Burkina Faso
-BG Bulgaria
-BH Bahrain
-BI Burundi
-BJ Benin
-BM Bermuda
-BN Brunei Darussalam
-BO Bolivia
-BR Brazil
-BS Bahamas
-BT Bhutan
-BV Bouvet Island
-BW Botswana
-BY Belarus
-BZ Belize
-CA Canada
-CC Cocos (Keeling) Islands
-CF Central African Republic
-CG Congo
-CH Switzerland
-CI Cote d'Ivoire
-CK Cook Islands
-CL Chile
-CM Cameroon
-CN China
-CO Colombia
-CR Costa Rica
-CS Former Czechoslovakia
-CU Cuba
-CV Cape Verde
-CX Christmas Island
-CY Cyprus
-CZ Czech Republic
-DE Germany
-DJ Djibouti
-DK Denmark
-DM Dominica
-DO Dominican Republic
-DZ Algeria
-EC Ecuador
-EE Estonia
-EG Egypt
-EH Western Sahara
-ER Eritrea
-ES Spain
-ET Ethiopia
-FI Finland
-FJ Fiji
-FK Falkland Islands (Malvinas)
-FM Micronesia
-FO Faroe Islands
-FR France
-FX France, Metropolitan
-GA Gabon
-GB United Kingdom
-GD Grenada
-GE Georgia
-GF French Guiana
-GH Ghana
-GI Gibraltar
-GL Greenland
-GM Gambia
-GN Guinea
-GP Guadeloupe
-GQ Equatorial Guinea
-GR Greece
-GS South Georgia and the South Sandwich Islands
-GT Guatemala
-GU Guam
-GW Guinea-Bissau
-GY Guyana
-HK Hong Kong
-HM Heard and McDonald Islands
-HN Honduras
-HR Croatia
-HT Haiti
-HU Hungary
-ID Indonesia
-IE Ireland
-IL Israel
-IN India
-IO British Indian Ocean Territory
-IQ Iraq
-IR Iran
-IS Iceland
-IT Italy
-JM Jamaica
-JO Jordan
-JP Japan
-KE Kenya
-KG Kyrgyzstan
-KH Cambodia
-KI Kiribati
-KM Comoros
-KN Saint Kitts and Nevis
-KP Korea, Democratic People's Republic of
-KR Korea, Republic of
-KW Kuwait
-KY Cayman Islands
-KZ Kazakhstan
-LA Laos
-LB Lebanon
-LC Saint Lucia
-LI Liechtenstein
-LK Sri Lanka
-LR Liberia
-LS Lesotho
-LT Lithuania
-LU Luxembourg
-LV Latvia
-LY Libya
-MA Morocco
-MC Monaco
-MD Moldova
-MG Madagascar
-MH Marshall Islands
-MK Macedonia
-ML Mali
-MM Myanmar
-MN Mongolia
-MO Macau
-MP Northern Mariana Islands
-MQ Martinique
-MR Mauritania
-MS Montserrat
-MT Malta
-MU Mauritius
-MV Maldives
-MW Malawi
-MX Mexico
-MY Malaysia
-MZ Mozambique
-NA Namibia
-NC New Caledonia
-NE Niger
-NF Norfolk Island
-NG Nigeria
-NI Nicaragua
-NL Netherlands
-NO Norway
-NP Nepal
-NR Nauru
-NU Niue
-NZ New Zealand
-OM Oman
-PA Panama
-PE Peru
-PF French Polynesia
-PG Papua New Guinea
-PH Philippines
-PK Pakistan
-PL Poland
-PM St. Pierre and Miquelon
-PN Pitcairn
-PR Puerto Rico
-PT Portugal
-PW Palau
-PY Paraguay
-QA Qatar
-RE Reunion
-RO Romania
-RU Russian Federation
-RW Rwanda
-SA Saudi Arabia
-SB Solomon Islands
-SC Seychelles
-SD Sudan
-SE Sweden
-SG Singapore
-SH St. Helena
-SI Slovenia
-SJ Svalbard and Jan Mayen Islands
-SK Slovakia (Slovak Republic)
-SL Sierra Leone
-SM San Marino
-SN Senegal
-SO Somalia
-SR Suriname
-ST Sao Tome and Principe
-SU Former Soviet Union
-SV El Salvador
-SY Syria
-SZ Swaziland
-TC Turks and Caicos Islands
-TD Chad
-TF French Southern Territories
-TG Togo
-TH Thailand
-TJ Tajikistan
-TK Tokelau
-TM Turkmenistan
-TN Tunisia
-TO Tonga
-TP East Timor
-TR Turkey
-TT Trinidad and Tobago
-TV Tuvalu
-TW Taiwan
-TZ Tanzania
-UA Ukraine
-UG Uganda
-UK United Kingdom
-UM United States Minor Outlying Islands
-US United States of America
-UY Uruguay
-UZ Uzbekistan
-VA Vatican City State (Holy See)
-VC Saint Vincent and the Grenadines
-VE Venezuela
-VG Virgin Islands (British)
-VI Virgin Islands (U.S.)
-VN Viet Nam
-VU Vanuatu
-WF Wallis and Futuna Islands
-WS Samoa
-YE Yemen
-YT Mayotte
-YU Yugoslavia
-ZA South Africa
-ZM Zambia
-ZR Zaire
-ZW Zimbabwe
diff --git a/usr/src/lib/libldap4/misc/ldapsearchprefs.conf b/usr/src/lib/libldap4/misc/ldapsearchprefs.conf
deleted file mode 100644
index 47df5b422e..0000000000
--- a/usr/src/lib/libldap4/misc/ldapsearchprefs.conf
+++ /dev/null
@@ -1,160 +0,0 @@
-/*
- *
- * Portions Copyright 1998 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- *
- */
-#pragma ident "%Z%%M% %I% %E% SMI"
-# Version should be 1 now
-Version 1
-#
-#
-# Name for this search object
-People
-# options (the only one supported right now is "internal" which means that
-# this search object should not be presented directly to the user)
-# use "" for none
-""
-# Label to place before text box user types in
-"Search For:"
-# Filter prefix to append to all "More Choices" searches
-"(&(objectClass=person)"
-# Tag to use for "Fewer Choices" searches - from ldapfilter.conf file
-"xax500"
-# If a search results in > 1 match, retrieve this attribute to help
-# user disambiguate the entries...
-title
-# ...and label it with this string:
-"Title"
-# Search scope to use when searching
-subtree
-# Follows a list of "More Choices" search options. Format is:
-# Label, attribute, select-bitmap, extra attr display name, extra attr ldap name
-# If last two are null, "Fewer Choices" name/attributes used
-"Common Name" cn 11111 "" ""
-"Surname" sn 11111 "" ""
-"Business Phone" "telephoneNumber" 11101 "" ""
-"E-Mail Address" "mail" 11111 "" ""
-"Uniqname" "uid" 11111 "" ""
-"Title" title 11111 "" ""
-END
-# Match types
-"exactly matches" "(%a=%v))"
-"approximately matches" "(%a~=%v))"
-"starts with" "(%a=%v*))"
-"ends with" "(%a=*%v))"
-"contains" "(%a=*%v*))"
-END
-#
-#
-#
-Groups
-""
-"Search For:"
-"(&(objectClass=rfc822MailGroup)"
-"xax500"
-multilineDescription
-"Description"
-subtree
-"Common Name" cn 11111 "" ""
-"Description" multilineDescription 11101 "" ""
-"Owner" "owner" 00001 "owner" "Owner"
-"X.500 Member" "member" 00001 "" ""
-"E-Mail Member" "mail" 00101 "" ""
-END
-"exactly matches" "(%a=%v))"
-"approximately matches" "(%a~=%v))"
-"starts with" "(%a=%v*))"
-"ends with" "(%a=*%v))"
-"contains" "(%a=*%v*))"
-END
-#
-#
-#
-"Joinable Groups"
-""
-"Search For:"
-"(&(&(objectClass=rfc822MailGroup)(joinable=TRUE))"
-"xax500"
-multilineDescription
-"Description"
-subtree
-"Common Name" cn 11111 "" ""
-"Description" multilineDescription 11101 "" ""
-"Owner" "owner" 00001 "owner" "Owner"
-"X.500 Member" "member" 00001 "" ""
-"E-Mail Member" "mail" 00101 "" ""
-END
-"exactly matches" "(%a=%v))"
-"approximately matches" "(%a~=%v))"
-"starts with" "(%a=%v*))"
-"ends with" "(%a=*%v))"
-"contains" "(%a=*%v*))"
-END
-#
-#
-#
-Services
-""
-"Search For:"
-"(&(objectClass=service)"
-"xax500"
-multilineDescription
-"Description"
-subtree
-"Common Name" cn 11111 "" ""
-"Description" multilineDescription 11101 "" ""
-"Owner" "owner" 00001 "owner" "Owner"
-"Keywords" "keywords" 11111 "" ""
-"Hours" "hoursOfOperation" 11111 "" ""
-END
-"exactly matches" "(%a=%v))"
-"approximately matches" "(%a~=%v))"
-"starts with" "(%a=%v*))"
-"ends with" "(%a=*%v))"
-"contains" "(%a=*%v*))"
-END
-#
-#
-#
-Organizations
-""
-"Search For:"
-"(&(objectClass=organization)"
-"xax500"
-multilineDescription
-"Description"
-subtree
-"Name" organizationName 01111 "" ""
-"Location" localityName 11111 "" ""
-"Phone Number" "telephoneNumber" 10111 "" ""
-"Description" description 10111 "" ""
-END
-"exactly matches" "(%a=%v))"
-"approximately matches" "(%a~=%v))"
-"starts with" "(%a=%v*))"
-"ends with" "(%a=*%v))"
-"contains" "(%a=*%v*))"
-END
-#
-#
-#
-Documents
-""
-"Search For:"
-"(&(objectClass=document)"
-"xax500"
-multilineDescription
-"Description"
-subtree
-"Document Title" cn 11111 "" ""
-"Keyword" "keywords" 11111 "" ""
-"Category" "category" 11111 "" ""
-"Document Number" "documentIdentifier" 11111 "" ""
-END
-"exactly matches" "(%a=%v))"
-"approximately matches" "(%a~=%v))"
-"starts with" "(%a=%v*))"
-"ends with" "(%a=*%v))"
-"contains" "(%a=*%v*))"
-END
diff --git a/usr/src/lib/libldap4/misc/ldaptemplates.conf b/usr/src/lib/libldap4/misc/ldaptemplates.conf
deleted file mode 100644
index 6a88c70ad6..0000000000
--- a/usr/src/lib/libldap4/misc/ldaptemplates.conf
+++ /dev/null
@@ -1,684 +0,0 @@
-/*
- *
- * Portions Copyright 1998 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- *
- */
-#pragma ident "%Z%%M% %I% %E% SMI"
-##########################################################################
-# LDAP display templates
-##########################################################################
-
-#
-# Version must be 1
-#
-Version 1
-
-##########################################################################
-# U-M Person template
-##########################################################################
-#
-# template name and plural name come first
-"U-M Person"
-"U-M People"
-
-# name of the icon that is associated with this template
-"person icon"
-
-# blank-separated list of template options ("" for none)
-# addable - end-user should be allowed to add these types of entries
-# modrdn - end-user can change the name of these entries
-# altview - this template is referred to in another template's
-# "linkact" item
-"addable"
-
-#
-# objectclass list
-umichPerson person
-END
-
-#
-# name of attribute to authenticate as ("" means auth as this entry)
-""
-
-#
-# default attribute name to use when forming RDN of a new entry
-#
-cn
-
-#
-# default location when adding new entries (DN; "" means no default)
-"o=University of Michigan, c=US"
-
-#
-# rules used to define default values for new entries
-END
-
-#
-#
-# list of items for display
-# each line is either:
-# item (type) (attribute) (attr name) (extra args...)
-# to define an item or
-# samerow
-# to keep the next item on the same row as the previous
-#
-# valid types are:
-# cis - case ignore string
-# mls - multiline string
-# dn -
-# mail - case ignore string that contains an RFC822 mail address
-# bool - boolean value
-# jpeg - inlined JPEG image
-# jpegbtn - JPEG image button
-# fax - inlined Fax image
-# faxbtn - Fax image button
-# audiobtn - audio button
-# time - time value
-# date - time value displayed as a date only
-# url - labeled URL for links to items in WWW
-# searchact - search action
-# linkact - link to another template
-#
-# valid options (comma separated list appended to the type) are:
-# ro - attribute is read only; don't let user edit it
-# sort - order the values of this attribute
-# 1val - disallow entry of multiple values
-# required - this attribute should have at least one value
-# hide - don't show this item if attribute has no values
-# hideiffalse - hide item if value is FALSE (for type 'bool' only)
-#
-item jpegbtn "View Photo" jpegPhoto "Next Photo"
-item audiobtn "Play Sound" audio
-item cis,ro,sort "Also Known As" cn
-item mail "E-Mail Address" mail
-item cis "Work Phone" telephoneNumber
-item cis "Fax Number" facsimileTelephoneNumber
-item cis "Pager Number" pager
-item mls "Work Address" postalAddress
-item cis,sort "Title" title
-item cis,ro "Uniqname" uid
-item mls "Description" multiLineDescription
-item cis "Home Phone" homePhone
-item mls "Home Address" homePostalAddress
-item url "More Info (URL)" labeledURL
-item dn,sort "See Also" seeAlso
-item cis "Favorite Beverage" drink
-item cis "Notice" notice
-item bool,hideiffalse "On Vacation" onVacation
-item mls,1val "Vacation Message" vacationMessage
-item bool,hideiffalse "Do Not Allow Updates" noBatchUpdates
-item time,ro "Last Modified" lastModifiedTime
-item dn,ro "Modified By" lastModifiedBy
-item searchact "Find Groups Added To" "" "-dnt" "(&(objectclass=rfc822mailgroup)(member=%v))" "multiLineDescription" "Description" ""
-item searchact "List Owned Groups" "" "-dnt" "(&(objectclass=rfc822mailgroup)(owner=%v))" "title" "Title" ""
-item linkact "Other Addresses" "" "other addresses"
-END
-
-
-##########################################################################
-# Person template
-##########################################################################
-"Person"
-"People"
-"person icon"
-
-# template options
-addable
-#
-# objectclass list
-person
-END
-# name of attribute to authenticate as
-""
-
-# default attribute name to use when forming RDN of a new entry
-#
-cn
-
-# default location when adding new entries
-""
-
-#
-# rules used to define default values for new entries
-END
-
-#
-# list of items for display
-item jpegbtn "View Photo" jpegPhoto "Next Photo"
-item audiobtn "Play Sound" audio
-item cis,sort "Also Known As" cn
-item cis,sort "Title" title
-item mls "Work Address" postalAddress
-item cis "Work Phone" telephoneNumber
-item cis "Fax Number" facsimileTelephoneNumber
-item cis "Pager Number" pager
-item mls "Home Address" homePostalAddress
-item cis "Home Phone" homePhone
-item cis "User ID" uid
-item mail "E-Mail Address" mail
-item cis "Description" description
-item cis "Favorite Beverage" drink
-item dn,sort "See Also" seeAlso
-item time,ro "Last Modified" lastModifiedTime
-item dn,ro "Modified By" lastModifiedBy
-END
-
-
-##########################################################################
-# Group template
-##########################################################################
-"Group"
-"Groups"
-"group icon"
-
-# template options
-addable modrdn
-
-# objectclass list
-rfc822MailGroup
-END
-
-# name of attribute to authenticate as
-"owner"
-
-# default attribute name to use when forming RDN of a new entry
-#
-cn
-
-# default location when adding new entries
-"ou=User Groups, ou=Groups, o=University of Michigan, c=US"
-
-#
-# rules used to define default values for new entries
-constant "associatedDomain" "umich.edu"
-constant "joinable" "FALSE"
-addersdn "owner"
-addersdn "member"
-addersdn "errorsTo"
-addersdn "requestsTo"
-END
-
-#
-#
-# list of items for display
-# each line is either:
-# item (type) (attribute) (attr name) (extra args...)
-# to define an item or
-# samerow
-#
-# list of items for display
-item cis,sort "Also Known As" cn
-item mls "Description" multiLineDescription
-item cis "Phone Number" telephoneNumber
-item cis "Fax Number" facsimileTelephoneNumber
-item mls "Address" postalAddress
-item dn,required,sort "Owner" owner
-item url "More Info (URL)" labeledURL
-item dn,sort "See Also" seeAlso
-item dn,sort "Errors To" errorsTo
-item dn,sort "Requests To" requestsTo
-item cis "Associated Domain" associatedDomain
-item cis "Moderator" moderator
-item bool "Suppress 'No E-Mail Address' Errors" suppressNoEmailError
-item bool "Others May Join" joinable
-item dn,sort "X.500 Members" member
-item mail,sort "E-Mail Errors To" rfc822ErrorsTo
-item mail,sort "E-Mail Requests To" rfc822RequestsTo
-item mail,sort "E-Mail Members" mail
-item cis "Notice" notice
-item time,ro "Last Modified" lastModifiedTime
-item dn,ro "Modified By" lastModifiedBy
-item searchact "Subscribers" "" "-dnt" "memberOfGroup=%v" "title" "Title" "joinable"
-item verifyact "Verify Members" "member" "mail" "E-Mail Address"
-END
-
-##########################################################################
-# Organization template
-##########################################################################
-"Organization"
-"Organizations"
-"organization icon"
-
-# template options
-""
-
-# objectclass list
-organization
-END
-
-# name of attribute to authenticate as
-""
-
-# default attribute name to use when forming RDN of a new entry
-o
-
-# default location when adding new entries
-""
-
-# rules used to define default values for new entries
-constant "o" "foo"
-END
-
-#
-#
-# list of items for display
-# each line is either:
-# item (type) (attribute) (attr name) (extra args...)
-# to define an item or
-# samerow
-#
-# list of items for display
-item cis,sort "Name" o
-item cis "Location" l
-item mls "Address" postalAddress
-item cis "Phone Number" telephoneNumber
-item cis "Fax Number" facsimileTelephoneNumber
-item cis "Description" description
-item dn,sort "See Also" seeAlso
-item time,ro "Last Modified" lastModifiedTime
-item dn,ro "Modified By" lastModifiedBy
-END
-
-
-##########################################################################
-# Service template
-##########################################################################
-"Service"
-"Services"
-"service icon"
-
-# template options
-"addable"
-
-# objectclass list
-service
-END
-
-# name of attribute to authenticate as
-"owner"
-
-# default attribute name to use when forming RDN of a new entry
-cn
-
-# default location when adding new entries
-"ou=Services, o=University of Michigan, c=US"
-
-# rules used to define default values for new entries
-addersdn "owner"
-END
-
-#
-#
-# list of items for display
-# each line is either:
-# item (type) (attribute) (attr name) (extra args...)
-# to define an item or
-# samerow
-#
-# list of items for display
-item jpegbtn "View Photo" jpegPhoto
-item cis,sort "Name" cn
-item mls "Description" multilineDescription
-item cis "Provider" provider
-item cis,sort "Service Area" serviceArea
-item mail "E-mail Address" mail
-item cis "Phone" telephoneNumber
-item cis "Fax Number" facsimileTelephoneNumber
-item mls "Postal Address" postalAddress
-item cis "Hours" hoursOfOperation
-item url "More Info (URL)" labeledURL
-item dn,sort "Depends On" dependentUpon
-item dn,sort "See Also" seeAlso
-item cis,sort "Platform" platform
-item cis,sort "Product" product
-item cis,sort "Keywords" keywords
-item cis "FCE Rating" serviceRating
-item date "Date Rated" ratingTime
-item mls "Rating Description" ratingDescription
-item time,ro "Last Modified" lastModifiedTime
-item dn,ro "Modified By" lastModifiedBy
-item dn,required,sort "Owner" owner
-END
-
-
-##########################################################################
-# Organizational Role template
-##########################################################################
-"Organizational Role"
-"Organizational Roles"
-"person icon"
-
-# template options
-""
-
-# objectclass list
-organizationalRole
-END
-
-# name of attribute to authenticate as
-""
-
-# default attribute name to use when forming RDN of a new entry
-cn
-
-# default location when adding new entries
-""
-
-# rules used to define default values for new entries
-END
-
-#
-#
-# list of items for display
-# each line is either:
-# item (type) (attribute) (attr name) (extra args...)
-# to define an item or
-# samerow
-#
-# list of items for display
-item cis,sort "Name" cn
-item cis "Description" description
-item dn "Role Occupant" roleOccupant
-item dn,sort "See Also" seeAlso
-item time,ro "Last Modified" lastModifiedTime
-item dn,ro "Modified By" lastModifiedBy
-END
-
-
-##########################################################################
-# Organizational Unit template
-##########################################################################
-"Organizational Unit"
-"Organizational Units"
-"organization icon"
-
-# template options
-""
-
-# objectclass list
-organizationalUnit
-END
-
-# name of attribute to authenticate as
-""
-
-# default attribute name to use when forming RDN of a new entry
-cn
-
-# default location when adding new entries
-""
-
-# rules used to define default values for new entries
-END
-
-# Item list
-item cis "Organization Unit Name" ou
-item cis "Title" title
-item time,ro "Last Modified" lastModifiedTime
-item dn,ro "Modified By" lastModifiedBy
-END
-
-
-
-##########################################################################
-# Application Entity template
-##########################################################################
-"Application Entity"
-"Application Entities"
-"application icon"
-
-# template options
-""
-
-# objectclass list
-applicationEntity
-END
-
-# name of attribute to authenticate as
-""
-
-# default attribute name to use when forming RDN of a new entry
-cn
-
-# default location when adding new entries
-""
-
-# rules used to define default values for new entries
-END
-
-# Item list
-item cis,sort "Name" cn
-item cis "Location" l
-item cis "Description" description
-item time,ro "Last Modified" lastModifiedTime
-item dn,ro "Modified By" lastModifiedBy
-END
-
-##########################################################################
-# Document template
-##########################################################################
-"Document"
-"Documents"
-"document icon"
-
-# template options
-""
-
-# objectclass list
-document
-umichDocument
-END
-
-# name of attribute to authenticate as
-""
-
-# default attribute name to use when forming RDN of a new entry
-cn
-
-# default location when adding new entries
-""
-
-# rules used to define default values for new entries
-END
-
-#
-# Item list
-item cis "Document ID" documentIdentifier
-item cis "Title" documentTitle
-item cis "Series Title" documentSeriesTitle
-item cis "Version" documentVersion
-item cis,sort "Service Area" serviceArea
-item mls "Abstract" multiLineAbstract
-item url "More Info (URL)" labeledURL
-item dn,sort "Availability" documentAvailable
-item dn,sort "See Also" seeAlso
-item cis,sort "Platform" platform
-item cis,sort "Product" product
-item cis,sort "Keyword" keywords
-item dn,sort "Author" documentAuthor
-item time,ro "Last Modified" lastModifiedTime
-item dn,ro "Modified By" lastModifiedBy
-item dn,required "Owner" owner
-END
-
-##########################################################################
-# Document description template
-##########################################################################
-"DocumentDescription"
-"DocumentDescriptions"
-"document description icon"
-
-# template options
-""
-
-# objectclass list
-documentDescription
-END
-
-# name of attribute to authenticate as
-""
-
-# default attribute name to use when forming RDN of a new entry
-cn
-
-# default location when adding new entries
-""
-
-# rules used to define default values for new entries
-END
-
-#
-# Item list
-item mls "Description" multilineDescription
-item url "More Info (URL)" labeledURL
-item time,ro "Last Modified" lastModifiedTime
-item dn,ro "Modified By" lastModifiedBy
-item dn,required "Owner" owner
-END
-
-##########################################################################
-# Image template
-##########################################################################
-"Image"
-"Images"
-"image icon"
-
-# template options
-""
-
-# objectclass list
-image
-END
-
-# name of attribute to authenticate as
-""
-
-# default attribute name to use when forming RDN of a new entry
-cn
-
-# default location when adding new entries
-""
-
-# rules used to define default values for new entries
-END
-
-#
-# Item list
-item cis "Name" cn
-item mls "Description" multilineDescription
-item jpegbtn "View Photo(s)" jpegPhoto
-item cis "Citation" citation
-item cis "Copyright" copyright
-item cis "Keywords" keywords
-item time,ro "Last Modified" lastModifiedTime
-item dn,ro "Modified By" lastModifiedBy
-item dn,required "Owner" owner
-END
-
-
-
-##########################################################################
-# Country template
-##########################################################################
-"Country"
-"Countries"
-"country icon"
-
-# template options
-""
-
-# objectclass list
-friendlyCountry
-END
-
-# name of attribute to authenticate as
-""
-
-# default attribute name to use when forming RDN of a new entry
-c
-
-# default location when adding new entries
-""
-
-# rules used to define default values for new entries
-END
-
-# Item list
-item cis "Country Name" co
-item cis "Country Code" c
-item cis "Description" description
-item time,ro "Last Modified" lastModifiedTime
-item dn,ro "Modified By" lastModifiedBy
-END
-
-##########################################################################
-# Locality template
-##########################################################################
-"Locality"
-"Localities"
-"locality icon"
-
-# template options
-""
-
-# objectclass list
-locality
-END
-
-# name of attribute to authenticate as
-""
-
-# default attribute name to use when forming RDN of a new entry
-l
-
-# default location when adding new entries
-""
-
-# rules used to define default values for new entries
-END
-
-#
-# Item list
-item cis "Name" l
-item time,ro "Last Modified" lastModifiedTime
-item dn,ro "Modified By" lastModifiedBy
-END
-
-
-##########################################################################
-# "Other Addresses" template
-##########################################################################
-"Others Addresses"
-"Other Addresses"
-"other addr icon"
-
-# template options
-"altview"
-
-# objectclass list
-END
-
-# name of attribute to authenticate as
-""
-
-# default attribute name to use when forming RDN of a new entry
-""
-
-# default location when adding new entries
-""
-
-# rules used to define default values for new entries
-END
-
-# Item list
-item cis "Street Address" streetAddress
-item cis "Locality" l
-item cis "State or Province" st
-item cis "Postal Code" postalCode
-item cis,hide "X.400 Address" mhsORAddresses
-item cis,hide "X.400 Address" textEncodedORAddress
-Item cis "Other Mailbox" otherMailbox
-item time,ro "Last Modified" lastModifiedTime
-item dn,ro "Modified By" lastModifiedBy
-END
diff --git a/usr/src/lib/libldap4/sec/cram_md5.c b/usr/src/lib/libldap4/sec/cram_md5.c
deleted file mode 100644
index 948e17c246..0000000000
--- a/usr/src/lib/libldap4/sec/cram_md5.c
+++ /dev/null
@@ -1,62 +0,0 @@
-/*
- *
- * Copyright 1998 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- *
- *
- * Comments:
- *
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#include <sys/types.h>
-#include <strings.h>
-#include "sec.h"
-
-/* text is the challenge, key is the password, digest is an allocated
- buffer (min 16 chars) which will contain the resulting digest */
-void hmac_md5(unsigned char *text, int text_len, unsigned char *key,
- int key_len, unsigned char *digest)
-{
- MD5_CTX context;
- unsigned char k_ipad[65];
- unsigned char k_opad[65];
- unsigned char tk[16];
- int i;
-
- if (key_len > 64){
- MD5_CTX tctx;
-
- (void) MD5Init(&tctx);
- (void) MD5Update(&tctx, key, key_len);
- (void) MD5Final(tk, &tctx);
- key = tk;
- key_len = 16;
- }
-
- bzero(k_ipad, sizeof (k_ipad));
- bzero(k_opad, sizeof (k_opad));
- bcopy(key, k_ipad, key_len);
- bcopy(key, k_opad, key_len);
-
- for (i=0; i<64; i++){
- k_ipad[i] ^= 0x36;
- k_opad[i] ^= 0x5c;
- }
-
- /* Perform inner MD5 */
- (void) MD5Init(&context);
- (void) MD5Update(&context, k_ipad, 64);
- (void) MD5Update(&context, text, text_len);
- (void) MD5Final(digest, &context);
-
- /* Perform outer MD5 */
- (void) MD5Init(&context);
- (void) MD5Update(&context, k_opad, 64);
- (void) MD5Update(&context, digest, 16);
-
- (void) MD5Final(digest, &context);
-
- return;
-}
diff --git a/usr/src/lib/libldap4/sec/secutil.c b/usr/src/lib/libldap4/sec/secutil.c
deleted file mode 100644
index 5e2902a2b3..0000000000
--- a/usr/src/lib/libldap4/sec/secutil.c
+++ /dev/null
@@ -1,63 +0,0 @@
-/*
- *
- * Copyright 1998 Sun Microsystems, Inc. All rights reserved.
- * Use is subject to license terms.
- *
- *
- * Comments:
- *
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#include <stdlib.h>
-#include <string.h>
-#include <ctype.h>
-
-static char hexdig[] = "0123456789abcdef";
-
-char* hexa_print(char *aString, int aLen)
-{
- char *res;
- int i =0;
-
- if ((res = (char *)calloc (aLen*2 + 1, 1 )) == NULL){
- return (NULL);
- }
- for (;;){
- if (aLen < 1)
- break;
- res[i] = hexdig[ ( *aString & 0xf0 ) >> 4 ];
- res[i + 1] = hexdig[ *aString & 0x0f ];
- i+= 2;
- aLen--;
- aString++;
- }
- return (res);
-}
-
-
-static int
-unhex( char c )
-{
- return( c >= '0' && c <= '9' ? c - '0'
- : c >= 'A' && c <= 'F' ? c - 'A' + 10
- : c - 'a' + 10 );
-}
-
-char * hexa2str(char *anHexaStr, int *aResLen) {
- int theLen = 0;
- char *theRes = malloc(strlen(anHexaStr) /2 + 1);
-
- while (isxdigit(*anHexaStr)){
- theRes[theLen] = unhex(*anHexaStr) << 4;
- if (++anHexaStr != '\0'){
- theRes[theLen] += unhex(*anHexaStr);
- anHexaStr++;
- }
- theLen++;
- }
- theRes[theLen] = '\0';
- * aResLen = theLen;
- return (theRes);
-}
diff --git a/usr/src/lib/libldap4/util/line64.c b/usr/src/lib/libldap4/util/line64.c
deleted file mode 100644
index 1deb3ef084..0000000000
--- a/usr/src/lib/libldap4/util/line64.c
+++ /dev/null
@@ -1,388 +0,0 @@
-/*
- *
- * Portions Copyright 07/23/97 Sun Microsystems, Inc. All Rights Reserved
- *
- */
-/* line64.c - routines for dealing with the slapd line format */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <unistd.h>
-#include <string.h>
-#include <ctype.h>
-#include <sys/types.h>
-#include <sys/socket.h>
-#include "lber.h"
-#include "ldap.h"
-#include "ldif.h"
-
-#define RIGHT2 0x03
-#define RIGHT4 0x0f
-#define CONTINUED_LINE_MARKER '\001'
-
-static char nib2b64[0x40f] =
- "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
-
-static unsigned char b642nib[0x80] = {
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0xff, 0xff, 0x3e, 0xff, 0xff, 0xff, 0x3f,
- 0x34, 0x35, 0x36, 0x37, 0x38, 0x39, 0x3a, 0x3b,
- 0x3c, 0x3d, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06,
- 0x07, 0x08, 0x09, 0x0a, 0x0b, 0x0c, 0x0d, 0x0e,
- 0x0f, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15, 0x16,
- 0x17, 0x18, 0x19, 0xff, 0xff, 0xff, 0xff, 0xff,
- 0xff, 0x1a, 0x1b, 0x1c, 0x1d, 0x1e, 0x1f, 0x20,
- 0x21, 0x22, 0x23, 0x24, 0x25, 0x26, 0x27, 0x28,
- 0x29, 0x2a, 0x2b, 0x2c, 0x2d, 0x2e, 0x2f, 0x30,
- 0x31, 0x32, 0x33, 0xff, 0xff, 0xff, 0xff, 0xff
-};
-
-/*
- * str_parse_line - takes a line of the form "type:[:] value" and splits it
- * into components "type" and "value". if a double colon separates type from
- * value, then value is encoded in base 64, and parse_line un-decodes it
- * (in place) before returning.
- */
-
-int
-str_parse_line(
- char *line,
- char **type,
- char **value,
- int *vlen
-)
-{
- char *p, *s, *d, *byte, *stop;
- char nib;
- int i = 0, b64 = 0;
-
- int url = 0;
-
- /* skip any leading space */
- while ( isspace( *line ) ) {
- line++;
- }
- *type = line;
-
- for ( s = line; *s && *s != ':'; s++ )
- ; /* NULL */
- if ( *s == '\0' ) {
- Debug( LDAP_DEBUG_PARSE, catgets(slapdcat, 1, 263, "parse_line missing ':'\n"), 0, 0, 0 );
- return( -1 );
- }
-
- /* trim any space between type and : */
- for ( p = s - 1; p > line && isspace( *p ); p-- ) {
- *p = '\0';
- }
- *s++ = '\0';
-
- /* check for double : - indicates base 64 encoded value */
- if ( *s == ':' ) {
- s++;
- b64 = 1;
-
- } else if ( *s == '<' ) { /* the value indicates an url */
- s++;
- url = 1;
-
- } else { /* single : - normally encoded value */
- b64 = 0;
- }
-
- /* skip space between : and value */
- while ( isspace( *s ) ) {
- s++;
- }
-
- /* if no value is present, error out */
- if ( *s == '\0' ) {
- Debug( LDAP_DEBUG_PARSE, catgets(slapdcat, 1, 264, "parse_line missing value\n"), 0,0,0 );
- return( -1 );
- }
-
- /* check for continued line markers that should be deleted */
- for ( p = s, d = s; *p; p++ ) {
- if ( *p != CONTINUED_LINE_MARKER )
- *d++ = *p;
- }
- *d = '\0';
-
- if ( b64 ) {
- *value = s;
- stop = strchr( s, '\0' );
- byte = s;
- for ( p = s, *vlen = 0; p < stop; p += 4, *vlen += 3 ) {
- for ( i = 0; i < 3; i++ ) {
- if ( p[i] != '=' && (p[i] & 0x80 ||
- b642nib[ p[i] & 0x7f ] > 0x3f) ) {
- Debug( LDAP_DEBUG_ANY,
- catgets(slapdcat, 1, 265, "invalid base 64 encoding char (%1$c) 0x%2$x\n"),
- p[i], p[i], 0 );
- return( -1 );
- }
- }
-
- /* first digit */
- nib = b642nib[ p[0] & 0x7f ];
- byte[0] = nib << 2;
- /* second digit */
- nib = b642nib[ p[1] & 0x7f ];
- byte[0] |= nib >> 4;
- byte[1] = (nib & RIGHT4) << 4;
- /* third digit */
- if ( p[2] == '=' ) {
- *vlen += 1;
- break;
- }
- nib = b642nib[ p[2] & 0x7f ];
- byte[1] |= nib >> 2;
- byte[2] = (nib & RIGHT2) << 6;
- /* fourth digit */
- if ( p[3] == '=' ) {
- *vlen += 2;
- break;
- }
- nib = b642nib[ p[3] & 0x7f ];
- byte[2] |= nib;
-
- byte += 3;
- }
- s[ *vlen ] = '\0';
- } else if ( url ) { /* checks that the url is properly formed */
- /* file://[localhost]/<pathname> */
- /* value contains the content of the file */
- char * s2;
- char * filename;
-
- FILE *fp;
- int rlen;
- int eof;
-
-
- if ( strncmp(s, "file://localhost", 16) == 0 )
- {
- s = s+16;
- }
- else if ( strncmp(s, "file://", 7) == 0 )
- {
- s = s+7;
- }
- else
- {
- /* url badly formed */
- Debug( LDAP_DEBUG_ANY, catgets(slapdcat, 1, 1289, "invalid url %s\n"), s, 0, 0);
- return -1;
- }
-
- filename = strdup(s);
-
- /* now we have the filename, read its content and return the value */
- if (( fp = fopen( filename, "r" )) == NULL )
- {
- perror( filename );
- return( -1 );
- }
-
- if ( fseek( fp, 0, SEEK_END ) != 0 )
- {
- perror( filename );
- fclose( fp );
- return( -1 );
- }
-
- *vlen = ftell(fp);
- if ( (*value = (char *)malloc(*vlen)) == NULL )
- {
- perror("malloc");
- fclose(fp);
- return(-1);
- }
- if ( fseek( fp, 0, SEEK_SET ) != 0 )
- {
- perror( filename );
- fclose( fp );
- return( -1 );
- }
-
- rlen = fread( *value, 1, *vlen, fp );
- eof = feof( fp );
- fclose( fp );
-
- if ( rlen != *vlen )
- {
- perror( filename );
- return( -1 );
- }
-
- } else {
- *value = s;
- *vlen = (int) (d - s);
- }
-
- return( 0 );
-}
-
-/*
- * str_getline - return the next "line" (minus newline) of input from a
- * string buffer of lines separated by newlines, terminated by \n\n
- * or \0. this routine handles continued lines, bundling them into
- * a single big line before returning. if a line begins with a white
- * space character, it is a continuation of the previous line. the white
- * space character (nb: only one char), and preceeding newline are changed
- * into CONTINUED_LINE_MARKER chars, to be deleted later by the
- * str_parse_line() routine above.
- *
- * it takes a pointer to a pointer to the buffer on the first call,
- * which it updates and must be supplied on subsequent calls.
- */
-
-char *
-str_getline( char **next )
-{
- char *l;
- char c;
-
- if ( *next == NULL || **next == '\n' || **next == '\0' ) {
- return( NULL );
- }
-
- l = *next;
- while ( (*next = strchr( *next, '\n' )) != NULL ) {
- c = *(*next + 1);
- if ( isspace( c ) && c != '\n' ) {
- **next = CONTINUED_LINE_MARKER;
- *(*next+1) = CONTINUED_LINE_MARKER;
- } else {
- *(*next)++ = '\0';
- break;
- }
- *(*next)++;
- }
-
- return( l );
-}
-
-void
-put_type_and_value( char **out, char *t, char *val, int vlen )
-{
- unsigned char *byte, *p, *stop;
- unsigned char buf[3];
- unsigned int bits;
- char *save;
- int i, b64, pad, len, savelen;
- len = 0;
-
- /* put the type + ": " */
- for ( p = (unsigned char *) t; *p; p++, len++ ) {
- *(*out)++ = *p;
- }
- *(*out)++ = ':';
- len++;
- save = *out;
- savelen = len;
- *(*out)++ = ' ';
- b64 = 0;
-
- stop = (unsigned char *) (val + vlen);
- if ( isascii( val[0] ) && isspace( val[0] ) || val[0] == ':' ) {
- b64 = 1;
- } else {
- for ( byte = (unsigned char *) val; byte < stop;
- byte++, len++ ) {
- if ( !isascii( *byte ) || !isprint( *byte ) ) {
- b64 = 1;
- break;
- }
- if ( len > LINE_WIDTH ) {
- *(*out)++ = '\n';
- *(*out)++ = ' ';
- len = 1;
- }
- *(*out)++ = *byte;
- }
- }
- if ( b64 ) {
- *out = save;
- *(*out)++ = ':';
- *(*out)++ = ' ';
- len = savelen + 2;
- /* convert to base 64 (3 bytes => 4 base 64 digits) */
- for ( byte = (unsigned char *) val; byte < stop - 2;
- byte += 3 ) {
- bits = (byte[0] & 0xff) << 16;
- bits |= (byte[1] & 0xff) << 8;
- bits |= (byte[2] & 0xff);
-
- for ( i = 0; i < 4; i++, len++, bits <<= 6 ) {
- if ( len > LINE_WIDTH ) {
- *(*out)++ = '\n';
- *(*out)++ = ' ';
- len = 1;
- }
-
- /* get b64 digit from high order 6 bits */
- *(*out)++ = nib2b64[ (bits & 0xfc0000) >> 18 ];
- }
- }
-
- /* add padding if necessary */
- if ( byte < stop ) {
- for ( i = 0; byte + i < stop; i++ ) {
- buf[i] = byte[i];
- }
- for ( pad = 0; i < 3; i++, pad++ ) {
- buf[i] = '\0';
- }
- byte = buf;
- bits = (byte[0] & 0xff) << 16;
- bits |= (byte[1] & 0xff) << 8;
- bits |= (byte[2] & 0xff);
-
- for ( i = 0; i < 4; i++, len++, bits <<= 6 ) {
- if ( len > LINE_WIDTH ) {
- *(*out)++ = '\n';
- *(*out)++ = ' ';
- len = 1;
- }
-
- /* get b64 digit from low order 6 bits */
- *(*out)++ = nib2b64[ (bits & 0xfc0000) >> 18 ];
- }
-
- for ( ; pad > 0; pad-- ) {
- *(*out - pad) = '=';
- }
- }
- }
- *(*out)++ = '\n';
-}
-
-
-char *
-ldif_type_and_value( char *type, char *val, int vlen )
-/*
- * return malloc'd, zero-terminated LDIF line
- */
-{
- char *buf, *p;
- int tlen;
-
- buf=NULL;
- tlen = strlen( type );
- if (( buf = (char *)malloc( LDIF_SIZE_NEEDED( tlen, vlen ) + 1 )) !=
- NULL ) {
-
- p = buf;
- put_type_and_value( &p, type, val, vlen );
- *p = '\0';
- }
- return( buf );
-}
diff --git a/usr/src/lib/libldap4/util/log.c b/usr/src/lib/libldap4/util/log.c
deleted file mode 100644
index 29ea85a644..0000000000
--- a/usr/src/lib/libldap4/util/log.c
+++ /dev/null
@@ -1,168 +0,0 @@
-/*
- * Copyright (c) 1998-1999 by Sun Microsystems, Inc.
- * All rights reserved.
- */
-
-#pragma ident "%Z%%M% %I% %E% SMI"
-
-#include <stdio.h>
-#include <stdlib.h>
-#include <sys/types.h>
-#include <sys/stat.h>
-#include <nl_types.h>
-#include <limits.h>
-#include <stdarg.h>
-#include <string.h>
-
-#include <syslog.h>
-#include <portable.h>
-/* #include <lthread.h> */
-#include <pthread.h>
-#include <thread.h>
-
-#include "log.h"
-
-#define LDAP_DEBUG_ANY 0xffff
-
-static pthread_mutex_t log_mutex;
-static char logfile[PATH_MAX] =
- "/var/opt/SUNWconn/ldap/log/slapd.log";
-static int logsize = 512000;
-static int logtime = 1;
-static FILE *logfd = NULL;
-static int syslogopen = 0;
-pthread_mutex_t systime_mutex;
-nl_catd sundscat;
-static int log_debug = LDAP_DEBUG_STATS;
-
-typedef struct _logctx {
- char *logfile;
- int syslogopen;
- int logsize;
- pthread_mutex_t log_mutex;
- int log_debug;
- int log_syslog;
-
-} LogCtx;
-
-void
-ldaplogconfig(char *logf, int size)
-{
- strcpy(logfile, logf);
- logsize = size * 1024;
-}
-
-void
-ldaplogconfigf(FILE *fd)
-{
- logfd = fd;
- logsize = 0;
-}
-
-void
-ldaploginit(char *name, int facility)
-{
- openlog(name, OPENLOG_OPTIONS, facility);
- syslogopen = 1;
- pthread_mutex_init(&log_mutex, NULL);
-}
-
-void
-ldaploginitlevel(char *name, int facility, int level)
-{
- ldaploginit(name, facility);
- log_debug = level;
-}
-
-LogCtx *
-sundsloginit(char *name, int facility, int debug_level, int syslog_level)
-{
- LogCtx *returnCtx = NULL;
-
- if ((returnCtx = (LogCtx *)malloc(sizeof (LogCtx))) == NULL)
- return (NULL);
- if ((returnCtx->logfile = strdup(name)) == NULL) {
- free(returnCtx);
- return (NULL);
- }
- openlog(returnCtx->logfile, OPENLOG_OPTIONS, facility);
- returnCtx->syslogopen = 1;
- pthread_mutex_init(&(returnCtx->log_mutex), NULL);
- returnCtx->log_debug = debug_level;
- returnCtx->log_syslog = syslog_level;
- return (returnCtx);
-}
-
-static char timestr[128];
-static time_t timelast = 0;
-
-/*VARARGS*/
-void
-ldaplog(int level, char *fmt, ...)
-{
- va_list ap;
- struct stat statbuf = {0};
- char newlog1[PATH_MAX];
- char newlog2[PATH_MAX];
- time_t now;
- int i;
-
- if (!(log_debug & level))
- return;
-
- va_start(ap, fmt);
-
- if (level == LDAP_DEBUG_ANY) {
- /*
- * this message is probably an error message, send it to syslog
- */
- if (syslogopen) {
- vsyslog(LOG_ERR, fmt, ap);
- } /* end if */
- /* and sent it also on stderr */
- vfprintf(stderr, fmt, ap);
- } /* end if */
-
- /*
- * check that the log file is not already too big
- */
- pthread_mutex_lock(&log_mutex);
- if ((logsize > 0) && (stat(logfile, &statbuf) == 0 &&
- statbuf.st_size > logsize)) {
- for (i = 9; i > 1; i--) {
- (void) sprintf(newlog1, "%s.%d", logfile, i-1);
- (void) sprintf(newlog2, "%s.%d", logfile, i);
- (void) rename(newlog1, newlog2);
- } /* end for */
- if (logfd) {
- fclose(logfd);
- logfd = NULL;
- } /* end if */
- (void) rename(logfile, newlog1);
- } /* end if */
- /*
- * send the message into a regular log file
- */
- if (!logfd) {
- logfd = fopen(logfile, "a");
- } /* end if */
- /*
- * finally write the message into the log file
- */
- if (logfd) {
- if (logtime) {
- time(&now);
- if (now-timelast > 60) {
- pthread_mutex_lock(&systime_mutex);
- timelast = now;
- ctime_r(&now, timestr, 128);
- pthread_mutex_unlock(&systime_mutex);
- } /* end if */
- fprintf(logfd, "%.16s : ", timestr);
- } /* end if */
- vfprintf(logfd, fmt, ap);
- fflush(logfd);
- } /* end if */
- pthread_mutex_unlock(&log_mutex);
- va_end(ap);
-}
diff --git a/usr/src/lib/libnisdb/ldap_op.c b/usr/src/lib/libnisdb/ldap_op.c
index 5feb84b35e..4caac35eba 100644
--- a/usr/src/lib/libnisdb/ldap_op.c
+++ b/usr/src/lib/libnisdb/ldap_op.c
@@ -1664,24 +1664,10 @@ retry_noVLV:
goto cleanup;
}
}
- /*
- * XXX the ldap_first_attribute(3LDAP) man
- * page says that the ldap_first_attribute/
- * ldap_next_attribute should be treated as
- * static, but the libldap.so.4 code mallocs
- * (and it's not TSD). So, in order to avoid
- * a leak, we free the return value.
- */
ldap_memfree(nm);
if (val != 0)
ldap_value_free_len(val);
}
- /*
- * XXX ldap_next_attribute(3LDAP) says that the 'ber'
- * pointer is freed when it returns NULL, but that's
- * not implemented in the libldap.so.4 code, so we
- * free it here in order to avoid a memory leak.
- */
if (ber != 0)
ber_free(ber, 0);
}
diff --git a/usr/src/lib/libnvpair/Makefile.com b/usr/src/lib/libnvpair/Makefile.com
index 4439415f03..b278c85672 100644
--- a/usr/src/lib/libnvpair/Makefile.com
+++ b/usr/src/lib/libnvpair/Makefile.com
@@ -22,7 +22,7 @@
# Copyright 2008 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
-# ident "%Z%%M% %I% %E% SMI"
+# Copyright (c) 2012 by Delphix. All rights reserved.
#
LIBRARY= libnvpair.a
@@ -31,7 +31,8 @@ VERS= .1
OBJECTS= libnvpair.o \
nvpair_alloc_system.o \
nvpair_alloc_fixed.o \
- nvpair.o
+ nvpair.o \
+ fnvpair.o
include ../../Makefile.lib
include ../../Makefile.rootfs
@@ -39,7 +40,8 @@ include ../../Makefile.rootfs
SRCS= ../libnvpair.c \
../nvpair_alloc_system.c \
$(SRC)/common/nvpair/nvpair_alloc_fixed.c \
- $(SRC)/common/nvpair/nvpair.c
+ $(SRC)/common/nvpair/nvpair.c \
+ $(SRC)/common/nvpair/fnvpair.c
#
# Libraries added to the next line must be present in miniroot
diff --git a/usr/src/lib/libnvpair/libnvpair.c b/usr/src/lib/libnvpair/libnvpair.c
index 16bce483be..c2e5a1b46d 100644
--- a/usr/src/lib/libnvpair/libnvpair.c
+++ b/usr/src/lib/libnvpair/libnvpair.c
@@ -20,6 +20,7 @@
*/
/*
* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012 by Delphix. All rights reserved.
*/
#include <unistd.h>
@@ -803,6 +804,10 @@ dump_nvlist(nvlist_t *list, int indent)
while ((elem = nvlist_next_nvpair(list, elem)) != NULL) {
switch (nvpair_type(elem)) {
+ case DATA_TYPE_BOOLEAN:
+ (void) printf("%*s%s\n", indent, "", nvpair_name(elem));
+ break;
+
case DATA_TYPE_BOOLEAN_VALUE:
(void) nvpair_value_boolean_value(elem, &bool_value);
(void) printf("%*s%s: %s\n", indent, "",
diff --git a/usr/src/lib/libnvpair/mapfile-vers b/usr/src/lib/libnvpair/mapfile-vers
index 079cac5a85..0a1e88b341 100644
--- a/usr/src/lib/libnvpair/mapfile-vers
+++ b/usr/src/lib/libnvpair/mapfile-vers
@@ -20,6 +20,7 @@
#
#
# Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2012 by Delphix. All rights reserved.
#
#
@@ -38,6 +39,73 @@
$mapfile_version 2
+SYMBOL_VERSION ILLUMOS_0.1 { # Illumos additions
+ global:
+ fnvlist_alloc;
+ fnvlist_free;
+ fnvlist_size;
+ fnvlist_pack;
+ fnvlist_pack_free;
+ fnvlist_unpack;
+ fnvlist_dup;
+ fnvlist_merge;
+ fnvlist_add_boolean;
+ fnvlist_add_boolean_value;
+ fnvlist_add_byte;
+ fnvlist_add_int8;
+ fnvlist_add_uint8;
+ fnvlist_add_int16;
+ fnvlist_add_uint16;
+ fnvlist_add_int32;
+ fnvlist_add_uint32;
+ fnvlist_add_int64;
+ fnvlist_add_uint64;
+ fnvlist_add_string;
+ fnvlist_add_nvlist;
+ fnvlist_add_nvpair;
+ fnvlist_add_boolean_array;
+ fnvlist_add_byte_array;
+ fnvlist_add_int8_array;
+ fnvlist_add_uint8_array;
+ fnvlist_add_int16_array;
+ fnvlist_add_uint16_array;
+ fnvlist_add_int32_array;
+ fnvlist_add_uint32_array;
+ fnvlist_add_int64_array;
+ fnvlist_add_uint64_array;
+ fnvlist_add_string_array;
+ fnvlist_add_nvlist_array;
+ fnvlist_remove;
+ fnvlist_remove_nvpair;
+ fnvlist_lookup_nvpair;
+ fnvlist_lookup_boolean;
+ fnvlist_lookup_boolean_value;
+ fnvlist_lookup_byte;
+ fnvlist_lookup_int8;
+ fnvlist_lookup_int16;
+ fnvlist_lookup_int32;
+ fnvlist_lookup_int64;
+ fnvlist_lookup_uint8_t;
+ fnvlist_lookup_uint16;
+ fnvlist_lookup_uint32;
+ fnvlist_lookup_uint64;
+ fnvlist_lookup_string;
+ fnvlist_lookup_nvlist;
+ fnvpair_value_boolean_value;
+ fnvpair_value_byte;
+ fnvpair_value_int8;
+ fnvpair_value_int16;
+ fnvpair_value_int32;
+ fnvpair_value_int64;
+ fnvpair_value_uint8_t;
+ fnvpair_value_uint16;
+ fnvpair_value_uint32;
+ fnvpair_value_uint64;
+ fnvpair_value_string;
+ fnvpair_value_nvlist;
+} SUNW_1.3;
+
+
SYMBOL_VERSION SUNW_1.3 {
global:
nvlist_add_double;
diff --git a/usr/src/lib/libscf/common/scf_tmpl.c b/usr/src/lib/libscf/common/scf_tmpl.c
index 69062e0eb9..cf1517f3d0 100644
--- a/usr/src/lib/libscf/common/scf_tmpl.c
+++ b/usr/src/lib/libscf/common/scf_tmpl.c
@@ -20,6 +20,7 @@
*/
/*
* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright 2012 Milan Jurik. All rights reserved.
*/
/*
@@ -913,8 +914,10 @@ _get_snapshot(scf_instance_t *inst, const char *snapshot,
scf_handle_t *h;
h = scf_instance_handle(inst);
- if (h == NULL)
+ if (h == NULL) {
+ *snap = NULL;
return (-1);
+ }
if ((*snap = scf_snapshot_create(h)) == NULL) {
return (-1);
@@ -2150,7 +2153,8 @@ _get_next_iterator(scf_handle_t *h, scf_pg_tmpl_t *t, const char *snapshot,
scf_instance_destroy(t->pt_inst);
t->pt_inst = _get_restarter_inst(h, t->pt_orig_svc,
t->pt_orig_inst, t->pt_snap);
- scf_service_destroy(t->pt_svc);
+ if (t->pt_svc != t->pt_orig_svc)
+ scf_service_destroy(t->pt_svc);
t->pt_svc = NULL;
break;
@@ -2159,7 +2163,8 @@ _get_next_iterator(scf_handle_t *h, scf_pg_tmpl_t *t, const char *snapshot,
if (t->pt_inst != t->pt_orig_inst)
scf_instance_destroy(t->pt_inst);
t->pt_inst = _get_global_inst(h);
- scf_service_destroy(t->pt_svc);
+ if (t->pt_svc != t->pt_orig_svc)
+ scf_service_destroy(t->pt_svc);
t->pt_svc = NULL;
break;
@@ -2181,7 +2186,6 @@ _get_next_iterator(scf_handle_t *h, scf_pg_tmpl_t *t, const char *snapshot,
goto fail;
}
-
iter = _get_svc_or_inst_iter(h, t);
fail:
return (iter);
diff --git a/usr/src/lib/libshare/smb/Makefile.com b/usr/src/lib/libshare/smb/Makefile.com
index 1a9ce5a652..18ced31487 100644
--- a/usr/src/lib/libshare/smb/Makefile.com
+++ b/usr/src/lib/libshare/smb/Makefile.com
@@ -22,6 +22,8 @@
# Copyright 2010 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
+# Copyright 2012 Nexenta Systems, Inc. All rights reserved.
+#
LIBRARY = libshare_smb.a
VERS = .1
@@ -49,6 +51,7 @@ all install := LDLIBS += -lxml2
CFLAGS += $(CCVERBOSE)
CPPFLAGS += -D_REENTRANT -I$(ADJUNCT_PROTO)/usr/include/libxml2 \
-I$(SRCDIR)/../common
+$(ENABLE_SMB_PRINTING) CPPFLAGS += -DHAVE_CUPS
.KEEP_STATE:
diff --git a/usr/src/lib/libshare/smb/libshare_smb.c b/usr/src/lib/libshare/smb/libshare_smb.c
index 19dd58d72d..f1ed417898 100644
--- a/usr/src/lib/libshare/smb/libshare_smb.c
+++ b/usr/src/lib/libshare/smb/libshare_smb.c
@@ -21,6 +21,7 @@
/*
* Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright 2012 Nexenta Systems, Inc. All rights reserved.
*/
/*
@@ -76,6 +77,7 @@ static int smb_enable_service(void);
static int range_check_validator(int, char *);
static int range_check_validator_zero_ok(int, char *);
static int string_length_check_validator(int, char *);
+static int print_enable_validator(int, char *);
static int true_false_validator(int, char *);
static int ipv4_validator(int, char *);
static int hostname_validator(int, char *);
@@ -912,7 +914,7 @@ struct smb_proto_option_defs {
{ SMB_CI_AUTOHOME_MAP, 0, MAX_VALUE_BUFLEN, path_validator, 0 },
{ SMB_CI_IPV6_ENABLE, 0, 0, true_false_validator,
SMB_REFRESH_REFRESH },
- { SMB_CI_PRINT_ENABLE, 0, 0, true_false_validator,
+ { SMB_CI_PRINT_ENABLE, 0, 0, print_enable_validator,
SMB_REFRESH_REFRESH },
{ SMB_CI_MAP, 0, MAX_VALUE_BUFLEN, cmd_validator, SMB_REFRESH_REFRESH },
{ SMB_CI_UNMAP, 0, MAX_VALUE_BUFLEN, cmd_validator,
@@ -999,6 +1001,27 @@ true_false_validator(int index, char *value)
}
/*
+ * If printing support is compiled in, this is the same as:
+ * true_false_validator. Otherwise, only allow false.
+ */
+/*ARGSUSED*/
+static int
+print_enable_validator(int index, char *value)
+{
+ if (value == NULL)
+ return (SA_BAD_VALUE);
+
+#ifdef HAVE_CUPS
+ if (strcasecmp(value, "true") == 0)
+ return (SA_OK);
+#endif
+ if (strcasecmp(value, "false") == 0)
+ return (SA_OK);
+
+ return (SA_BAD_VALUE);
+}
+
+/*
* Check IP v4 address.
*/
/*ARGSUSED*/
diff --git a/usr/src/lib/libumem/common/envvar.c b/usr/src/lib/libumem/common/envvar.c
index 0c4d872814..2fdf7824c3 100644
--- a/usr/src/lib/libumem/common/envvar.c
+++ b/usr/src/lib/libumem/common/envvar.c
@@ -22,6 +22,7 @@
/*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
+ * Copyright 2012 Joyent, Inc. All rights reserved.
*/
/*
diff --git a/usr/src/lib/libumem/common/vmem_base.c b/usr/src/lib/libumem/common/vmem_base.c
index dcd83ddf31..d64f6362d6 100644
--- a/usr/src/lib/libumem/common/vmem_base.c
+++ b/usr/src/lib/libumem/common/vmem_base.c
@@ -29,7 +29,7 @@
#include "umem_base.h"
uint_t vmem_backend = 0;
-uint_t vmem_allocator = VM_BESTFIT;
+uint_t vmem_allocator = 0;
vmem_t *
vmem_heap_arena(vmem_alloc_t **allocp, vmem_free_t **freep)
diff --git a/usr/src/lib/libuuid/common/uuid.c b/usr/src/lib/libuuid/common/uuid.c
index 8c5171e2f3..92770e0b84 100644
--- a/usr/src/lib/libuuid/common/uuid.c
+++ b/usr/src/lib/libuuid/common/uuid.c
@@ -71,7 +71,6 @@ shared_buffer_t *data;
static uuid_node_t node_id_cache;
static int node_init;
-static int buffer_init;
static int file_type;
static int fd;
@@ -123,11 +122,8 @@ uuid_create(struct uuid *uuid)
* file_type tells us whether we had access to the state file or
* created a temporary one.
*/
- buffer_init = map_state();
-
- if (!buffer_init) {
- return (buffer_init);
- }
+ if (map_state() == -1)
+ return (-1);
/*
* Acquire the lock
diff --git a/usr/src/lib/libzfs/Makefile.com b/usr/src/lib/libzfs/Makefile.com
index 44327f934b..67aa4f4695 100644
--- a/usr/src/lib/libzfs/Makefile.com
+++ b/usr/src/lib/libzfs/Makefile.com
@@ -20,13 +20,14 @@
#
#
# Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
-# Copyright (c) 2011 by Delphix. All rights reserved.
+# Copyright (c) 2012 by Delphix. All rights reserved.
#
LIBRARY= libzfs.a
VERS= .1
OBJS_SHARED= \
+ zfeature_common.o \
zfs_comutil.o \
zfs_deleg.o \
zfs_fletcher.o \
@@ -68,7 +69,7 @@ INCS += -I../../libc/inc
C99MODE= -xc99=%all
C99LMODE= -Xc99=%all
LDLIBS += -lc -lm -ldevid -lgen -lnvpair -luutil -lavl -lefi \
- -ladm -lidmap -ltsol -lmd -lumem
+ -ladm -lidmap -ltsol -lmd -lumem -lzfs_core
CPPFLAGS += $(INCS) -D_LARGEFILE64_SOURCE=1 -D_REENTRANT
SRCS= $(OBJS_COMMON:%.o=$(SRCDIR)/%.c) \
diff --git a/usr/src/lib/libzfs/common/libzfs.h b/usr/src/lib/libzfs/common/libzfs.h
index 67d596b800..bcb99b7758 100644
--- a/usr/src/lib/libzfs/common/libzfs.h
+++ b/usr/src/lib/libzfs/common/libzfs.h
@@ -54,7 +54,8 @@ extern "C" {
/*
* libzfs errors
*/
-enum {
+typedef enum zfs_error {
+ EZFS_SUCCESS = 0, /* no error -- success */
EZFS_NOMEM = 2000, /* out of memory */
EZFS_BADPROP, /* invalid property value */
EZFS_PROPREADONLY, /* cannot set readonly property */
@@ -127,7 +128,7 @@ enum {
EZFS_DIFFDATA, /* bad zfs diff data */
EZFS_POOLREADONLY, /* pool is in read-only mode */
EZFS_UNKNOWN
-};
+} zfs_error_t;
/*
* The following data structures are all part
@@ -184,6 +185,9 @@ extern libzfs_handle_t *zfs_get_handle(zfs_handle_t *);
extern void libzfs_print_on_error(libzfs_handle_t *, boolean_t);
extern void libzfs_set_cachedprops(libzfs_handle_t *, boolean_t);
+extern void zfs_save_arguments(int argc, char **, char *, int);
+extern int zpool_log_history(libzfs_handle_t *, const char *);
+
extern int libzfs_errno(libzfs_handle_t *);
extern const char *libzfs_error_action(libzfs_handle_t *);
extern const char *libzfs_error_description(libzfs_handle_t *);
@@ -218,7 +222,7 @@ extern int zpool_iter(libzfs_handle_t *, zpool_iter_f, void *);
*/
extern int zpool_create(libzfs_handle_t *, const char *, nvlist_t *,
nvlist_t *, nvlist_t *);
-extern int zpool_destroy(zpool_handle_t *);
+extern int zpool_destroy(zpool_handle_t *, const char *);
extern int zpool_add(zpool_handle_t *, nvlist_t *);
typedef struct splitflags {
@@ -293,6 +297,15 @@ typedef enum {
ZPOOL_STATUS_BAD_LOG, /* cannot read log chain(s) */
/*
+ * If the pool has unsupported features but can still be opened in
+ * read-only mode, its status is ZPOOL_STATUS_UNSUP_FEAT_WRITE. If the
+ * pool has unsupported features but cannot be opened at all, its
+ * status is ZPOOL_STATUS_UNSUP_FEAT_READ.
+ */
+ ZPOOL_STATUS_UNSUP_FEAT_READ, /* unsupported features for read */
+ ZPOOL_STATUS_UNSUP_FEAT_WRITE, /* unsupported features for write */
+
+ /*
* These faults have no corresponding message ID. At the time we are
* checking the status, the original reason for the FMA fault (I/O or
* checksum errors) has been lost.
@@ -305,7 +318,8 @@ typedef enum {
* requiring administrative attention. There is no corresponding
* message ID.
*/
- ZPOOL_STATUS_VERSION_OLDER, /* older on-disk version */
+ ZPOOL_STATUS_VERSION_OLDER, /* older legacy on-disk version */
+ ZPOOL_STATUS_FEAT_DISABLED, /* supported features are disabled */
ZPOOL_STATUS_RESILVERING, /* device being resilvered */
ZPOOL_STATUS_OFFLINE_DEV, /* device online */
ZPOOL_STATUS_REMOVED_DEV, /* removed device */
@@ -324,18 +338,20 @@ extern void zpool_dump_ddt(const ddt_stat_t *dds, const ddt_histogram_t *ddh);
* Statistics and configuration functions.
*/
extern nvlist_t *zpool_get_config(zpool_handle_t *, nvlist_t **);
+extern nvlist_t *zpool_get_features(zpool_handle_t *);
extern int zpool_refresh_stats(zpool_handle_t *, boolean_t *);
extern int zpool_get_errlog(zpool_handle_t *, nvlist_t **);
/*
* Import and export functions
*/
-extern int zpool_export(zpool_handle_t *, boolean_t);
-extern int zpool_export_force(zpool_handle_t *);
+extern int zpool_export(zpool_handle_t *, boolean_t, const char *);
+extern int zpool_export_force(zpool_handle_t *, const char *);
extern int zpool_import(libzfs_handle_t *, nvlist_t *, const char *,
char *altroot);
extern int zpool_import_props(libzfs_handle_t *, nvlist_t *, const char *,
nvlist_t *, int);
+extern void zpool_print_unsup_feat(nvlist_t *config);
/*
* Search for pools to import
@@ -364,7 +380,7 @@ extern nvlist_t *zpool_find_import_cached(libzfs_handle_t *, const char *,
*/
struct zfs_cmd;
-extern const char *zfs_history_event_names[LOG_END];
+extern const char *zfs_history_event_names[];
extern char *zpool_vdev_name(libzfs_handle_t *, zpool_handle_t *, nvlist_t *,
boolean_t verbose);
@@ -372,9 +388,6 @@ extern int zpool_upgrade(zpool_handle_t *, uint64_t);
extern int zpool_get_history(zpool_handle_t *, nvlist_t **);
extern int zpool_history_unpack(char *, uint64_t, uint64_t *,
nvlist_t ***, uint_t *);
-extern void zpool_set_history_str(const char *subcommand, int argc,
- char **argv, char *history_str);
-extern int zpool_stage_history(libzfs_handle_t *, const char *);
extern void zpool_obj_to_path(zpool_handle_t *, uint64_t, uint64_t, char *,
size_t len);
extern int zfs_ioctl(libzfs_handle_t *, int, struct zfs_cmd *);
@@ -425,8 +438,8 @@ extern int zfs_prop_get_written_int(zfs_handle_t *zhp, const char *propname,
uint64_t *propvalue);
extern int zfs_prop_get_written(zfs_handle_t *zhp, const char *propname,
char *propbuf, int proplen, boolean_t literal);
-extern int zfs_get_snapused_int(zfs_handle_t *firstsnap, zfs_handle_t *lastsnap,
- uint64_t *usedp);
+extern int zfs_prop_get_feature(zfs_handle_t *zhp, const char *propname,
+ char *buf, size_t len);
extern uint64_t zfs_prop_get_int(zfs_handle_t *, zfs_prop_t);
extern int zfs_prop_inherit(zfs_handle_t *, const char *, boolean_t);
extern const char *zfs_prop_values(zfs_prop_t);
@@ -452,10 +465,19 @@ extern void zfs_prune_proplist(zfs_handle_t *, uint8_t *);
#define ZFS_MOUNTPOINT_NONE "none"
#define ZFS_MOUNTPOINT_LEGACY "legacy"
+#define ZFS_FEATURE_DISABLED "disabled"
+#define ZFS_FEATURE_ENABLED "enabled"
+#define ZFS_FEATURE_ACTIVE "active"
+
+#define ZFS_UNSUPPORTED_INACTIVE "inactive"
+#define ZFS_UNSUPPORTED_READONLY "readonly"
+
/*
* zpool property management
*/
extern int zpool_expand_proplist(zpool_handle_t *, zprop_list_t **);
+extern int zpool_prop_get_feature(zpool_handle_t *, const char *, char *,
+ size_t);
extern const char *zpool_prop_default_string(zpool_prop_t);
extern uint64_t zpool_prop_default_numeric(zpool_prop_t);
extern const char *zpool_prop_column_name(zpool_prop_t);
@@ -533,6 +555,8 @@ extern int zfs_destroy_snaps(zfs_handle_t *, char *, boolean_t);
extern int zfs_destroy_snaps_nvl(zfs_handle_t *, nvlist_t *, boolean_t);
extern int zfs_clone(zfs_handle_t *, const char *, nvlist_t *);
extern int zfs_snapshot(libzfs_handle_t *, const char *, boolean_t, nvlist_t *);
+extern int zfs_snapshot_nvl(libzfs_handle_t *hdl, nvlist_t *snaps,
+ nvlist_t *props);
extern int zfs_rollback(zfs_handle_t *, zfs_handle_t *, boolean_t);
extern int zfs_rename(zfs_handle_t *, const char *, boolean_t, boolean_t);
@@ -560,6 +584,9 @@ typedef struct sendflags {
/* parsable verbose output (ie. -P) */
boolean_t parsable;
+
+ /* show progress (ie. -v) */
+ boolean_t progress;
} sendflags_t;
typedef boolean_t (snapfilter_cb_t)(zfs_handle_t *, void *);
diff --git a/usr/src/lib/libzfs/common/libzfs_config.c b/usr/src/lib/libzfs/common/libzfs_config.c
index dc27238c9c..d5ba20fde0 100644
--- a/usr/src/lib/libzfs/common/libzfs_config.c
+++ b/usr/src/lib/libzfs/common/libzfs_config.c
@@ -18,12 +18,17 @@
*
* CDDL HEADER END
*/
+
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
/*
+ * Copyright (c) 2012 by Delphix. All rights reserved.
+ */
+
+/*
* The pool configuration repository is stored in /etc/zfs/zpool.cache as a
* single packed nvlist. While it would be nice to just read in this
* file from userland, this wouldn't work from a local zone. So we have to have
@@ -218,6 +223,36 @@ zpool_get_config(zpool_handle_t *zhp, nvlist_t **oldconfig)
}
/*
+ * Retrieves a list of enabled features and their refcounts and caches it in
+ * the pool handle.
+ */
+nvlist_t *
+zpool_get_features(zpool_handle_t *zhp)
+{
+ nvlist_t *config, *features;
+
+ config = zpool_get_config(zhp, NULL);
+
+ if (config == NULL || !nvlist_exists(config,
+ ZPOOL_CONFIG_FEATURE_STATS)) {
+ int error;
+ boolean_t missing = B_FALSE;
+
+ error = zpool_refresh_stats(zhp, &missing);
+
+ if (error != 0 || missing)
+ return (NULL);
+
+ config = zpool_get_config(zhp, NULL);
+ }
+
+ verify(nvlist_lookup_nvlist(config, ZPOOL_CONFIG_FEATURE_STATS,
+ &features) == 0);
+
+ return (features);
+}
+
+/*
* Refresh the vdev statistics associated with the given pool. This is used in
* iostat to show configuration changes and determine the delta from the last
* time the function was called. This function can fail, in case the pool has
@@ -302,6 +337,48 @@ zpool_refresh_stats(zpool_handle_t *zhp, boolean_t *missing)
}
/*
+ * If the __ZFS_POOL_RESTRICT environment variable is set we only iterate over
+ * pools it lists.
+ *
+ * This is an undocumented feature for use during testing only.
+ *
+ * This function returns B_TRUE if the pool should be skipped
+ * during iteration.
+ */
+static boolean_t
+check_restricted(const char *poolname)
+{
+ static boolean_t initialized = B_FALSE;
+ static char *restricted = NULL;
+
+ const char *cur, *end;
+ int len, namelen;
+
+ if (!initialized) {
+ initialized = B_TRUE;
+ restricted = getenv("__ZFS_POOL_RESTRICT");
+ }
+
+ if (NULL == restricted)
+ return (B_FALSE);
+
+ cur = restricted;
+ namelen = strlen(poolname);
+ do {
+ end = strchr(cur, ' ');
+ len = (NULL == end) ? strlen(cur) : (end - cur);
+
+ if (len == namelen && 0 == strncmp(cur, poolname, len)) {
+ return (B_FALSE);
+ }
+
+ cur += (len + 1);
+ } while (NULL != end);
+
+ return (B_TRUE);
+}
+
+/*
* Iterate over all pools in the system.
*/
int
@@ -324,6 +401,9 @@ zpool_iter(libzfs_handle_t *hdl, zpool_iter_f func, void *data)
for (cn = uu_avl_first(hdl->libzfs_ns_avl); cn != NULL;
cn = uu_avl_next(hdl->libzfs_ns_avl, cn)) {
+ if (check_restricted(cn->cn_name))
+ continue;
+
if (zpool_open_silent(hdl, cn->cn_name, &zhp) != 0) {
hdl->libzfs_pool_iter--;
return (-1);
@@ -359,6 +439,9 @@ zfs_iter_root(libzfs_handle_t *hdl, zfs_iter_f func, void *data)
for (cn = uu_avl_first(hdl->libzfs_ns_avl); cn != NULL;
cn = uu_avl_next(hdl->libzfs_ns_avl, cn)) {
+ if (check_restricted(cn->cn_name))
+ continue;
+
if ((zhp = make_dataset_handle(hdl, cn->cn_name)) == NULL)
continue;
diff --git a/usr/src/lib/libzfs/common/libzfs_dataset.c b/usr/src/lib/libzfs/common/libzfs_dataset.c
index 97f7cbfbd2..53e012078e 100644
--- a/usr/src/lib/libzfs/common/libzfs_dataset.c
+++ b/usr/src/lib/libzfs/common/libzfs_dataset.c
@@ -24,6 +24,7 @@
* Copyright 2010 Nexenta Systems, Inc. All rights reserved.
* Copyright (c) 2012, Joyent, Inc. All rights reserved.
* Copyright (c) 2012 by Delphix. All rights reserved.
+ * Copyright (c) 2012 DEY Storage Systems, Inc. All rights reserved.
*/
#include <ctype.h>
@@ -1411,8 +1412,7 @@ zfs_prop_set(zfs_handle_t *zhp, const char *propname, const char *propval)
libzfs_handle_t *hdl = zhp->zfs_hdl;
nvlist_t *nvl = NULL, *realprops;
zfs_prop_t prop;
- boolean_t do_prefix;
- uint64_t idx;
+ boolean_t do_prefix = B_TRUE;
int added_resv;
(void) snprintf(errbuf, sizeof (errbuf),
@@ -1451,12 +1451,17 @@ zfs_prop_set(zfs_handle_t *zhp, const char *propname, const char *propval)
}
/*
- * If the dataset's canmount property is being set to noauto,
- * then we want to prevent unmounting & remounting it.
+ * We don't want to unmount & remount the dataset when changing
+ * its canmount property to 'on' or 'noauto'. We only use
+ * the changelist logic to unmount when setting canmount=off.
*/
- do_prefix = !((prop == ZFS_PROP_CANMOUNT) &&
- (zprop_string_to_index(prop, propval, &idx,
- ZFS_TYPE_DATASET) == 0) && (idx == ZFS_CANMOUNT_NOAUTO));
+ if (prop == ZFS_PROP_CANMOUNT) {
+ uint64_t idx;
+ int err = zprop_string_to_index(prop, propval, &idx,
+ ZFS_TYPE_DATASET);
+ if (err == 0 && idx != ZFS_CANMOUNT_OFF)
+ do_prefix = B_FALSE;
+ }
if (do_prefix && (ret = changelist_prefix(cl)) != 0)
goto error;
@@ -2301,6 +2306,17 @@ zfs_prop_get(zfs_handle_t *zhp, zfs_prop_t prop, char *propbuf, size_t proplen,
}
break;
+ case ZFS_PROP_GUID:
+ /*
+ * GUIDs are stored as numbers, but they are identifiers.
+ * We don't want them to be pretty printed, because pretty
+ * printing mangles the ID into a truncated and useless value.
+ */
+ if (get_numeric_property(zhp, prop, src, &source, &val) != 0)
+ return (-1);
+ (void) snprintf(propbuf, proplen, "%llu", (u_longlong_t)val);
+ break;
+
default:
switch (zfs_prop_get_type(prop)) {
case PROP_TYPE_NUMBER:
@@ -2650,25 +2666,6 @@ zfs_prop_get_written(zfs_handle_t *zhp, const char *propname,
return (0);
}
-int
-zfs_get_snapused_int(zfs_handle_t *firstsnap, zfs_handle_t *lastsnap,
- uint64_t *usedp)
-{
- int err;
- zfs_cmd_t zc = { 0 };
-
- (void) strlcpy(zc.zc_name, lastsnap->zfs_name, sizeof (zc.zc_name));
- (void) strlcpy(zc.zc_value, firstsnap->zfs_name, sizeof (zc.zc_value));
-
- err = ioctl(lastsnap->zfs_hdl->libzfs_fd, ZFS_IOC_SPACE_SNAPS, &zc);
- if (err)
- return (err);
-
- *usedp = zc.zc_cookie;
-
- return (0);
-}
-
/*
* Returns the name of the given zfs handle.
*/
@@ -2869,7 +2866,6 @@ create_parents(libzfs_handle_t *hdl, char *target, int prefixlen)
*/
for (cp = target + prefixlen + 1;
cp = strchr(cp, '/'); *cp = '/', cp++) {
- char *logstr;
*cp = '\0';
@@ -2880,16 +2876,12 @@ create_parents(libzfs_handle_t *hdl, char *target, int prefixlen)
continue;
}
- logstr = hdl->libzfs_log_str;
- hdl->libzfs_log_str = NULL;
if (zfs_create(hdl, target, ZFS_TYPE_FILESYSTEM,
NULL) != 0) {
- hdl->libzfs_log_str = logstr;
opname = dgettext(TEXT_DOMAIN, "create");
goto ancestorerr;
}
- hdl->libzfs_log_str = logstr;
h = zfs_open(hdl, target, ZFS_TYPE_FILESYSTEM);
if (h == NULL) {
opname = dgettext(TEXT_DOMAIN, "open");
@@ -2947,12 +2939,12 @@ int
zfs_create(libzfs_handle_t *hdl, const char *path, zfs_type_t type,
nvlist_t *props)
{
- zfs_cmd_t zc = { 0 };
int ret;
uint64_t size = 0;
uint64_t blocksize = zfs_prop_default_numeric(ZFS_PROP_VOLBLOCKSIZE);
char errbuf[1024];
uint64_t zoned;
+ dmu_objset_type_t ost;
(void) snprintf(errbuf, sizeof (errbuf), dgettext(TEXT_DOMAIN,
"cannot create '%s'"), path);
@@ -2972,17 +2964,16 @@ zfs_create(libzfs_handle_t *hdl, const char *path, zfs_type_t type,
* will return ENOENT, not EEXIST. To prevent this from happening, we
* first try to see if the dataset exists.
*/
- (void) strlcpy(zc.zc_name, path, sizeof (zc.zc_name));
- if (zfs_dataset_exists(hdl, zc.zc_name, ZFS_TYPE_DATASET)) {
+ if (zfs_dataset_exists(hdl, path, ZFS_TYPE_DATASET)) {
zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
"dataset already exists"));
return (zfs_error(hdl, EZFS_EXISTS, errbuf));
}
if (type == ZFS_TYPE_VOLUME)
- zc.zc_objset_type = DMU_OST_ZVOL;
+ ost = DMU_OST_ZVOL;
else
- zc.zc_objset_type = DMU_OST_ZFS;
+ ost = DMU_OST_ZFS;
if (props && (props = zfs_valid_proplist(hdl, type, props,
zoned, NULL, errbuf)) == 0)
@@ -3034,14 +3025,9 @@ zfs_create(libzfs_handle_t *hdl, const char *path, zfs_type_t type,
}
}
- if (props && zcmd_write_src_nvlist(hdl, &zc, props) != 0)
- return (-1);
- nvlist_free(props);
-
/* create the dataset */
- ret = zfs_ioctl(hdl, ZFS_IOC_CREATE, &zc);
-
- zcmd_free_nvlists(&zc);
+ ret = lzc_create(path, ost, props);
+ nvlist_free(props);
/* check for failure */
if (ret != 0) {
@@ -3093,7 +3079,8 @@ zfs_create(libzfs_handle_t *hdl, const char *path, zfs_type_t type,
/*
* Destroys the given dataset. The caller must make sure that the filesystem
- * isn't mounted, and that there are no active dependents.
+ * isn't mounted, and that there are no active dependents. If the file system
+ * does not exist this function does nothing.
*/
int
zfs_destroy(zfs_handle_t *zhp, boolean_t defer)
@@ -3109,7 +3096,8 @@ zfs_destroy(zfs_handle_t *zhp, boolean_t defer)
}
zc.zc_defer_destroy = defer;
- if (zfs_ioctl(zhp->zfs_hdl, ZFS_IOC_DESTROY, &zc) != 0) {
+ if (zfs_ioctl(zhp->zfs_hdl, ZFS_IOC_DESTROY, &zc) != 0 &&
+ errno != ENOENT) {
return (zfs_standard_error_fmt(zhp->zfs_hdl, errno,
dgettext(TEXT_DOMAIN, "cannot destroy '%s'"),
zhp->zfs_name));
@@ -3179,33 +3167,35 @@ int
zfs_destroy_snaps_nvl(zfs_handle_t *zhp, nvlist_t *snaps, boolean_t defer)
{
int ret;
- zfs_cmd_t zc = { 0 };
+ nvlist_t *errlist;
- (void) strlcpy(zc.zc_name, zhp->zfs_name, sizeof (zc.zc_name));
- if (zcmd_write_src_nvlist(zhp->zfs_hdl, &zc, snaps) != 0)
- return (-1);
- zc.zc_defer_destroy = defer;
+ ret = lzc_destroy_snaps(snaps, defer, &errlist);
- ret = zfs_ioctl(zhp->zfs_hdl, ZFS_IOC_DESTROY_SNAPS_NVL, &zc);
if (ret != 0) {
- char errbuf[1024];
-
- (void) snprintf(errbuf, sizeof (errbuf), dgettext(TEXT_DOMAIN,
- "cannot destroy snapshots in %s"), zc.zc_name);
-
- switch (errno) {
- case EEXIST:
- zfs_error_aux(zhp->zfs_hdl, dgettext(TEXT_DOMAIN,
- "snapshot is cloned"));
- return (zfs_error(zhp->zfs_hdl, EZFS_EXISTS, errbuf));
+ for (nvpair_t *pair = nvlist_next_nvpair(errlist, NULL);
+ pair != NULL; pair = nvlist_next_nvpair(errlist, pair)) {
+ char errbuf[1024];
+ (void) snprintf(errbuf, sizeof (errbuf),
+ dgettext(TEXT_DOMAIN, "cannot destroy snapshot %s"),
+ nvpair_name(pair));
- default:
- return (zfs_standard_error(zhp->zfs_hdl, errno,
- errbuf));
+ switch (fnvpair_value_int32(pair)) {
+ case EEXIST:
+ zfs_error_aux(zhp->zfs_hdl,
+ dgettext(TEXT_DOMAIN,
+ "snapshot is cloned"));
+ ret = zfs_error(zhp->zfs_hdl, EZFS_EXISTS,
+ errbuf);
+ break;
+ default:
+ ret = zfs_standard_error(zhp->zfs_hdl, errno,
+ errbuf);
+ break;
+ }
}
}
- return (0);
+ return (ret);
}
/*
@@ -3214,12 +3204,10 @@ zfs_destroy_snaps_nvl(zfs_handle_t *zhp, nvlist_t *snaps, boolean_t defer)
int
zfs_clone(zfs_handle_t *zhp, const char *target, nvlist_t *props)
{
- zfs_cmd_t zc = { 0 };
char parent[ZFS_MAXNAMELEN];
int ret;
char errbuf[1024];
libzfs_handle_t *hdl = zhp->zfs_hdl;
- zfs_type_t type;
uint64_t zoned;
assert(zhp->zfs_type == ZFS_TYPE_SNAPSHOT);
@@ -3238,32 +3226,21 @@ zfs_clone(zfs_handle_t *zhp, const char *target, nvlist_t *props)
(void) parent_name(target, parent, sizeof (parent));
/* do the clone */
- if (ZFS_IS_VOLUME(zhp)) {
- zc.zc_objset_type = DMU_OST_ZVOL;
- type = ZFS_TYPE_VOLUME;
- } else {
- zc.zc_objset_type = DMU_OST_ZFS;
- type = ZFS_TYPE_FILESYSTEM;
- }
if (props) {
+ zfs_type_t type;
+ if (ZFS_IS_VOLUME(zhp)) {
+ type = ZFS_TYPE_VOLUME;
+ } else {
+ type = ZFS_TYPE_FILESYSTEM;
+ }
if ((props = zfs_valid_proplist(hdl, type, props, zoned,
zhp, errbuf)) == NULL)
return (-1);
-
- if (zcmd_write_src_nvlist(hdl, &zc, props) != 0) {
- nvlist_free(props);
- return (-1);
- }
-
- nvlist_free(props);
}
- (void) strlcpy(zc.zc_name, target, sizeof (zc.zc_name));
- (void) strlcpy(zc.zc_value, zhp->zfs_name, sizeof (zc.zc_value));
- ret = zfs_ioctl(zhp->zfs_hdl, ZFS_IOC_CREATE, &zc);
-
- zcmd_free_nvlists(&zc);
+ ret = lzc_clone(target, zhp->zfs_name, props);
+ nvlist_free(props);
if (ret != 0) {
switch (errno) {
@@ -3348,74 +3325,134 @@ zfs_promote(zfs_handle_t *zhp)
return (ret);
}
+typedef struct snapdata {
+ nvlist_t *sd_nvl;
+ const char *sd_snapname;
+} snapdata_t;
+
+static int
+zfs_snapshot_cb(zfs_handle_t *zhp, void *arg)
+{
+ snapdata_t *sd = arg;
+ char name[ZFS_MAXNAMELEN];
+ int rv = 0;
+
+ (void) snprintf(name, sizeof (name),
+ "%s@%s", zfs_get_name(zhp), sd->sd_snapname);
+
+ fnvlist_add_boolean(sd->sd_nvl, name);
+
+ rv = zfs_iter_filesystems(zhp, zfs_snapshot_cb, sd);
+ zfs_close(zhp);
+ return (rv);
+}
+
/*
- * Takes a snapshot of the given dataset.
+ * Creates snapshots. The keys in the snaps nvlist are the snapshots to be
+ * created.
*/
int
-zfs_snapshot(libzfs_handle_t *hdl, const char *path, boolean_t recursive,
- nvlist_t *props)
+zfs_snapshot_nvl(libzfs_handle_t *hdl, nvlist_t *snaps, nvlist_t *props)
{
- const char *delim;
- char parent[ZFS_MAXNAMELEN];
- zfs_handle_t *zhp;
- zfs_cmd_t zc = { 0 };
int ret;
char errbuf[1024];
+ nvpair_t *elem;
+ nvlist_t *errors;
(void) snprintf(errbuf, sizeof (errbuf), dgettext(TEXT_DOMAIN,
- "cannot snapshot '%s'"), path);
+ "cannot create snapshots "));
- /* validate the target name */
- if (!zfs_validate_name(hdl, path, ZFS_TYPE_SNAPSHOT, B_TRUE))
- return (zfs_error(hdl, EZFS_INVALIDNAME, errbuf));
+ elem = NULL;
+ while ((elem = nvlist_next_nvpair(snaps, elem)) != NULL) {
+ const char *snapname = nvpair_name(elem);
- if (props) {
- if ((props = zfs_valid_proplist(hdl, ZFS_TYPE_SNAPSHOT,
- props, B_FALSE, NULL, errbuf)) == NULL)
- return (-1);
+ /* validate the target name */
+ if (!zfs_validate_name(hdl, snapname, ZFS_TYPE_SNAPSHOT,
+ B_TRUE)) {
+ (void) snprintf(errbuf, sizeof (errbuf),
+ dgettext(TEXT_DOMAIN,
+ "cannot create snapshot '%s'"), snapname);
+ return (zfs_error(hdl, EZFS_INVALIDNAME, errbuf));
+ }
+ }
- if (zcmd_write_src_nvlist(hdl, &zc, props) != 0) {
- nvlist_free(props);
- return (-1);
+ if (props != NULL &&
+ (props = zfs_valid_proplist(hdl, ZFS_TYPE_SNAPSHOT,
+ props, B_FALSE, NULL, errbuf)) == NULL) {
+ return (-1);
+ }
+
+ ret = lzc_snapshot(snaps, props, &errors);
+
+ if (ret != 0) {
+ boolean_t printed = B_FALSE;
+ for (elem = nvlist_next_nvpair(errors, NULL);
+ elem != NULL;
+ elem = nvlist_next_nvpair(errors, elem)) {
+ (void) snprintf(errbuf, sizeof (errbuf),
+ dgettext(TEXT_DOMAIN,
+ "cannot create snapshot '%s'"), nvpair_name(elem));
+ (void) zfs_standard_error(hdl,
+ fnvpair_value_int32(elem), errbuf);
+ printed = B_TRUE;
}
+ if (!printed) {
+ switch (ret) {
+ case EXDEV:
+ zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
+ "multiple snapshots of same "
+ "fs not allowed"));
+ (void) zfs_error(hdl, EZFS_EXISTS, errbuf);
- nvlist_free(props);
+ break;
+ default:
+ (void) zfs_standard_error(hdl, ret, errbuf);
+ }
+ }
}
- /* make sure the parent exists and is of the appropriate type */
- delim = strchr(path, '@');
- (void) strncpy(parent, path, delim - path);
- parent[delim - path] = '\0';
+ nvlist_free(props);
+ nvlist_free(errors);
+ return (ret);
+}
+
+int
+zfs_snapshot(libzfs_handle_t *hdl, const char *path, boolean_t recursive,
+ nvlist_t *props)
+{
+ int ret;
+ snapdata_t sd = { 0 };
+ char fsname[ZFS_MAXNAMELEN];
+ char *cp;
+ zfs_handle_t *zhp;
+ char errbuf[1024];
- if ((zhp = zfs_open(hdl, parent, ZFS_TYPE_FILESYSTEM |
+ (void) snprintf(errbuf, sizeof (errbuf), dgettext(TEXT_DOMAIN,
+ "cannot snapshot %s"), path);
+
+ if (!zfs_validate_name(hdl, path, ZFS_TYPE_SNAPSHOT, B_TRUE))
+ return (zfs_error(hdl, EZFS_INVALIDNAME, errbuf));
+
+ (void) strlcpy(fsname, path, sizeof (fsname));
+ cp = strchr(fsname, '@');
+ *cp = '\0';
+ sd.sd_snapname = cp + 1;
+
+ if ((zhp = zfs_open(hdl, fsname, ZFS_TYPE_FILESYSTEM |
ZFS_TYPE_VOLUME)) == NULL) {
- zcmd_free_nvlists(&zc);
return (-1);
}
- (void) strlcpy(zc.zc_name, zhp->zfs_name, sizeof (zc.zc_name));
- (void) strlcpy(zc.zc_value, delim+1, sizeof (zc.zc_value));
- if (ZFS_IS_VOLUME(zhp))
- zc.zc_objset_type = DMU_OST_ZVOL;
- else
- zc.zc_objset_type = DMU_OST_ZFS;
- zc.zc_cookie = recursive;
- ret = zfs_ioctl(zhp->zfs_hdl, ZFS_IOC_SNAPSHOT, &zc);
-
- zcmd_free_nvlists(&zc);
-
- /*
- * if it was recursive, the one that actually failed will be in
- * zc.zc_name.
- */
- if (ret != 0) {
- (void) snprintf(errbuf, sizeof (errbuf), dgettext(TEXT_DOMAIN,
- "cannot create snapshot '%s@%s'"), zc.zc_name, zc.zc_value);
- (void) zfs_standard_error(hdl, errno, errbuf);
+ verify(nvlist_alloc(&sd.sd_nvl, NV_UNIQUE_NAME, 0) == 0);
+ if (recursive) {
+ (void) zfs_snapshot_cb(zfs_handle_dup(zhp), &sd);
+ } else {
+ fnvlist_add_boolean(sd.sd_nvl, path);
}
+ ret = zfs_snapshot_nvl(hdl, sd.sd_nvl, props);
+ nvlist_free(sd.sd_nvl);
zfs_close(zhp);
-
return (ret);
}
@@ -3443,17 +3480,13 @@ rollback_destroy(zfs_handle_t *zhp, void *data)
zfs_get_type(zhp) == ZFS_TYPE_SNAPSHOT &&
zfs_prop_get_int(zhp, ZFS_PROP_CREATETXG) >
cbp->cb_create) {
- char *logstr;
cbp->cb_dependent = B_TRUE;
cbp->cb_error |= zfs_iter_dependents(zhp, B_FALSE,
rollback_destroy, cbp);
cbp->cb_dependent = B_FALSE;
- logstr = zhp->zfs_hdl->libzfs_log_str;
- zhp->zfs_hdl->libzfs_log_str = NULL;
cbp->cb_error |= zfs_destroy(zhp, B_FALSE);
- zhp->zfs_hdl->libzfs_log_str = logstr;
}
} else {
/* We must destroy this clone; first unmount it */
diff --git a/usr/src/lib/libzfs/common/libzfs_impl.h b/usr/src/lib/libzfs/common/libzfs_impl.h
index 7bfc84114b..62793dcda1 100644
--- a/usr/src/lib/libzfs/common/libzfs_impl.h
+++ b/usr/src/lib/libzfs/common/libzfs_impl.h
@@ -21,12 +21,12 @@
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2011 by Delphix. All rights reserved.
* Copyright (c) 2012, Joyent, Inc. All rights reserved.
+ * Copyright (c) 2012 by Delphix. All rights reserved.
*/
-#ifndef _LIBFS_IMPL_H
-#define _LIBFS_IMPL_H
+#ifndef _LIBZFS_IMPL_H
+#define _LIBZFS_IMPL_H
#include <sys/dmu.h>
#include <sys/fs/zfs.h>
@@ -37,6 +37,7 @@
#include <libuutil.h>
#include <libzfs.h>
#include <libshare.h>
+#include <libzfs_core.h>
#include <fm/libtopo.h>
@@ -68,7 +69,6 @@ struct libzfs_handle {
int libzfs_desc_active;
char libzfs_action[1024];
char libzfs_desc[1024];
- char *libzfs_log_str;
int libzfs_printerr;
int libzfs_storeerr; /* stuff error messages into buffer */
void *libzfs_sharehdl; /* libshare handle */
@@ -216,4 +216,4 @@ extern void libzfs_fru_clear(libzfs_handle_t *, boolean_t);
}
#endif
-#endif /* _LIBFS_IMPL_H */
+#endif /* _LIBZFS_IMPL_H */
diff --git a/usr/src/lib/libzfs/common/libzfs_iter.c b/usr/src/lib/libzfs/common/libzfs_iter.c
index 7fe69e29e2..48333df7d9 100644
--- a/usr/src/lib/libzfs/common/libzfs_iter.c
+++ b/usr/src/lib/libzfs/common/libzfs_iter.c
@@ -22,8 +22,8 @@
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright 2010 Nexenta Systems, Inc. All rights reserved.
- * Copyright (c) 2011 by Delphix. All rights reserved.
* Copyright (c) 2012, Joyent, Inc. All rights reserved.
+ * Copyright (c) 2012 by Delphix. All rights reserved.
*/
#include <stdio.h>
@@ -309,12 +309,11 @@ int
zfs_iter_snapspec(zfs_handle_t *fs_zhp, const char *spec_orig,
zfs_iter_f func, void *arg)
{
- char buf[ZFS_MAXNAMELEN];
- char *comma_separated, *cp;
+ char *buf, *comma_separated, *cp;
int err = 0;
int ret = 0;
- (void) strlcpy(buf, spec_orig, sizeof (buf));
+ buf = zfs_strdup(fs_zhp->zfs_hdl, spec_orig);
cp = buf;
while ((comma_separated = strsep(&cp, ",")) != NULL) {
@@ -372,6 +371,7 @@ zfs_iter_snapspec(zfs_handle_t *fs_zhp, const char *spec_orig,
}
}
+ free(buf);
return (ret);
}
diff --git a/usr/src/lib/libzfs/common/libzfs_pool.c b/usr/src/lib/libzfs/common/libzfs_pool.c
index cbf0718376..8315e1404b 100644
--- a/usr/src/lib/libzfs/common/libzfs_pool.c
+++ b/usr/src/lib/libzfs/common/libzfs_pool.c
@@ -35,6 +35,7 @@
#include <stdlib.h>
#include <strings.h>
#include <unistd.h>
+#include <libgen.h>
#include <sys/efi_partition.h>
#include <sys/vtoc.h>
#include <sys/zfs_ioctl.h>
@@ -44,6 +45,7 @@
#include "zfs_prop.h"
#include "libzfs_impl.h"
#include "zfs_comutil.h"
+#include "zfeature_common.h"
static int read_efi_label(nvlist_t *config, diskaddr_t *sb);
@@ -280,6 +282,7 @@ zpool_get_prop(zpool_handle_t *zhp, zpool_prop_t prop, char *buf, size_t len,
case ZPOOL_PROP_SIZE:
case ZPOOL_PROP_ALLOCATED:
case ZPOOL_PROP_FREE:
+ case ZPOOL_PROP_FREEING:
case ZPOOL_PROP_EXPANDSZ:
(void) zfs_nicenum(intval, buf, len);
break;
@@ -305,6 +308,12 @@ zpool_get_prop(zpool_handle_t *zhp, zpool_prop_t prop, char *buf, size_t len,
(void) strlcpy(buf, zpool_state_to_name(intval,
vs->vs_aux), len);
break;
+ case ZPOOL_PROP_VERSION:
+ if (intval >= SPA_VERSION_FEATURES) {
+ (void) snprintf(buf, len, "-");
+ break;
+ }
+ /* FALLTHROUGH */
default:
(void) snprintf(buf, len, "%llu", intval);
}
@@ -408,10 +417,48 @@ zpool_valid_proplist(libzfs_handle_t *hdl, const char *poolname,
while ((elem = nvlist_next_nvpair(props, elem)) != NULL) {
const char *propname = nvpair_name(elem);
+ prop = zpool_name_to_prop(propname);
+ if (prop == ZPROP_INVAL && zpool_prop_feature(propname)) {
+ int err;
+ zfeature_info_t *feature;
+ char *fname = strchr(propname, '@') + 1;
+
+ err = zfeature_lookup_name(fname, &feature);
+ if (err != 0) {
+ ASSERT3U(err, ==, ENOENT);
+ zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
+ "invalid feature '%s'"), fname);
+ (void) zfs_error(hdl, EZFS_BADPROP, errbuf);
+ goto error;
+ }
+
+ if (nvpair_type(elem) != DATA_TYPE_STRING) {
+ zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
+ "'%s' must be a string"), propname);
+ (void) zfs_error(hdl, EZFS_BADPROP, errbuf);
+ goto error;
+ }
+
+ (void) nvpair_value_string(elem, &strval);
+ if (strcmp(strval, ZFS_FEATURE_ENABLED) != 0) {
+ zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
+ "property '%s' can only be set to "
+ "'enabled'"), propname);
+ (void) zfs_error(hdl, EZFS_BADPROP, errbuf);
+ goto error;
+ }
+
+ if (nvlist_add_uint64(retprops, propname, 0) != 0) {
+ (void) no_memory(hdl);
+ goto error;
+ }
+ continue;
+ }
+
/*
* Make sure this property is valid and applies to this type.
*/
- if ((prop = zpool_name_to_prop(propname)) == ZPROP_INVAL) {
+ if (prop == ZPROP_INVAL) {
zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
"invalid property '%s'"), propname);
(void) zfs_error(hdl, EZFS_BADPROP, errbuf);
@@ -434,7 +481,8 @@ zpool_valid_proplist(libzfs_handle_t *hdl, const char *poolname,
*/
switch (prop) {
case ZPOOL_PROP_VERSION:
- if (intval < version || intval > SPA_VERSION) {
+ if (intval < version ||
+ !SPA_VERSION_IS_SUPPORTED(intval)) {
zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
"property '%s' number %d is invalid."),
propname, intval);
@@ -656,10 +704,77 @@ zpool_expand_proplist(zpool_handle_t *zhp, zprop_list_t **plp)
libzfs_handle_t *hdl = zhp->zpool_hdl;
zprop_list_t *entry;
char buf[ZFS_MAXPROPLEN];
+ nvlist_t *features = NULL;
+ zprop_list_t **last;
+ boolean_t firstexpand = (NULL == *plp);
if (zprop_expand_list(hdl, plp, ZFS_TYPE_POOL) != 0)
return (-1);
+ last = plp;
+ while (*last != NULL)
+ last = &(*last)->pl_next;
+
+ if ((*plp)->pl_all)
+ features = zpool_get_features(zhp);
+
+ if ((*plp)->pl_all && firstexpand) {
+ for (int i = 0; i < SPA_FEATURES; i++) {
+ zprop_list_t *entry = zfs_alloc(hdl,
+ sizeof (zprop_list_t));
+ entry->pl_prop = ZPROP_INVAL;
+ entry->pl_user_prop = zfs_asprintf(hdl, "feature@%s",
+ spa_feature_table[i].fi_uname);
+ entry->pl_width = strlen(entry->pl_user_prop);
+ entry->pl_all = B_TRUE;
+
+ *last = entry;
+ last = &entry->pl_next;
+ }
+ }
+
+ /* add any unsupported features */
+ for (nvpair_t *nvp = nvlist_next_nvpair(features, NULL);
+ nvp != NULL; nvp = nvlist_next_nvpair(features, nvp)) {
+ char *propname;
+ boolean_t found;
+ zprop_list_t *entry;
+
+ if (zfeature_is_supported(nvpair_name(nvp)))
+ continue;
+
+ propname = zfs_asprintf(hdl, "unsupported@%s",
+ nvpair_name(nvp));
+
+ /*
+ * Before adding the property to the list make sure that no
+ * other pool already added the same property.
+ */
+ found = B_FALSE;
+ entry = *plp;
+ while (entry != NULL) {
+ if (entry->pl_user_prop != NULL &&
+ strcmp(propname, entry->pl_user_prop) == 0) {
+ found = B_TRUE;
+ break;
+ }
+ entry = entry->pl_next;
+ }
+ if (found) {
+ free(propname);
+ continue;
+ }
+
+ entry = zfs_alloc(hdl, sizeof (zprop_list_t));
+ entry->pl_prop = ZPROP_INVAL;
+ entry->pl_user_prop = propname;
+ entry->pl_width = strlen(entry->pl_user_prop);
+ entry->pl_all = B_TRUE;
+
+ *last = entry;
+ last = &entry->pl_next;
+ }
+
for (entry = *plp; entry != NULL; entry = entry->pl_next) {
if (entry->pl_fixed)
@@ -676,6 +791,66 @@ zpool_expand_proplist(zpool_handle_t *zhp, zprop_list_t **plp)
return (0);
}
+/*
+ * Get the state for the given feature on the given ZFS pool.
+ */
+int
+zpool_prop_get_feature(zpool_handle_t *zhp, const char *propname, char *buf,
+ size_t len)
+{
+ uint64_t refcount;
+ boolean_t found = B_FALSE;
+ nvlist_t *features = zpool_get_features(zhp);
+ boolean_t supported;
+ const char *feature = strchr(propname, '@') + 1;
+
+ supported = zpool_prop_feature(propname);
+ ASSERT(supported || zfs_prop_unsupported(propname));
+
+ /*
+ * Convert from feature name to feature guid. This conversion is
+ * unecessary for unsupported@... properties because they already
+ * use guids.
+ */
+ if (supported) {
+ int ret;
+ zfeature_info_t *fi;
+
+ ret = zfeature_lookup_name(feature, &fi);
+ if (ret != 0) {
+ (void) strlcpy(buf, "-", len);
+ return (ENOTSUP);
+ }
+ feature = fi->fi_guid;
+ }
+
+ if (nvlist_lookup_uint64(features, feature, &refcount) == 0)
+ found = B_TRUE;
+
+ if (supported) {
+ if (!found) {
+ (void) strlcpy(buf, ZFS_FEATURE_DISABLED, len);
+ } else {
+ if (refcount == 0)
+ (void) strlcpy(buf, ZFS_FEATURE_ENABLED, len);
+ else
+ (void) strlcpy(buf, ZFS_FEATURE_ACTIVE, len);
+ }
+ } else {
+ if (found) {
+ if (refcount == 0) {
+ (void) strcpy(buf, ZFS_UNSUPPORTED_INACTIVE);
+ } else {
+ (void) strcpy(buf, ZFS_UNSUPPORTED_READONLY);
+ }
+ } else {
+ (void) strlcpy(buf, "-", len);
+ return (ENOTSUP);
+ }
+ }
+
+ return (0);
+}
/*
* Don't start the slice at the default block of 34; many storage
@@ -1039,7 +1214,7 @@ create_failed:
* datasets left in the pool.
*/
int
-zpool_destroy(zpool_handle_t *zhp)
+zpool_destroy(zpool_handle_t *zhp, const char *log_str)
{
zfs_cmd_t zc = { 0 };
zfs_handle_t *zfp = NULL;
@@ -1051,6 +1226,7 @@ zpool_destroy(zpool_handle_t *zhp)
return (-1);
(void) strlcpy(zc.zc_name, zhp->zpool_name, sizeof (zc.zc_name));
+ zc.zc_history = (uint64_t)(uintptr_t)log_str;
if (zfs_ioctl(hdl, ZFS_IOC_POOL_DESTROY, &zc) != 0) {
(void) snprintf(msg, sizeof (msg), dgettext(TEXT_DOMAIN,
@@ -1205,8 +1381,9 @@ zpool_add(zpool_handle_t *zhp, nvlist_t *nvroot)
* Exports the pool from the system. The caller must ensure that there are no
* mounted datasets in the pool.
*/
-int
-zpool_export_common(zpool_handle_t *zhp, boolean_t force, boolean_t hardforce)
+static int
+zpool_export_common(zpool_handle_t *zhp, boolean_t force, boolean_t hardforce,
+ const char *log_str)
{
zfs_cmd_t zc = { 0 };
char msg[1024];
@@ -1217,6 +1394,7 @@ zpool_export_common(zpool_handle_t *zhp, boolean_t force, boolean_t hardforce)
(void) strlcpy(zc.zc_name, zhp->zpool_name, sizeof (zc.zc_name));
zc.zc_cookie = force;
zc.zc_guid = hardforce;
+ zc.zc_history = (uint64_t)(uintptr_t)log_str;
if (zfs_ioctl(zhp->zpool_hdl, ZFS_IOC_POOL_EXPORT, &zc) != 0) {
switch (errno) {
@@ -1238,15 +1416,15 @@ zpool_export_common(zpool_handle_t *zhp, boolean_t force, boolean_t hardforce)
}
int
-zpool_export(zpool_handle_t *zhp, boolean_t force)
+zpool_export(zpool_handle_t *zhp, boolean_t force, const char *log_str)
{
- return (zpool_export_common(zhp, force, B_FALSE));
+ return (zpool_export_common(zhp, force, B_FALSE, log_str));
}
int
-zpool_export_force(zpool_handle_t *zhp)
+zpool_export_force(zpool_handle_t *zhp, const char *log_str)
{
- return (zpool_export_common(zhp, B_TRUE, B_TRUE));
+ return (zpool_export_common(zhp, B_TRUE, B_TRUE, log_str));
}
static void
@@ -1262,8 +1440,10 @@ zpool_rewind_exclaim(libzfs_handle_t *hdl, const char *name, boolean_t dryrun,
if (!hdl->libzfs_printerr || config == NULL)
return;
- if (nvlist_lookup_nvlist(config, ZPOOL_CONFIG_LOAD_INFO, &nv) != 0)
+ if (nvlist_lookup_nvlist(config, ZPOOL_CONFIG_LOAD_INFO, &nv) != 0 ||
+ nvlist_lookup_nvlist(nv, ZPOOL_CONFIG_REWIND_INFO, &nv) != 0) {
return;
+ }
if (nvlist_lookup_uint64(nv, ZPOOL_CONFIG_LOAD_TIME, &rewindto) != 0)
return;
@@ -1319,6 +1499,7 @@ zpool_explain_recover(libzfs_handle_t *hdl, const char *name, int reason,
/* All attempted rewinds failed if ZPOOL_CONFIG_LOAD_TIME missing */
if (nvlist_lookup_nvlist(config, ZPOOL_CONFIG_LOAD_INFO, &nv) != 0 ||
+ nvlist_lookup_nvlist(nv, ZPOOL_CONFIG_REWIND_INFO, &nv) != 0 ||
nvlist_lookup_uint64(nv, ZPOOL_CONFIG_LOAD_TIME, &rewindto) != 0)
goto no_info;
@@ -1441,6 +1622,30 @@ print_vdev_tree(libzfs_handle_t *hdl, const char *name, nvlist_t *nv,
}
}
+void
+zpool_print_unsup_feat(nvlist_t *config)
+{
+ nvlist_t *nvinfo, *unsup_feat;
+
+ verify(nvlist_lookup_nvlist(config, ZPOOL_CONFIG_LOAD_INFO, &nvinfo) ==
+ 0);
+ verify(nvlist_lookup_nvlist(nvinfo, ZPOOL_CONFIG_UNSUP_FEAT,
+ &unsup_feat) == 0);
+
+ for (nvpair_t *nvp = nvlist_next_nvpair(unsup_feat, NULL); nvp != NULL;
+ nvp = nvlist_next_nvpair(unsup_feat, nvp)) {
+ char *desc;
+
+ verify(nvpair_type(nvp) == DATA_TYPE_STRING);
+ verify(nvpair_value_string(nvp, &desc) == 0);
+
+ if (strlen(desc) > 0)
+ (void) printf("\t%s (%s)\n", nvpair_name(nvp), desc);
+ else
+ (void) printf("\t%s\n", nvpair_name(nvp));
+ }
+}
+
/*
* Import the given pool using the known configuration and a list of
* properties to be set. The configuration should have come from
@@ -1547,6 +1752,22 @@ zpool_import_props(libzfs_handle_t *hdl, nvlist_t *config, const char *newname,
switch (error) {
case ENOTSUP:
+ if (nv != NULL && nvlist_lookup_nvlist(nv,
+ ZPOOL_CONFIG_LOAD_INFO, &nvinfo) == 0 &&
+ nvlist_exists(nvinfo, ZPOOL_CONFIG_UNSUP_FEAT)) {
+ (void) printf(dgettext(TEXT_DOMAIN, "This "
+ "pool uses the following feature(s) not "
+ "supported by this system:\n"));
+ zpool_print_unsup_feat(nv);
+ if (nvlist_exists(nvinfo,
+ ZPOOL_CONFIG_CAN_RDONLY)) {
+ (void) printf(dgettext(TEXT_DOMAIN,
+ "All unsupported features are only "
+ "required for writing to the pool."
+ "\nThe pool can be imported using "
+ "'-o readonly=on'.\n"));
+ }
+ }
/*
* Unsupported version.
*/
@@ -3365,40 +3586,30 @@ zpool_upgrade(zpool_handle_t *zhp, uint64_t new_version)
}
void
-zpool_set_history_str(const char *subcommand, int argc, char **argv,
- char *history_str)
+zfs_save_arguments(int argc, char **argv, char *string, int len)
{
- int i;
-
- (void) strlcpy(history_str, subcommand, HIS_MAX_RECORD_LEN);
- for (i = 1; i < argc; i++) {
- if (strlen(history_str) + 1 + strlen(argv[i]) >
- HIS_MAX_RECORD_LEN)
- break;
- (void) strlcat(history_str, " ", HIS_MAX_RECORD_LEN);
- (void) strlcat(history_str, argv[i], HIS_MAX_RECORD_LEN);
+ (void) strlcpy(string, basename(argv[0]), len);
+ for (int i = 1; i < argc; i++) {
+ (void) strlcat(string, " ", len);
+ (void) strlcat(string, argv[i], len);
}
}
-/*
- * Stage command history for logging.
- */
int
-zpool_stage_history(libzfs_handle_t *hdl, const char *history_str)
+zpool_log_history(libzfs_handle_t *hdl, const char *message)
{
- if (history_str == NULL)
- return (EINVAL);
-
- if (strlen(history_str) > HIS_MAX_RECORD_LEN)
- return (EINVAL);
-
- if (hdl->libzfs_log_str != NULL)
- free(hdl->libzfs_log_str);
-
- if ((hdl->libzfs_log_str = strdup(history_str)) == NULL)
- return (no_memory(hdl));
-
- return (0);
+ zfs_cmd_t zc = { 0 };
+ nvlist_t *args;
+ int err;
+
+ args = fnvlist_alloc();
+ fnvlist_add_string(args, "message", message);
+ err = zcmd_write_src_nvlist(hdl, &zc, args);
+ if (err == 0)
+ err = ioctl(hdl->libzfs_fd, ZFS_IOC_LOG_HISTORY, &zc);
+ nvlist_free(args);
+ zcmd_free_nvlists(&zc);
+ return (err);
}
/*
diff --git a/usr/src/lib/libzfs/common/libzfs_sendrecv.c b/usr/src/lib/libzfs/common/libzfs_sendrecv.c
index 224e46812a..ee6e64319e 100644
--- a/usr/src/lib/libzfs/common/libzfs_sendrecv.c
+++ b/usr/src/lib/libzfs/common/libzfs_sendrecv.c
@@ -21,7 +21,8 @@
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2011 by Delphix. All rights reserved.
+ * Copyright (c) 2012 by Delphix. All rights reserved.
+ * Copyright (c) 2012, Joyent, Inc. All rights reserved.
*/
#include <assert.h>
@@ -37,6 +38,7 @@
#include <sys/mount.h>
#include <pthread.h>
#include <umem.h>
+#include <time.h>
#include <libzfs.h>
@@ -62,6 +64,12 @@ typedef struct dedup_arg {
libzfs_handle_t *dedup_hdl;
} dedup_arg_t;
+typedef struct progress_arg {
+ zfs_handle_t *pa_zhp;
+ int pa_fd;
+ boolean_t pa_parsable;
+} progress_arg_t;
+
typedef struct dataref {
uint64_t ref_guid;
uint64_t ref_object;
@@ -781,7 +789,7 @@ typedef struct send_dump_data {
char prevsnap[ZFS_MAXNAMELEN];
uint64_t prevsnap_obj;
boolean_t seenfrom, seento, replicate, doall, fromorigin;
- boolean_t verbose, dryrun, parsable;
+ boolean_t verbose, dryrun, parsable, progress;
int outfd;
boolean_t err;
nvlist_t *fss;
@@ -973,10 +981,60 @@ hold_for_send(zfs_handle_t *zhp, send_dump_data_t *sdd)
return (error);
}
+static void *
+send_progress_thread(void *arg)
+{
+ progress_arg_t *pa = arg;
+
+ zfs_cmd_t zc = { 0 };
+ zfs_handle_t *zhp = pa->pa_zhp;
+ libzfs_handle_t *hdl = zhp->zfs_hdl;
+ unsigned long long bytes;
+ char buf[16];
+
+ time_t t;
+ struct tm *tm;
+
+ assert(zhp->zfs_type == ZFS_TYPE_SNAPSHOT);
+ (void) strlcpy(zc.zc_name, zhp->zfs_name, sizeof (zc.zc_name));
+
+ if (!pa->pa_parsable)
+ (void) fprintf(stderr, "TIME SENT SNAPSHOT\n");
+
+ /*
+ * Print the progress from ZFS_IOC_SEND_PROGRESS every second.
+ */
+ for (;;) {
+ (void) sleep(1);
+
+ zc.zc_cookie = pa->pa_fd;
+ if (zfs_ioctl(hdl, ZFS_IOC_SEND_PROGRESS, &zc) != 0)
+ return ((void *)-1);
+
+ (void) time(&t);
+ tm = localtime(&t);
+ bytes = zc.zc_cookie;
+
+ if (pa->pa_parsable) {
+ (void) fprintf(stderr, "%02d:%02d:%02d\t%llu\t%s\n",
+ tm->tm_hour, tm->tm_min, tm->tm_sec,
+ bytes, zhp->zfs_name);
+ } else {
+ zfs_nicenum(bytes, buf, sizeof (buf));
+ (void) fprintf(stderr, "%02d:%02d:%02d %5s %s\n",
+ tm->tm_hour, tm->tm_min, tm->tm_sec,
+ buf, zhp->zfs_name);
+ }
+ }
+}
+
static int
dump_snapshot(zfs_handle_t *zhp, void *arg)
{
send_dump_data_t *sdd = arg;
+ progress_arg_t pa = { 0 };
+ pthread_t tid;
+
char *thissnap;
int err;
boolean_t isfromsnap, istosnap, fromorigin;
@@ -1094,8 +1152,29 @@ dump_snapshot(zfs_handle_t *zhp, void *arg)
}
if (!sdd->dryrun) {
+ /*
+ * If progress reporting is requested, spawn a new thread to
+ * poll ZFS_IOC_SEND_PROGRESS at a regular interval.
+ */
+ if (sdd->progress) {
+ pa.pa_zhp = zhp;
+ pa.pa_fd = sdd->outfd;
+ pa.pa_parsable = sdd->parsable;
+
+ if (err = pthread_create(&tid, NULL,
+ send_progress_thread, &pa)) {
+ zfs_close(zhp);
+ return (err);
+ }
+ }
+
err = dump_ioctl(zhp, sdd->prevsnap, sdd->prevsnap_obj,
fromorigin, sdd->outfd, sdd->debugnv);
+
+ if (sdd->progress) {
+ (void) pthread_cancel(tid);
+ (void) pthread_join(tid, NULL);
+ }
}
(void) strcpy(sdd->prevsnap, thissnap);
@@ -1302,7 +1381,6 @@ zfs_send(zfs_handle_t *zhp, const char *fromsnap, const char *tosnap,
avl_tree_t *fsavl = NULL;
static uint64_t holdseq;
int spa_version;
- boolean_t holdsnaps = B_FALSE;
pthread_t tid;
int pipefd[2];
dedup_arg_t dda = { 0 };
@@ -1325,11 +1403,6 @@ zfs_send(zfs_handle_t *zhp, const char *fromsnap, const char *tosnap,
}
}
- if (!flags->dryrun && zfs_spa_version(zhp, &spa_version) == 0 &&
- spa_version >= SPA_VERSION_USERREFS &&
- (flags->doall || flags->replicate))
- holdsnaps = B_TRUE;
-
if (flags->dedup && !flags->dryrun) {
featureflags |= (DMU_BACKUP_FEATURE_DEDUP |
DMU_BACKUP_FEATURE_DEDUPPROPS);
@@ -1445,12 +1518,24 @@ zfs_send(zfs_handle_t *zhp, const char *fromsnap, const char *tosnap,
sdd.fsavl = fsavl;
sdd.verbose = flags->verbose;
sdd.parsable = flags->parsable;
+ sdd.progress = flags->progress;
sdd.dryrun = flags->dryrun;
sdd.filter_cb = filter_func;
sdd.filter_cb_arg = cb_arg;
if (debugnvp)
sdd.debugnv = *debugnvp;
- if (holdsnaps) {
+
+ /*
+ * Some flags require that we place user holds on the datasets that are
+ * being sent so they don't get destroyed during the send. We can skip
+ * this step if the pool is imported read-only since the datasets cannot
+ * be destroyed.
+ */
+ if (!flags->dryrun && !zpool_get_prop_int(zfs_get_pool_handle(zhp),
+ ZPOOL_PROP_READONLY, NULL) &&
+ zfs_spa_version(zhp, &spa_version) == 0 &&
+ spa_version >= SPA_VERSION_USERREFS &&
+ (flags->doall || flags->replicate)) {
++holdseq;
(void) snprintf(sdd.holdtag, sizeof (sdd.holdtag),
".send-%d-%llu", getpid(), (u_longlong_t)holdseq);
diff --git a/usr/src/lib/libzfs/common/libzfs_status.c b/usr/src/lib/libzfs/common/libzfs_status.c
index 24725ec044..560bacdc37 100644
--- a/usr/src/lib/libzfs/common/libzfs_status.c
+++ b/usr/src/lib/libzfs/common/libzfs_status.c
@@ -18,8 +18,10 @@
*
* CDDL HEADER END
*/
+
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012 by Delphix. All rights reserved.
*/
/*
@@ -42,6 +44,7 @@
#include <string.h>
#include <unistd.h>
#include "libzfs_impl.h"
+#include "zfeature_common.h"
/*
* Message ID table. This must be kept in sync with the ZPOOL_STATUS_* defines
@@ -214,6 +217,20 @@ check_status(nvlist_t *config, boolean_t isimport)
return (ZPOOL_STATUS_VERSION_NEWER);
/*
+ * Unsupported feature(s).
+ */
+ if (vs->vs_state == VDEV_STATE_CANT_OPEN &&
+ vs->vs_aux == VDEV_AUX_UNSUP_FEAT) {
+ nvlist_t *nvinfo;
+
+ verify(nvlist_lookup_nvlist(config, ZPOOL_CONFIG_LOAD_INFO,
+ &nvinfo) == 0);
+ if (nvlist_exists(nvinfo, ZPOOL_CONFIG_CAN_RDONLY))
+ return (ZPOOL_STATUS_UNSUP_FEAT_WRITE);
+ return (ZPOOL_STATUS_UNSUP_FEAT_READ);
+ }
+
+ /*
* Check that the config is complete.
*/
if (vs->vs_state == VDEV_STATE_CANT_OPEN &&
@@ -300,9 +317,33 @@ check_status(nvlist_t *config, boolean_t isimport)
/*
* Outdated, but usable, version
*/
- if (version < SPA_VERSION)
+ if (SPA_VERSION_IS_SUPPORTED(version) && version != SPA_VERSION)
return (ZPOOL_STATUS_VERSION_OLDER);
+ /*
+ * Usable pool with disabled features
+ */
+ if (version >= SPA_VERSION_FEATURES) {
+ int i;
+ nvlist_t *feat;
+
+ if (isimport) {
+ feat = fnvlist_lookup_nvlist(config,
+ ZPOOL_CONFIG_LOAD_INFO);
+ feat = fnvlist_lookup_nvlist(feat,
+ ZPOOL_CONFIG_ENABLED_FEAT);
+ } else {
+ feat = fnvlist_lookup_nvlist(config,
+ ZPOOL_CONFIG_FEATURE_STATS);
+ }
+
+ for (i = 0; i < SPA_FEATURES; i++) {
+ zfeature_info_t *fi = &spa_feature_table[i];
+ if (!nvlist_exists(feat, fi->fi_guid))
+ return (ZPOOL_STATUS_FEAT_DISABLED);
+ }
+ }
+
return (ZPOOL_STATUS_OK);
}
diff --git a/usr/src/lib/libzfs/common/libzfs_util.c b/usr/src/lib/libzfs/common/libzfs_util.c
index 4f6c1cfbda..8706a6fdbb 100644
--- a/usr/src/lib/libzfs/common/libzfs_util.c
+++ b/usr/src/lib/libzfs/common/libzfs_util.c
@@ -18,10 +18,11 @@
*
* CDDL HEADER END
*/
+
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2011 by Delphix. All rights reserved.
* Copyright (c) 2012, Joyent, Inc. All rights reserved.
+ * Copyright (c) 2012 by Delphix. All rights reserved.
*/
/*
@@ -43,9 +44,11 @@
#include <sys/types.h>
#include <libzfs.h>
+#include <libzfs_core.h>
#include "libzfs_impl.h"
#include "zfs_prop.h"
+#include "zfeature_common.h"
int
libzfs_errno(libzfs_handle_t *hdl)
@@ -116,7 +119,8 @@ libzfs_error_description(libzfs_handle_t *hdl)
case EZFS_RESILVERING:
return (dgettext(TEXT_DOMAIN, "currently resilvering"));
case EZFS_BADVERSION:
- return (dgettext(TEXT_DOMAIN, "unsupported version"));
+ return (dgettext(TEXT_DOMAIN, "unsupported version or "
+ "feature"));
case EZFS_POOLUNAVAIL:
return (dgettext(TEXT_DOMAIN, "pool is unavailable"));
case EZFS_DEVOVERFLOW:
@@ -667,8 +671,17 @@ libzfs_init(void)
hdl->libzfs_sharetab = fopen("/etc/dfs/sharetab", "r");
+ if (libzfs_core_init() != 0) {
+ (void) close(hdl->libzfs_fd);
+ (void) fclose(hdl->libzfs_mnttab);
+ (void) fclose(hdl->libzfs_sharetab);
+ free(hdl);
+ return (NULL);
+ }
+
zfs_prop_init();
zpool_prop_init();
+ zpool_feature_init();
libzfs_mnttab_init(hdl);
hdl->libzfs_cachedprops = B_FALSE;
@@ -685,12 +698,11 @@ libzfs_fini(libzfs_handle_t *hdl)
if (hdl->libzfs_sharetab)
(void) fclose(hdl->libzfs_sharetab);
zfs_uninit_libshare(hdl);
- if (hdl->libzfs_log_str)
- (void) free(hdl->libzfs_log_str);
zpool_free_handles(hdl);
libzfs_fru_clear(hdl, B_TRUE);
namespace_clear(hdl);
libzfs_mnttab_fini(hdl);
+ libzfs_core_fini();
free(hdl);
}
@@ -852,17 +864,7 @@ zcmd_read_dst_nvlist(libzfs_handle_t *hdl, zfs_cmd_t *zc, nvlist_t **nvlp)
int
zfs_ioctl(libzfs_handle_t *hdl, int request, zfs_cmd_t *zc)
{
- int error;
-
- zc->zc_history = (uint64_t)(uintptr_t)hdl->libzfs_log_str;
- error = ioctl(hdl->libzfs_fd, request, zc);
- if (hdl->libzfs_log_str) {
- free(hdl->libzfs_log_str);
- hdl->libzfs_log_str = NULL;
- }
- zc->zc_history = 0;
-
- return (error);
+ return (ioctl(hdl->libzfs_fd, request, zc));
}
/*
@@ -1324,9 +1326,11 @@ addlist(libzfs_handle_t *hdl, char *propname, zprop_list_t **listp,
* this is a pool property or if this isn't a user-defined
* dataset property,
*/
- if (prop == ZPROP_INVAL && (type == ZFS_TYPE_POOL ||
- (!zfs_prop_user(propname) && !zfs_prop_userquota(propname) &&
- !zfs_prop_written(propname)))) {
+ if (prop == ZPROP_INVAL && ((type == ZFS_TYPE_POOL &&
+ !zpool_prop_feature(propname) &&
+ !zpool_prop_unsupported(propname)) ||
+ (type == ZFS_TYPE_DATASET && !zfs_prop_user(propname) &&
+ !zfs_prop_userquota(propname) && !zfs_prop_written(propname)))) {
zfs_error_aux(hdl, dgettext(TEXT_DOMAIN,
"invalid property '%s'"), propname);
return (zfs_error(hdl, EZFS_BADPROP,
@@ -1338,7 +1342,8 @@ addlist(libzfs_handle_t *hdl, char *propname, zprop_list_t **listp,
entry->pl_prop = prop;
if (prop == ZPROP_INVAL) {
- if ((entry->pl_user_prop = zfs_strdup(hdl, propname)) == NULL) {
+ if ((entry->pl_user_prop = zfs_strdup(hdl, propname)) ==
+ NULL) {
free(entry);
return (-1);
}
diff --git a/usr/src/lib/libzfs/common/llib-lzfs b/usr/src/lib/libzfs/common/llib-lzfs
index 25c49f099b..bd026bcbbb 100644
--- a/usr/src/lib/libzfs/common/llib-lzfs
+++ b/usr/src/lib/libzfs/common/llib-lzfs
@@ -24,10 +24,16 @@
* Use is subject to license terms.
*/
+ /*
+ * Copyright (c) 2012 by Delphix. All rights reserved.
+ */
+
/*LINTLIBRARY*/
/*PROTOLIB1*/
#include <libzfs.h>
+#include <libzfs_core.h>
#include "../../../common/zfs/zfs_comutil.h"
#include "../../../common/zfs/zfs_fletcher.h"
#include "../../../common/zfs/zfs_prop.h"
+#include "../../../common/zfs/zfeature_common.h"
diff --git a/usr/src/lib/libzfs/common/mapfile-vers b/usr/src/lib/libzfs/common/mapfile-vers
index b6145a09d0..cff2c0dc9a 100644
--- a/usr/src/lib/libzfs/common/mapfile-vers
+++ b/usr/src/lib/libzfs/common/mapfile-vers
@@ -61,6 +61,7 @@ SYMBOL_VERSION SUNWprivate_1.1 {
libzfs_mnttab_cache;
libzfs_print_on_error;
libzfs_set_cachedprops;
+ spa_feature_table;
zfs_allocatable_devs;
zfs_asprintf;
zfs_clone;
@@ -77,7 +78,6 @@ SYMBOL_VERSION SUNWprivate_1.1 {
zfs_get_holds;
zfs_get_name;
zfs_get_pool_handle;
- zfs_get_snapused_int;
zfs_get_user_props;
zfs_get_type;
zfs_handle_dup;
@@ -135,6 +135,7 @@ SYMBOL_VERSION SUNWprivate_1.1 {
zfs_release;
zfs_rename;
zfs_rollback;
+ zfs_save_arguments;
zfs_send;
zfs_share;
zfs_shareall;
@@ -146,6 +147,7 @@ SYMBOL_VERSION SUNWprivate_1.1 {
zfs_smb_acl_remove;
zfs_smb_acl_rename;
zfs_snapshot;
+ zfs_snapshot_nvl;
zfs_spa_version;
zfs_spa_version_map;
zfs_type_to_name;
@@ -183,6 +185,7 @@ SYMBOL_VERSION SUNWprivate_1.1 {
zpool_fru_set;
zpool_get_config;
zpool_get_errlog;
+ zpool_get_features;
zpool_get_handle;
zpool_get_history;
zpool_get_name;
@@ -199,15 +202,20 @@ SYMBOL_VERSION SUNWprivate_1.1 {
zpool_is_bootable;
zpool_iter;
zpool_label_disk;
+ zpool_log_history;
zpool_mount_datasets;
zpool_name_to_prop;
zpool_obj_to_path;
zpool_open;
zpool_open_canfail;
+ zpool_print_unsup_feat;
zpool_prop_align_right;
zpool_prop_column_name;
+ zpool_prop_feature;
+ zpool_prop_get_feature;
zpool_prop_readonly;
zpool_prop_to_name;
+ zpool_prop_unsupported;
zpool_prop_values;
zpool_read_label;
zpool_refresh_stats;
@@ -215,9 +223,7 @@ SYMBOL_VERSION SUNWprivate_1.1 {
zpool_reopen;
zpool_scan;
zpool_search_import;
- zpool_set_history_str;
zpool_set_prop;
- zpool_stage_history;
zpool_state_to_name;
zpool_unmount_datasets;
zpool_upgrade;
diff --git a/usr/src/lib/libldap4/Makefile b/usr/src/lib/libzfs_core/Makefile
index b666813ce9..f0711971e5 100644
--- a/usr/src/lib/libldap4/Makefile
+++ b/usr/src/lib/libzfs_core/Makefile
@@ -19,39 +19,46 @@
# CDDL HEADER END
#
#
-# Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+# Copyright 2007 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
-# ident "%Z%%M% %I% %E% SMI"
+# Copyright (c) 2012 by Delphix. All rights reserved.
#
-include ../Makefile.lib
+include ../Makefile.lib
-SUBDIRS = $(MACH)
+HDRS= libzfs_core.h
+
+HDRDIR= common
+
+SUBDIRS= $(MACH)
$(BUILD64)SUBDIRS += $(MACH64)
all := TARGET= all
clean := TARGET= clean
clobber := TARGET= clobber
-delete := TARGET= delete
install := TARGET= install
lint := TARGET= lint
-catalog := TARGET= catalog
-package := TARGET= package
+
+MSGFILES = `$(GREP) -l gettext $(HDRDIR)/*.[ch]`
+POFILE = libzfs_core.po
.KEEP_STATE:
-all clean clobber delete install lint catalog package: $(SUBDIRS)
+all clean clobber install lint: $(SUBDIRS)
-# install rule for install_h target
-$(ROOTHDRDIR)/%: %
- $(INS.file)
+$(POFILE): pofile_MSGFILES
install_h: $(ROOTHDRS)
check: $(CHECKHDRS)
-$(SUBDIRS): FRC
+_msg: $(MSGDOMAINPOFILE)
+
+$(SUBDIRS): FRC
@cd $@; pwd; $(MAKE) $(TARGET)
FRC:
+
+include ../Makefile.targ
+include ../../Makefile.msg.targ
diff --git a/usr/src/lib/libzfs_core/Makefile.com b/usr/src/lib/libzfs_core/Makefile.com
new file mode 100644
index 0000000000..1a48353cef
--- /dev/null
+++ b/usr/src/lib/libzfs_core/Makefile.com
@@ -0,0 +1,69 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (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) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2012 by Delphix. All rights reserved.
+#
+
+LIBRARY= libzfs_core.a
+VERS= .1
+
+OBJS_SHARED=
+
+OBJS_COMMON= \
+ libzfs_core.o
+
+OBJECTS= $(OBJS_COMMON) $(OBJS_SHARED)
+
+include ../../Makefile.lib
+
+# libzfs_core must be installed in the root filesystem for mount(1M)
+include ../../Makefile.rootfs
+
+LIBS= $(DYNLIB) $(LINTLIB)
+
+SRCDIR = ../common
+
+INCS += -I$(SRCDIR)
+INCS += -I../../../uts/common/fs/zfs
+INCS += -I../../../common/zfs
+INCS += -I../../libc/inc
+
+C99MODE= -xc99=%all
+C99LMODE= -Xc99=%all
+LDLIBS += -lc -lnvpair
+CPPFLAGS += $(INCS) -D_LARGEFILE64_SOURCE=1 -D_REENTRANT
+
+SRCS= $(OBJS_COMMON:%.o=$(SRCDIR)/%.c) \
+ $(OBJS_SHARED:%.o=$(SRC)/common/zfs/%.c)
+$(LINTLIB) := SRCS= $(SRCDIR)/$(LINTSRC)
+
+.KEEP_STATE:
+
+all: $(LIBS)
+
+lint: lintcheck
+
+pics/%.o: ../../../common/zfs/%.c
+ $(COMPILE.c) -o $@ $<
+ $(POST_PROCESS_O)
+
+include ../../Makefile.targ
diff --git a/usr/src/lib/libldap4/amd64/Makefile b/usr/src/lib/libzfs_core/amd64/Makefile
index 4e772d362a..b780a6dba8 100644
--- a/usr/src/lib/libldap4/amd64/Makefile
+++ b/usr/src/lib/libzfs_core/amd64/Makefile
@@ -2,8 +2,9 @@
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
-# Common Development and Distribution License (the "License").
-# You may not use this file except in compliance with the License.
+# 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.
@@ -19,19 +20,11 @@
# CDDL HEADER END
#
#
-# Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+# Copyright 2005 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
-# ident "%Z%%M% %I% %E% SMI"
-#
include ../Makefile.com
include ../../Makefile.lib.64
-LIBS = $(DYNLIB)
-
-.KEEP_STATE:
-
-all: $(LIBS)
-
-install: all $(ROOTLIBS64)
+install: all $(ROOTLIBS64) $(ROOTLINKS64)
diff --git a/usr/src/lib/libzfs_core/common/libzfs_core.c b/usr/src/lib/libzfs_core/common/libzfs_core.c
new file mode 100644
index 0000000000..73afd50b8d
--- /dev/null
+++ b/usr/src/lib/libzfs_core/common/libzfs_core.c
@@ -0,0 +1,477 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (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) 2012 by Delphix. All rights reserved.
+ */
+
+/*
+ * LibZFS_Core (lzc) is intended to replace most functionality in libzfs.
+ * It has the following characteristics:
+ *
+ * - Thread Safe. libzfs_core is accessible concurrently from multiple
+ * threads. This is accomplished primarily by avoiding global data
+ * (e.g. caching). Since it's thread-safe, there is no reason for a
+ * process to have multiple libzfs "instances". Therefore, we store
+ * our few pieces of data (e.g. the file descriptor) in global
+ * variables. The fd is reference-counted so that the libzfs_core
+ * library can be "initialized" multiple times (e.g. by different
+ * consumers within the same process).
+ *
+ * - Committed Interface. The libzfs_core interface will be committed,
+ * therefore consumers can compile against it and be confident that
+ * their code will continue to work on future releases of this code.
+ * Currently, the interface is Evolving (not Committed), but we intend
+ * to commit to it once it is more complete and we determine that it
+ * meets the needs of all consumers.
+ *
+ * - Programatic Error Handling. libzfs_core communicates errors with
+ * defined error numbers, and doesn't print anything to stdout/stderr.
+ *
+ * - Thin Layer. libzfs_core is a thin layer, marshaling arguments
+ * to/from the kernel ioctls. There is generally a 1:1 correspondence
+ * between libzfs_core functions and ioctls to /dev/zfs.
+ *
+ * - Clear Atomicity. Because libzfs_core functions are generally 1:1
+ * with kernel ioctls, and kernel ioctls are general atomic, each
+ * libzfs_core function is atomic. For example, creating multiple
+ * snapshots with a single call to lzc_snapshot() is atomic -- it
+ * can't fail with only some of the requested snapshots created, even
+ * in the event of power loss or system crash.
+ *
+ * - Continued libzfs Support. Some higher-level operations (e.g.
+ * support for "zfs send -R") are too complicated to fit the scope of
+ * libzfs_core. This functionality will continue to live in libzfs.
+ * Where appropriate, libzfs will use the underlying atomic operations
+ * of libzfs_core. For example, libzfs may implement "zfs send -R |
+ * zfs receive" by using individual "send one snapshot", rename,
+ * destroy, and "receive one snapshot" operations in libzfs_core.
+ * /sbin/zfs and /zbin/zpool will link with both libzfs and
+ * libzfs_core. Other consumers should aim to use only libzfs_core,
+ * since that will be the supported, stable interface going forwards.
+ */
+
+#include <libzfs_core.h>
+#include <ctype.h>
+#include <unistd.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
+#include <fcntl.h>
+#include <pthread.h>
+#include <sys/nvpair.h>
+#include <sys/param.h>
+#include <sys/types.h>
+#include <sys/stat.h>
+#include <sys/zfs_ioctl.h>
+
+static int g_fd;
+static pthread_mutex_t g_lock = PTHREAD_MUTEX_INITIALIZER;
+static int g_refcount;
+
+int
+libzfs_core_init(void)
+{
+ (void) pthread_mutex_lock(&g_lock);
+ if (g_refcount == 0) {
+ g_fd = open("/dev/zfs", O_RDWR);
+ if (g_fd < 0) {
+ (void) pthread_mutex_unlock(&g_lock);
+ return (errno);
+ }
+ }
+ g_refcount++;
+ (void) pthread_mutex_unlock(&g_lock);
+ return (0);
+}
+
+void
+libzfs_core_fini(void)
+{
+ (void) pthread_mutex_lock(&g_lock);
+ ASSERT3S(g_refcount, >, 0);
+ g_refcount--;
+ if (g_refcount == 0)
+ (void) close(g_fd);
+ (void) pthread_mutex_unlock(&g_lock);
+}
+
+static int
+lzc_ioctl(zfs_ioc_t ioc, const char *name,
+ nvlist_t *source, nvlist_t **resultp)
+{
+ zfs_cmd_t zc = { 0 };
+ int error = 0;
+ char *packed;
+ size_t size;
+
+ ASSERT3S(g_refcount, >, 0);
+
+ (void) strlcpy(zc.zc_name, name, sizeof (zc.zc_name));
+
+ packed = fnvlist_pack(source, &size);
+ zc.zc_nvlist_src = (uint64_t)(uintptr_t)packed;
+ zc.zc_nvlist_src_size = size;
+
+ if (resultp != NULL) {
+ zc.zc_nvlist_dst_size = MAX(size * 2, 128 * 1024);
+ zc.zc_nvlist_dst = (uint64_t)(uintptr_t)
+ malloc(zc.zc_nvlist_dst_size);
+ if (zc.zc_nvlist_dst == NULL) {
+ error = ENOMEM;
+ goto out;
+ }
+ }
+
+ while (ioctl(g_fd, ioc, &zc) != 0) {
+ if (errno == ENOMEM && resultp != NULL) {
+ free((void *)(uintptr_t)zc.zc_nvlist_dst);
+ zc.zc_nvlist_dst_size *= 2;
+ zc.zc_nvlist_dst = (uint64_t)(uintptr_t)
+ malloc(zc.zc_nvlist_dst_size);
+ if (zc.zc_nvlist_dst == NULL) {
+ error = ENOMEM;
+ goto out;
+ }
+ } else {
+ error = errno;
+ break;
+ }
+ }
+ if (zc.zc_nvlist_dst_filled) {
+ *resultp = fnvlist_unpack((void *)(uintptr_t)zc.zc_nvlist_dst,
+ zc.zc_nvlist_dst_size);
+ } else if (resultp != NULL) {
+ *resultp = NULL;
+ }
+
+out:
+ fnvlist_pack_free(packed, size);
+ free((void *)(uintptr_t)zc.zc_nvlist_dst);
+ return (error);
+}
+
+int
+lzc_create(const char *fsname, dmu_objset_type_t type, nvlist_t *props)
+{
+ int error;
+ nvlist_t *args = fnvlist_alloc();
+ fnvlist_add_int32(args, "type", type);
+ if (props != NULL)
+ fnvlist_add_nvlist(args, "props", props);
+ error = lzc_ioctl(ZFS_IOC_CREATE, fsname, args, NULL);
+ nvlist_free(args);
+ return (error);
+}
+
+int
+lzc_clone(const char *fsname, const char *origin,
+ nvlist_t *props)
+{
+ int error;
+ nvlist_t *args = fnvlist_alloc();
+ fnvlist_add_string(args, "origin", origin);
+ if (props != NULL)
+ fnvlist_add_nvlist(args, "props", props);
+ error = lzc_ioctl(ZFS_IOC_CLONE, fsname, args, NULL);
+ nvlist_free(args);
+ return (error);
+}
+
+/*
+ * Creates snapshots.
+ *
+ * The keys in the snaps nvlist are the snapshots to be created.
+ * They must all be in the same pool.
+ *
+ * The props nvlist is properties to set. Currently only user properties
+ * are supported. { user:prop_name -> string value }
+ *
+ * The returned results nvlist will have an entry for each snapshot that failed.
+ * The value will be the (int32) error code.
+ *
+ * The return value will be 0 if all snapshots were created, otherwise it will
+ * be the errno of a (undetermined) snapshot that failed.
+ */
+int
+lzc_snapshot(nvlist_t *snaps, nvlist_t *props, nvlist_t **errlist)
+{
+ nvpair_t *elem;
+ nvlist_t *args;
+ int error;
+ char pool[MAXNAMELEN];
+
+ *errlist = NULL;
+
+ /* determine the pool name */
+ elem = nvlist_next_nvpair(snaps, NULL);
+ if (elem == NULL)
+ return (0);
+ (void) strlcpy(pool, nvpair_name(elem), sizeof (pool));
+ pool[strcspn(pool, "/@")] = '\0';
+
+ args = fnvlist_alloc();
+ fnvlist_add_nvlist(args, "snaps", snaps);
+ if (props != NULL)
+ fnvlist_add_nvlist(args, "props", props);
+
+ error = lzc_ioctl(ZFS_IOC_SNAPSHOT, pool, args, errlist);
+ nvlist_free(args);
+
+ return (error);
+}
+
+/*
+ * Destroys snapshots.
+ *
+ * The keys in the snaps nvlist are the snapshots to be destroyed.
+ * They must all be in the same pool.
+ *
+ * Snapshots that do not exist will be silently ignored.
+ *
+ * If 'defer' is not set, and a snapshot has user holds or clones, the
+ * destroy operation will fail and none of the snapshots will be
+ * destroyed.
+ *
+ * If 'defer' is set, and a snapshot has user holds or clones, it will be
+ * marked for deferred destruction, and will be destroyed when the last hold
+ * or clone is removed/destroyed.
+ *
+ * The return value will be 0 if all snapshots were destroyed (or marked for
+ * later destruction if 'defer' is set) or didn't exist to begin with.
+ *
+ * Otherwise the return value will be the errno of a (undetermined) snapshot
+ * that failed, no snapshots will be destroyed, and the errlist will have an
+ * entry for each snapshot that failed. The value in the errlist will be
+ * the (int32) error code.
+ */
+int
+lzc_destroy_snaps(nvlist_t *snaps, boolean_t defer, nvlist_t **errlist)
+{
+ nvpair_t *elem;
+ nvlist_t *args;
+ int error;
+ char pool[MAXNAMELEN];
+
+ /* determine the pool name */
+ elem = nvlist_next_nvpair(snaps, NULL);
+ if (elem == NULL)
+ return (0);
+ (void) strlcpy(pool, nvpair_name(elem), sizeof (pool));
+ pool[strcspn(pool, "/@")] = '\0';
+
+ args = fnvlist_alloc();
+ fnvlist_add_nvlist(args, "snaps", snaps);
+ if (defer)
+ fnvlist_add_boolean(args, "defer");
+
+ error = lzc_ioctl(ZFS_IOC_DESTROY_SNAPS, pool, args, errlist);
+ nvlist_free(args);
+
+ return (error);
+
+}
+
+int
+lzc_snaprange_space(const char *firstsnap, const char *lastsnap,
+ uint64_t *usedp)
+{
+ nvlist_t *args;
+ nvlist_t *result;
+ int err;
+ char fs[MAXNAMELEN];
+ char *atp;
+
+ /* determine the fs name */
+ (void) strlcpy(fs, firstsnap, sizeof (fs));
+ atp = strchr(fs, '@');
+ if (atp == NULL)
+ return (EINVAL);
+ *atp = '\0';
+
+ args = fnvlist_alloc();
+ fnvlist_add_string(args, "firstsnap", firstsnap);
+
+ err = lzc_ioctl(ZFS_IOC_SPACE_SNAPS, lastsnap, args, &result);
+ nvlist_free(args);
+ if (err == 0)
+ *usedp = fnvlist_lookup_uint64(result, "used");
+ fnvlist_free(result);
+
+ return (err);
+}
+
+boolean_t
+lzc_exists(const char *dataset)
+{
+ /*
+ * The objset_stats ioctl is still legacy, so we need to construct our
+ * own zfs_cmd_t rather than using zfsc_ioctl().
+ */
+ zfs_cmd_t zc = { 0 };
+
+ (void) strlcpy(zc.zc_name, dataset, sizeof (zc.zc_name));
+ return (ioctl(g_fd, ZFS_IOC_OBJSET_STATS, &zc) == 0);
+}
+
+/*
+ * If fromsnap is NULL, a full (non-incremental) stream will be sent.
+ */
+int
+lzc_send(const char *snapname, const char *fromsnap, int fd)
+{
+ nvlist_t *args;
+ int err;
+
+ args = fnvlist_alloc();
+ fnvlist_add_int32(args, "fd", fd);
+ if (fromsnap != NULL)
+ fnvlist_add_string(args, "fromsnap", fromsnap);
+ err = lzc_ioctl(ZFS_IOC_SEND_NEW, snapname, args, NULL);
+ nvlist_free(args);
+ return (err);
+}
+
+/*
+ * If fromsnap is NULL, a full (non-incremental) stream will be estimated.
+ */
+int
+lzc_send_space(const char *snapname, const char *fromsnap, uint64_t *spacep)
+{
+ nvlist_t *args;
+ nvlist_t *result;
+ int err;
+
+ args = fnvlist_alloc();
+ if (fromsnap != NULL)
+ fnvlist_add_string(args, "fromsnap", fromsnap);
+ err = lzc_ioctl(ZFS_IOC_SEND_SPACE, snapname, args, &result);
+ nvlist_free(args);
+ if (err == 0)
+ *spacep = fnvlist_lookup_uint64(result, "space");
+ nvlist_free(result);
+ return (err);
+}
+
+static int
+recv_read(int fd, void *buf, int ilen)
+{
+ char *cp = buf;
+ int rv;
+ int len = ilen;
+
+ do {
+ rv = read(fd, cp, len);
+ cp += rv;
+ len -= rv;
+ } while (rv > 0);
+
+ if (rv < 0 || len != 0)
+ return (EIO);
+
+ return (0);
+}
+
+/*
+ * The simplest receive case: receive from the specified fd, creating the
+ * specified snapshot. Apply the specified properties a "received" properties
+ * (which can be overridden by locally-set properties). If the stream is a
+ * clone, its origin snapshot must be specified by 'origin'. The 'force'
+ * flag will cause the target filesystem to be rolled back or destroyed if
+ * necessary to receive.
+ *
+ * Return 0 on success or an errno on failure.
+ *
+ * Note: this interface does not work on dedup'd streams
+ * (those with DMU_BACKUP_FEATURE_DEDUP).
+ */
+int
+lzc_receive(const char *snapname, nvlist_t *props, const char *origin,
+ boolean_t force, int fd)
+{
+ /*
+ * The receive ioctl is still legacy, so we need to construct our own
+ * zfs_cmd_t rather than using zfsc_ioctl().
+ */
+ zfs_cmd_t zc = { 0 };
+ char *atp;
+ char *packed = NULL;
+ size_t size;
+ dmu_replay_record_t drr;
+ int error;
+
+ ASSERT3S(g_refcount, >, 0);
+
+ /* zc_name is name of containing filesystem */
+ (void) strlcpy(zc.zc_name, snapname, sizeof (zc.zc_name));
+ atp = strchr(zc.zc_name, '@');
+ if (atp == NULL)
+ return (EINVAL);
+ *atp = '\0';
+
+ /* if the fs does not exist, try its parent. */
+ if (!lzc_exists(zc.zc_name)) {
+ char *slashp = strrchr(zc.zc_name, '/');
+ if (slashp == NULL)
+ return (ENOENT);
+ *slashp = '\0';
+
+ }
+
+ /* zc_value is full name of the snapshot to create */
+ (void) strlcpy(zc.zc_value, snapname, sizeof (zc.zc_value));
+
+ if (props != NULL) {
+ /* zc_nvlist_src is props to set */
+ packed = fnvlist_pack(props, &size);
+ zc.zc_nvlist_src = (uint64_t)(uintptr_t)packed;
+ zc.zc_nvlist_src_size = size;
+ }
+
+ /* zc_string is name of clone origin (if DRR_FLAG_CLONE) */
+ if (origin != NULL)
+ (void) strlcpy(zc.zc_string, origin, sizeof (zc.zc_string));
+
+ /* zc_begin_record is non-byteswapped BEGIN record */
+ error = recv_read(fd, &drr, sizeof (drr));
+ if (error != 0)
+ goto out;
+ zc.zc_begin_record = drr.drr_u.drr_begin;
+
+ /* zc_cookie is fd to read from */
+ zc.zc_cookie = fd;
+
+ /* zc guid is force flag */
+ zc.zc_guid = force;
+
+ /* zc_cleanup_fd is unused */
+ zc.zc_cleanup_fd = -1;
+
+ error = ioctl(g_fd, ZFS_IOC_RECV, &zc);
+ if (error != 0)
+ error = errno;
+
+out:
+ if (packed != NULL)
+ fnvlist_pack_free(packed, size);
+ free((void*)(uintptr_t)zc.zc_nvlist_dst);
+ return (error);
+}
diff --git a/usr/src/lib/libzfs_core/common/libzfs_core.h b/usr/src/lib/libzfs_core/common/libzfs_core.h
new file mode 100644
index 0000000000..9edc884a14
--- /dev/null
+++ b/usr/src/lib/libzfs_core/common/libzfs_core.h
@@ -0,0 +1,62 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (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) 2012 by Delphix. All rights reserved.
+ */
+
+#ifndef _LIBZFS_CORE_H
+#define _LIBZFS_CORE_H
+
+#include <libnvpair.h>
+#include <sys/param.h>
+#include <sys/types.h>
+#include <sys/fs/zfs.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+int libzfs_core_init(void);
+void libzfs_core_fini(void);
+
+int lzc_snapshot(nvlist_t *snaps, nvlist_t *props, nvlist_t **errlist);
+int lzc_create(const char *fsname, dmu_objset_type_t type, nvlist_t *props);
+int lzc_clone(const char *fsname, const char *origin, nvlist_t *props);
+int lzc_destroy_snaps(nvlist_t *snaps, boolean_t defer, nvlist_t **errlist);
+
+int lzc_snaprange_space(const char *firstsnap, const char *lastsnap,
+ uint64_t *usedp);
+
+int lzc_send(const char *snapname, const char *fromsnap, int fd);
+int lzc_receive(const char *snapname, nvlist_t *props, const char *origin,
+ boolean_t force, int fd);
+int lzc_send_space(const char *snapname, const char *fromsnap,
+ uint64_t *result);
+
+boolean_t lzc_exists(const char *dataset);
+
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _LIBZFS_CORE_H */
diff --git a/usr/src/cmd/dtrace/test/tst/common/print/err.D_PRINT_DYN.bad.d b/usr/src/lib/libzfs_core/common/llib-lzfs_core
index 892b445613..55f5d4e5e6 100644
--- a/usr/src/cmd/dtrace/test/tst/common/print/err.D_PRINT_DYN.bad.d
+++ b/usr/src/lib/libzfs_core/common/llib-lzfs_core
@@ -18,12 +18,11 @@
*
* CDDL HEADER END
*/
-
/*
- * Copyright (c) 2011 by Delphix. All rights reserved.
+ * Copyright (c) 2012 by Delphix. All rights reserved.
*/
-BEGIN
-{
- print(*curpsinfo);
-}
+/*LINTLIBRARY*/
+/*PROTOLIB1*/
+
+#include <libzfs_core.h>
diff --git a/usr/src/lib/libzfs_core/common/mapfile-vers b/usr/src/lib/libzfs_core/common/mapfile-vers
new file mode 100644
index 0000000000..612688334f
--- /dev/null
+++ b/usr/src/lib/libzfs_core/common/mapfile-vers
@@ -0,0 +1,56 @@
+#
+# CDDL HEADER START
+#
+# The contents of this file are subject to the terms of the
+# Common Development and Distribution License (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) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2012 by Delphix. All rights reserved.
+#
+# MAPFILE HEADER START
+#
+# WARNING: STOP NOW. DO NOT MODIFY THIS FILE.
+# Object versioning must comply with the rules detailed in
+#
+# usr/src/lib/README.mapfiles
+#
+# You should not be making modifications here until you've read the most current
+# copy of that file. If you need help, contact a gatekeeper for guidance.
+#
+# MAPFILE HEADER END
+#
+
+$mapfile_version 2
+
+SYMBOL_VERSION ILLUMOS_0.1 {
+ global:
+
+ libzfs_core_fini;
+ libzfs_core_init;
+ lzc_clone;
+ lzc_create;
+ lzc_destroy_snaps;
+ lzc_exists;
+ lzc_receive;
+ lzc_send;
+ lzc_send_space;
+ lzc_snaprange_space;
+ lzc_snapshot;
+
+ local:
+ *;
+};
diff --git a/usr/src/lib/libldap4/i386/Makefile b/usr/src/lib/libzfs_core/i386/Makefile
index 7cf5507978..4088a1eac0 100644
--- a/usr/src/lib/libldap4/i386/Makefile
+++ b/usr/src/lib/libzfs_core/i386/Makefile
@@ -2,8 +2,9 @@
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
-# Common Development and Distribution License (the "License").
-# You may not use this file except in compliance with the License.
+# 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.
@@ -19,16 +20,10 @@
# CDDL HEADER END
#
#
-# Copyright 2006 Sun Microsystems, Inc. All rights reserved.
+# Copyright 2005 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
-# ident "%Z%%M% %I% %E% SMI"
-#
include ../Makefile.com
-.KEEP_STATE:
-
-all: $(LIBS)
-
-install: all $(ROOTLIBS)
+install: all $(ROOTLIBS) $(ROOTLINKS) $(ROOTLINT)
diff --git a/usr/src/lib/libzfs_core/sparc/Makefile b/usr/src/lib/libzfs_core/sparc/Makefile
new file mode 100644
index 0000000000..4088a1eac0
--- /dev/null
+++ b/usr/src/lib/libzfs_core/sparc/Makefile
@@ -0,0 +1,29 @@
+#
+# 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 2005 Sun Microsystems, Inc. All rights reserved.
+# Use is subject to license terms.
+#
+
+include ../Makefile.com
+
+install: all $(ROOTLIBS) $(ROOTLINKS) $(ROOTLINT)
diff --git a/usr/src/lib/libldap4/sparcv9/Makefile b/usr/src/lib/libzfs_core/sparcv9/Makefile
index 4e772d362a..c5b6ca49b4 100644
--- a/usr/src/lib/libldap4/sparcv9/Makefile
+++ b/usr/src/lib/libzfs_core/sparcv9/Makefile
@@ -2,8 +2,9 @@
# CDDL HEADER START
#
# The contents of this file are subject to the terms of the
-# Common Development and Distribution License (the "License").
-# You may not use this file except in compliance with the License.
+# 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.
@@ -22,16 +23,10 @@
# Copyright 2006 Sun Microsystems, Inc. All rights reserved.
# Use is subject to license terms.
#
-# ident "%Z%%M% %I% %E% SMI"
-#
include ../Makefile.com
include ../../Makefile.lib.64
-LIBS = $(DYNLIB)
-
-.KEEP_STATE:
-
-all: $(LIBS)
+sparcv9_C_PICFLAGS= -K PIC
-install: all $(ROOTLIBS64)
+install: all $(ROOTLIBS64) $(ROOTLINKS64)
diff --git a/usr/src/lib/libzpool/common/kernel.c b/usr/src/lib/libzpool/common/kernel.c
index f323bf60b0..04d530727f 100644
--- a/usr/src/lib/libzpool/common/kernel.c
+++ b/usr/src/lib/libzpool/common/kernel.c
@@ -20,6 +20,7 @@
*/
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012 by Delphix. All rights reserved.
*/
#include <assert.h>
@@ -45,6 +46,7 @@ int aok;
uint64_t physmem;
vnode_t *rootdir = (vnode_t *)0xabcd1234;
char hw_serial[HW_HOSTID_LEN];
+vmem_t *zio_arena = NULL;
struct utsname utsname = {
"userland", "libzpool", "1", "1", "na"
@@ -424,7 +426,9 @@ vn_rdwr(int uio, vnode_t *vp, void *addr, ssize_t len, offset_t offset,
* To simulate partial disk writes, we split writes into two
* system calls so that the process can be killed in between.
*/
- split = (len > 0 ? rand() % len : 0);
+ int sectors = len >> SPA_MINBLOCKSHIFT;
+ split = (sectors > 0 ? rand() % sectors : 0) <<
+ SPA_MINBLOCKSHIFT;
iolen = pwrite64(vp->v_fd, addr, split, offset);
iolen += pwrite64(vp->v_fd, (char *)addr + split,
len - split, offset + split);
@@ -867,6 +871,12 @@ crgetuid(cred_t *cr)
return (0);
}
+uid_t
+crgetruid(cred_t *cr)
+{
+ return (0);
+}
+
gid_t
crgetgid(cred_t *cr)
{
diff --git a/usr/src/lib/libzpool/common/llib-lzpool b/usr/src/lib/libzpool/common/llib-lzpool
index 77afe8bf13..934a7409b7 100644
--- a/usr/src/lib/libzpool/common/llib-lzpool
+++ b/usr/src/lib/libzpool/common/llib-lzpool
@@ -23,6 +23,10 @@
* Use is subject to license terms.
*/
+/*
+ * Copyright (c) 2012 by Delphix. All rights reserved.
+ */
+
/* LINTLIBRARY */
/* PROTOLIB1 */
@@ -52,6 +56,8 @@
#include <sys/ddt.h>
#include <sys/sa.h>
#include <sys/zfs_sa.h>
+#include <sys/zfeature.h>
extern uint64_t metaslab_gang_bang;
extern uint64_t metaslab_df_alloc_threshold;
+extern boolean_t zfeature_checks_disable;
diff --git a/usr/src/lib/libzpool/common/sys/zfs_context.h b/usr/src/lib/libzpool/common/sys/zfs_context.h
index c4d3c98e4b..39af927f71 100644
--- a/usr/src/lib/libzpool/common/sys/zfs_context.h
+++ b/usr/src/lib/libzpool/common/sys/zfs_context.h
@@ -20,9 +20,9 @@
*/
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
- */
-/*
* Copyright 2011 Nexenta Systems, Inc. All rights reserved.
+ * Copyright (c) 2012 by Delphix. All rights reserved.
+ * Copyright (c) 2012, Joyent, Inc. All rights reserved.
*/
#ifndef _SYS_ZFS_CONTEXT_H
@@ -215,6 +215,7 @@ struct proc {
};
extern struct proc p0;
+#define curproc (&p0)
#define PS_NONE -1
@@ -285,6 +286,7 @@ extern void rw_exit(krwlock_t *rwlp);
#define rw_downgrade(rwlp) do { } while (0)
extern uid_t crgetuid(cred_t *cr);
+extern uid_t crgetruid(cred_t *cr);
extern gid_t crgetgid(cred_t *cr);
extern int crgetngroups(cred_t *cr);
extern gid_t *crgetgroups(cred_t *cr);
@@ -330,9 +332,12 @@ extern void kstat_delete(kstat_t *);
#define kmem_debugging() 0
#define kmem_cache_reap_now(_c) /* nothing */
#define kmem_cache_set_move(_c, _cb) /* nothing */
+#define vmem_qcache_reap(_v) /* nothing */
#define POINTER_INVALIDATE(_pp) /* nothing */
#define POINTER_IS_VALID(_p) 0
+extern vmem_t *zio_arena;
+
typedef umem_cache_t kmem_cache_t;
typedef enum kmem_cbrc {
diff --git a/usr/src/lib/smbsrv/libmlsvc/Makefile.com b/usr/src/lib/smbsrv/libmlsvc/Makefile.com
index 092d564777..be2472157f 100644
--- a/usr/src/lib/smbsrv/libmlsvc/Makefile.com
+++ b/usr/src/lib/smbsrv/libmlsvc/Makefile.com
@@ -19,7 +19,7 @@
# CDDL HEADER END
#
#
-# Copyright 2011 Nexenta Systems, Inc. All rights reserved.
+# Copyright 2012 Nexenta Systems, Inc. All rights reserved.
# Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
#
@@ -87,6 +87,7 @@ LDLIBS += -lmlrpc -lsmb -lsmbns -lshare -lsmbfs -lresolv -lnsl -lpkcs11 \
-lscf -lcmdutils -lsec -lavl -lnvpair -luutil -luuid -lgen -lzfs -lc
CPPFLAGS += $(INCS) -D_REENTRANT
+$(ENABLE_SMB_PRINTING) CPPFLAGS += -DHAVE_CUPS
SRCS= $(OBJS_COMMON:%.o=$(SRCDIR)/%.c)
diff --git a/usr/src/lib/smbsrv/libmlsvc/common/spoolss_svc.c b/usr/src/lib/smbsrv/libmlsvc/common/spoolss_svc.c
index d0fc9aa4ab..5accb7cc75 100644
--- a/usr/src/lib/smbsrv/libmlsvc/common/spoolss_svc.c
+++ b/usr/src/lib/smbsrv/libmlsvc/common/spoolss_svc.c
@@ -20,6 +20,7 @@
*/
/*
* Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright 2012 Nexenta Systems, Inc. All rights reserved.
*/
/*
@@ -44,6 +45,8 @@
#include <smbsrv/nmpipes.h>
#include <mlsvc.h>
+#ifdef HAVE_CUPS
+
#define SPOOLSS_PRINTER "Postscript"
typedef struct smb_spool {
@@ -1194,3 +1197,27 @@ fixup_spoolss_GetPrinter(struct spoolss_GetPrinter *val)
FIXUP_PDU_SIZE(spoolss_GetPrinter_result, size2);
FIXUP_PDU_SIZE(spoolss_GetPrinter, size3);
}
+
+#else /* HAVE_CUPS */
+
+/*
+ * If not HAVE_CUPS, just provide a few "stubs".
+ */
+
+void
+spoolss_initialize(void)
+{
+}
+
+void
+spoolss_finalize(void)
+{
+}
+
+/*ARGSUSED*/
+void
+spoolss_register_copyfile(spoolss_copyfile_t copyfile)
+{
+}
+
+#endif /* HAVE_CUPS */
diff --git a/usr/src/lib/sun_fc/Makefile.com b/usr/src/lib/sun_fc/Makefile.com
index 205fe56f71..906c82a1ba 100644
--- a/usr/src/lib/sun_fc/Makefile.com
+++ b/usr/src/lib/sun_fc/Makefile.com
@@ -137,12 +137,12 @@ CCFLAGS64 += -D_POSIX_PTHREAD_SEMANTICS
CCFLAGS64 += -compat=5
CPPFLAGS += $(INCS) -DBUILD_TIME='"Wed Sep 24 12:00:00 2008"'
-LDLIBS += -ldevinfo
-LDLIBS += -lsysevent
-LDLIBS += -lnvpair
-$(__SUNC)CCNEEDED = -lCstd -lCrun
-LDLIBS += $(CCNEEDED)
-LDLIBS += -lc
+LDLIBS += -ldevinfo
+LDLIBS += -lsysevent
+LDLIBS += -lnvpair
+$(__SUNC)CCNEEDED = $(CCEXTNEEDED)
+LDLIBS += $(CCNEEDED)
+LDLIBS += -lc
$(LINTLIB) := SRCS= $(SRCDIR)/$(LINTSRC)
diff --git a/usr/src/lib/sun_fc/amd64/Makefile b/usr/src/lib/sun_fc/amd64/Makefile
index 9cd01791ef..514226db12 100644
--- a/usr/src/lib/sun_fc/amd64/Makefile
+++ b/usr/src/lib/sun_fc/amd64/Makefile
@@ -27,7 +27,7 @@
include ../Makefile.com
include ../../Makefile.lib.64
-$(__SUNC)CCNEEDED = -lCrun -lCstd
+$(__SUNC)CCNEEDED = $(CCEXTNEEDED)
.KEEP_STATE:
diff --git a/usr/src/lib/sun_fc/sparcv9/Makefile b/usr/src/lib/sun_fc/sparcv9/Makefile
index 9cd01791ef..514226db12 100644
--- a/usr/src/lib/sun_fc/sparcv9/Makefile
+++ b/usr/src/lib/sun_fc/sparcv9/Makefile
@@ -27,7 +27,7 @@
include ../Makefile.com
include ../../Makefile.lib.64
-$(__SUNC)CCNEEDED = -lCrun -lCstd
+$(__SUNC)CCNEEDED = $(CCEXTNEEDED)
.KEEP_STATE:
diff --git a/usr/src/man/man1/tar.1 b/usr/src/man/man1/tar.1
index cbf3aebccc..fd21f6c53c 100644
--- a/usr/src/man/man1/tar.1
+++ b/usr/src/man/man1/tar.1
@@ -1,6 +1,7 @@
'\" te
.\" Copyright 1989 AT&T
.\" Copyright (c) 2006, Sun Microsystems, Inc. All Rights Reserved
+.\" Copyright 2012 Milan Jurik. All rights reserved.
.\" Portions Copyright (c) 1992, X/Open Company Limited All Rights Reserved
.\" Sun Microsystems, Inc. gratefully acknowledges The Open Group for permission to reproduce portions of its copyrighted documentation. Original documentation from The Open Group can be obtained online at
.\" http://www.opengroup.org/bookstore/.
@@ -9,39 +10,39 @@
.\" The contents of this file are subject to the terms of the Common Development and Distribution License (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]
-.TH TAR 1 "Oct 26, 2007"
+.TH TAR 1 "May 9, 2012"
.SH NAME
tar \- create tape archives and add or extract files
.SH SYNOPSIS
.LP
.nf
-\fBtar\fR c[BDeEFhilnopPqTvw@/[0-7]][bfk][X...] [\fIblocksize\fR]
+\fBtar\fR c[BDeEFhilnopPqTvw@/[0-7]][bfk][X...][a|j|J|z|Z] [\fIblocksize\fR]
[\fItarfile\fR] [\fIsize\fR] [\fIexclude-file\fR]...
{\fIfile\fR | \(miI \fIinclude-file\fR | \(miC \fIdirectory\fR \fIfile\fR}...
.fi
.LP
.nf
-\fBtar\fR r[BDeEFhilnqTvw@/[0-7]][bfk] [\fIblocksize\fR] [\fItarfile\fR]
+\fBtar\fR r[BDeEFhilnqTvw@/[0-7]][bfk][j|J|z|Z] [\fIblocksize\fR] [\fItarfile\fR]
[\fIsize\fR]
{\fIfile\fR | \(miI \fIinclude-file\fR | \(miC \fIdirectory\fR \fIfile\fR}...
.fi
.LP
.nf
-\fBtar\fR t[BeFhilnqTv[0-7]][fk][X...] [\fItarfile\fR] [\fIsize\fR]
+\fBtar\fR t[BeFhilnqTv[0-7]][fk][X...][j|J|z|Z] [\fItarfile\fR] [\fIsize\fR]
[\fIexclude-file\fR]... {\fIfile\fR | \(miI \fIinclude-file\fR}...
.fi
.LP
.nf
-\fBtar\fR u[BDeEFhilnqTvw@/[0-7]][bfk] [\fIblocksize\fR] [\fItarfile\fR]
+\fBtar\fR u[BDeEFhilnqTvw@/[0-7]][bfk][j|J|z|Z] [\fIblocksize\fR] [\fItarfile\fR]
[\fIsize\fR] \fIfile\fR...
.fi
.LP
.nf
-\fBtar\fR x[BeFhilmnopqTvw@/[0-7]][fk][X...] [\fItarfile\fR] [\fIsize\fR]
+\fBtar\fR x[BeFhilmnopqTvw@/[0-7]][fk][X...][j|J|z|Z] [\fItarfile\fR] [\fIsize\fR]
[\fIexclude-file\fR]... [\fIfile\fR]...
.fi
@@ -241,6 +242,17 @@ the desired function.
.sp
.ne 2
.na
+\fB\fBa\fR\fR
+.ad
+.sp .6
+.RS 4n
+During a \fBcreate\fR operation autodetect compression based on the archive
+suffix.
+.RE
+
+.sp
+.ne 2
+.na
\fB\fBb\fR \fIblocksize\fR\fR
.ad
.sp .6
@@ -397,6 +409,26 @@ Ignore directory checksum errors.
.sp
.ne 2
.na
+\fB\fBj\fR\fR
+.ad
+.sp .6
+.RS 4n
+Use \fBbzip2\fR for compressing or decompressing the archives.
+.RE
+
+.sp
+.ne 2
+.na
+\fB\fBJ\fR\fR
+.ad
+.sp .6
+.RS 4n
+Use \fBxz\fR for compressing or decompressing the archives.
+.RE
+
+.sp
+.ne 2
+.na
\fB\fBk\fR \fIsize\fR\fR
.ad
.sp .6
@@ -589,6 +621,26 @@ included files. If a file is specified in both the \fIexclude-file\fR and the
.sp
.ne 2
.na
+\fB\fBz\fR\fR
+.ad
+.sp .6
+.RS 4n
+Use \fBgzip\fR for compressing or decompressing the archives.
+.RE
+
+.sp
+.ne 2
+.na
+\fB\fBZ\fR\fR
+.ad
+.sp .6
+.RS 4n
+Use \fBcompress\fR for compressing or decompressing the archives.
+.RE
+
+.sp
+.ne 2
+.na
\fB\fB@\fR\fR
.ad
.sp .6
@@ -952,42 +1004,6 @@ tar: tape read error
.SH ENVIRONMENT VARIABLES
.sp
-.ne 2
-.na
-\fB\fBSYSV3\fR\fR
-.ad
-.sp .6
-.RS 4n
-This variable is used to override the default behavior of \fBtar\fR, provide
-compatibility with INTERACTIVE UNIX Systems and SCO UNIX installation scripts,
-and should not be used in new scripts. (It is intended for compatibility
-purposes only.) When set, the following function modifiers behave differently:
-.sp
-.ne 2
-.na
-\fB\fBF\fR \fIfilename\fR\fR
-.ad
-.sp .6
-.RS 4n
-Uses \fIfilename\fR to obtain a list of command line switches and files on
-which to operate.
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fBe\fR\fR
-.ad
-.sp .6
-.RS 4n
-Prevents files from being split across volumes. If there is insufficient room
-on one volume, \fBtar\fR prompts for a new volume. If the file does not fit on
-the new volume, \fBtar\fR exits with an error.
-.RE
-
-.RE
-
-.sp
.LP
See \fBenviron\fR(5) for descriptions of the following environment variables
that affect the execution of \fBtar\fR: \fBLC_COLLATE\fR, \fBLC_CTYPE\fR,
@@ -1160,9 +1176,10 @@ Interface Stability Committed
.SH SEE ALSO
.sp
.LP
-\fBar\fR(1), \fBbasename\fR(1), \fBcd\fR(1), \fBchown\fR(1), \fBcpio\fR(1),
-\fBcsh\fR(1), \fBdirname\fR(1), \fBfind\fR(1), \fBls\fR(1), \fBmt\fR(1),
-\fBpax\fR(1), \fBsetfacl\fR(1), \fBumask\fR(1), \fBmknod\fR(1M),
+\fBar\fR(1), \fBbasename\fR(1), \fBbzip2\fR(1), \fBcd\fR(1), \fBchown\fR(1),
+\fBcompress\fR)(1), \fBcpio\fR(1), \fBcsh\fR(1), \fBdirname\fR(1),
+\fBfind\fR(1), \fBgzip\fR(1), \fBls\fR(1), \fBmt\fR(1), \fBpax\fR(1),
+\fBsetfacl\fR(1), \fBumask\fR(1), \fBxz\fR(1), \fBmknod\fR(1M),
\fBarchives.h\fR(3HEAD), \fBattributes\fR(5), \fBenviron\fR(5),
\fBfsattr\fR(5), \fBlargefile\fR(5), \fBmtio\fR(7I)
.SH DIAGNOSTICS
diff --git a/usr/src/man/man1m/Makefile b/usr/src/man/man1m/Makefile
index 4103245062..3d17bc7f65 100644
--- a/usr/src/man/man1m/Makefile
+++ b/usr/src/man/man1m/Makefile
@@ -11,8 +11,8 @@
#
# Copyright 2011, Richard Lowe
-# Copyright 2011 Nexenta Systems, Inc. All rights reserved.
# Copyright (c) 2012 Joyent, Inc. All rights reserved.
+# Copyright 2012 Nexenta Systems, Inc. All rights reserved.
#
include ../../Makefile.master
@@ -254,7 +254,6 @@ COMMON_MANFILES = 6to4relay.1m \
isns.1m \
isnsadm.1m \
itadm.1m \
- itu.1m \
k5srvutil.1m \
kadb.1m \
kadmin.1m \
@@ -323,7 +322,6 @@ COMMON_MANFILES = 6to4relay.1m \
metastat.1m \
metasync.1m \
metattach.1m \
- mkbootmedia.1m \
mkdevalloc.1m \
mkdevmaps.1m \
mkfifo.1m \
@@ -377,7 +375,6 @@ COMMON_MANFILES = 6to4relay.1m \
pbind.1m \
picld.1m \
ping.1m \
- pkg2du.1m \
pkgadd.1m \
pkgadm.1m \
pkgask.1m \
@@ -557,7 +554,6 @@ COMMON_MANFILES = 6to4relay.1m \
unshare_nfs.1m \
update_drv.1m \
updatehome.1m \
- updatemedia.1m \
useradd.1m \
userdel.1m \
usermod.1m \
diff --git a/usr/src/man/man1m/beadm.1m b/usr/src/man/man1m/beadm.1m
index 33203152f3..91edb619af 100644
--- a/usr/src/man/man1m/beadm.1m
+++ b/usr/src/man/man1m/beadm.1m
@@ -6,54 +6,55 @@ beadm \- utility for managing zfs boot environments
.SH SYNOPSIS
.LP
.nf
-\fBbeadm\fR create [\fB-a\fR] [\fB-d\fR \fIdescription\fR]
+\fBbeadm\fR \fBcreate\fR [\fB-a\fR] [\fB-d\fR \fIdescription\fR]
[\fB-e\fR \fInon-activeBeName\fR | \fIbeName@snapshot\fR]
- [\fB-o\fR \fIproperty=value\fR] ... [\fB-p\fR \fIzpool\FI] \fIbeName\fR
+ [\fB-o\fR \fIproperty=value\fR] ... [\fB-p\fR \fIzpool\fR]
+ [\fB-v\fR] \fIbeName\fR
.fi
.LP
.nf
-\fBbeadm\fR \fBcreate\fR \fIbeName@snapshot\fR
+\fBbeadm\fR \fBcreate\fR [\fB-v\fR] \fIbeName@snapshot\fR
.fi
.LP
.nf
-\fBbeadm\fR \fBdestroy\fR [\fB-fFs\fR] \fIbeName\fR | \fIbeName@snapshot\fR
+\fBbeadm\fR \fBdestroy\fR [\fB-fFsv\fR] \fIbeName\fR | \fIbeName@snapshot\fR
.fi
.LP
.nf
-\fBbeadm\fR \fBlist\fR [\fB-a\fR | \fB-ds\fR] [\fB-H\fR] [\fIbeName\fR]
+\fBbeadm\fR \fBlist\fR [\fB-a\fR | \fB-ds\fR] [\fB-H\fR] [\fB-v\fR] [\fIbeName\fR]
.fi
.LP
.nf
-\fBbeadm\fR \fBmount\fR \fIbeName\fR \fImountpoint\fR
+\fBbeadm\fR \fBmount\fR [\fB-v\fR] \fIbeName\fR \fImountpoint\fR
.fi
.LP
.nf
-\fBbeadm\fR \fBunmount\fR [\fB-f\fR] \fIbeName\fR | \fImountpoint\fR
+\fBbeadm\fR \fBunmount\fR [\fB-fv\fR] \fIbeName\fR | \fImountpoint\fR
.fi
.LP
.nf
-\fBbeadm\fR \fBrename\fR \fIbeName\fR \fInewBeName\fR
+\fBbeadm\fR \fBrename\fR [\fB-v\fR] \fIbeName\fR \fInewBeName\fR
.fi
.LP
.nf
-\fBbeadm\fR \fBactivate\fR \fIbeName\fR
+\fBbeadm\fR \fBactivate\fR [\fB-v\fR] \fIbeName\fR
.fi
.LP
.nf
-\fBbeadm\fR \fBrollback\fR \fIbeName\fR \fIsnapshot\fR
+\fBbeadm\fR \fBrollback\fR [\fB-v\fR] \fIbeName\fR \fIsnapshot\fR
.fi
.LP
.nf
-\fBbeadm\fR \fBrollback\fR \fIbeName@snapshot\fR
+\fBbeadm\fR \fBrollback\fR [\fB-v\fR] \fIbeName@snapshot\fR
.fi
.SH DESCRIPTION
@@ -160,9 +161,9 @@ Displays command usage.
.ne 2
.na
\fBbeadm\fR \fBcreate\fR [\fB-a\fR] [\fB-d\fR \fIdescription\fR]
-[\fB-e\fR \fInon-activeBeName\fR | \fIbeName@snapshot\fR]
- [\fB-o\fR
-\fIproperty=value\fR] ... [\fB-p\fR \fIzpool\fR] \fIbeName\fR
+ [\fB-e\fR \fInon-activeBeName\fR | \fIbeName@snapshot\fR]
+ [\fB-o\fR \fIproperty=value\fR] ... [\fB-p\fR \fIzpool\fR]
+ [\fB-v\fR] \fIbeName\fR
.ad
.sp .6
@@ -239,22 +240,40 @@ Create the new BE in the specified zpool. If this is not provided, the
default
behavior is to create the new BE in the same pool as as the origin BE.
.RE
+.sp
+.ne 2
+.na
+\fB-v\fR
+.ad
+.sp .6
+.RS 4n
+Verbose mode. Displays verbose error messages from \fBbeadm\fR.
+.RE
.RE
.sp
.ne 2
.na
-\fBbeadm\fR \fBcreate\fR \fIbeName@snapshot\fR
+\fBbeadm\fR \fBcreate\fR [\fB-v\fR] \fIbeName@snapshot\fR
.ad
.sp .6
.RS 4n
Creates a snapshot of the existing BE named beName.
+.sp
+.ne 2
+.na
+\fB-v\fR
+.ad
+.sp .6
+.RS 4n
+Verbose mode. Displays verbose error messages from \fBbeadm\fR.
+.RE
.RE
.sp
.ne 2
.na
-\fBbeadm\fR \fBdestroy\fR [\fB-fFs\fR] \fIbeName\fR | \fIbeName@snapshot\fR
+\fBbeadm\fR \fBdestroy\fR [\fB-fFsv\fR] \fIbeName\fR | \fIbeName@snapshot\fR
.ad
.sp .6
.RS 4n
@@ -294,12 +313,21 @@ environment.
Destroy all snapshots of the boot
environment.
.RE
+.sp
+.ne 2
+.na
+\fB-v\fR
+.ad
+.sp .6
+.RS 4n
+Verbose mode. Displays verbose error messages from \fBbeadm\fR.
+.RE
.RE
.sp
.ne 2
.na
-\fBbeadm\fR \fBlist\fR [\fB-a\fR | \fB-ds\fR] [\fB-H\fR] [\fIbeName\fR]
+\fBbeadm\fR \fBlist\fR [\fB-a\fR | \fB-ds\fR] [\fB-H\fR] [\fB-v\fR] [\fIbeName\fR]
.ad
.sp .6
.RS 4n
@@ -358,23 +386,41 @@ Lists information about the snapshots of the boot environment.
Do not list header information. Each field in the list information is
separated by a semicolon.
.RE
+.sp
+.ne 2
+.na
+\fB-v\fR
+.ad
+.sp .6
+.RS 4n
+Verbose mode. Displays verbose error messages from \fBbeadm\fR.
+.RE
.RE
.sp
.ne 2
.na
-\fBbeadm\fR \fBmount\fR \fIbeName\fR \fImountpoint\fR
+\fBbeadm\fR \fBmount\fR [\fB-v\fR] \fIbeName\fR \fImountpoint\fR
.ad
.sp .6
.RS 4n
Mounts a boot environment named beName at mountpoint. mountpoint must be an
already existing empty directory.
+.sp
+.ne 2
+.na
+\fB-v\fR
+.ad
+.sp .6
+.RS 4n
+Verbose mode. Displays verbose error messages from \fBbeadm\fR.
+.RE
.RE
.sp
.ne 2
.na
-\fBbeadm\fR \fBunmount\fR [\fB-f\fR] \fIbeName\fR | \fImountpoint\fR
+\fBbeadm\fR \fBunmount\fR [\fB-fv\fR] \fIbeName\fR | \fImountpoint\fR
.ad
.sp .6
.RS 4n
@@ -389,37 +435,73 @@ beName mount point on the system.
.RS 4n
Forcefully unmount the boot environment even if its currently busy.
.RE
+.sp
+.ne 2
+.na
+\fB-v\fR
+.ad
+.sp .6
+.RS 4n
+Verbose mode. Displays verbose error messages from \fBbeadm\fR.
+.RE
.RE
.sp
.ne 2
.na
-\fBbeadm\fR \fBrename\fR \fIbeName\fR \fInewBeName\fR
+\fBbeadm\fR \fBrename\fR [\fB-v\fR] \fIbeName\fR \fInewBeName\fR
.ad
.sp .6
.RS 4n
Renames the boot environment named \fIbeName\fR to \fInewBeName\fR.
+.sp
+.ne 2
+.na
+\fB-v\fR
+.ad
+.sp .6
+.RS 4n
+Verbose mode. Displays verbose error messages from \fBbeadm\fR.
+.RE
.RE
.sp
.ne 2
.na
-\fBbeadm\fR \fBrollback\fR \fIbeName\fR \fIsnapshot\fR | \fIbeName@snapshot\fR
+\fBbeadm\fR \fBrollback\fR [\fB-v\fR] \fIbeName\fR \fIsnapshot\fR | \fIbeName@snapshot\fR
.ad
.sp .6
.RS 4n
Roll back the boot environment named \fIbeName\fR to existing snapshot
of the boot environment named \fIbeName@snapshot\fR.
+.sp
+.ne 2
+.na
+\fB-v\fR
+.ad
+.sp .6
+.RS 4n
+Verbose mode. Displays verbose error messages from \fBbeadm\fR.
+.RE
.RE
.sp
.ne 2
.na
-\fBbeadm\fR \fBactivate\fR \fIbeName\fR
+\fBbeadm\fR \fBactivate\fR [\fB-v\fR] \fIbeName\fR
.ad
.sp .6
.RS 4n
Makes beName the active BE on next reboot.
+.sp
+.ne 2
+.na
+\fB-v\fR
+.ad
+.sp .6
+.RS 4n
+Verbose mode. Displays verbose error messages from \fBbeadm\fR.
+.RE
.RE
.SH ALTERNATE BE LOCATION
diff --git a/usr/src/man/man1m/itu.1m b/usr/src/man/man1m/itu.1m
deleted file mode 100644
index 6b4d2ea70a..0000000000
--- a/usr/src/man/man1m/itu.1m
+++ /dev/null
@@ -1,321 +0,0 @@
-'\" te
-.\" Copyright (c) 2008, Sun Microsystems, Inc. All Rights Reserved
-.\" The contents of this file are subject to the terms of the Common Development and Distribution License (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]
-.TH ITU 1M "Sep 23, 2009"
-.SH NAME
-itu \- convert packages to Driver Update format and patch Solaris install media
-for Install Time Update
-.SH SYNOPSIS
-.LP
-.nf
-\fBitu makedu\fR \fB-r\fR \fIsolaris_release\fR [\fB-v\fR] [\fB-f\fR] [\fB-d\fR \fIoutput_dir\fR] [\fB-o\fR \fIiso_file\fR]
- [\fB-l\fR \fIiso_label\fR] \fIpackage\fR [\fIpackage\fR...]
-.fi
-
-.LP
-.nf
-\fBitu updatemedia\fR \fB-R\fR \fImedia_root\fR [\fB-v\fR] [\fB-f\fR] [\fB-o\fR \fIiso_file\fR]
- [\fB-l\fR \fIiso_label\fR] \fIpkg\fR [\fIpkg\fR...]
-.fi
-
-.LP
-.nf
-\fBitu makeiso\fR \fB-o\fR \fIiso_file\fR [\fB-v\fR] [\fB-l\fR \fIiso_label\fR] \fImedia_root\fR
-.fi
-
-.SH DESCRIPTION
-.sp
-.LP
-The \fBitu\fR utility converts driver packages to Driver Update (DU) format and
-patches a Solaris install media with driver packages for Install Time Update
-(ITU). \fBitu\fR has three subcommands: \fBmakedu\fR, \fBupdatemedia\fR and
-\fBmakeiso\fR.
-.SH OPTIONS
-.sp
-.LP
-The following options are supported:
-.sp
-.ne 2
-.na
-\fB\fB-d\fR \fIoutput_dir\fR\fR
-.ad
-.sp .6
-.RS 4n
-Directory where the Driver Update directory is to be created.
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fB-f\fR\fR
-.ad
-.sp .6
-.RS 4n
-If \fIoutput_dir\fR/DU or \fIiso_file\fR already exists, remove it without
-asking first.
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fB-l\fR \fIiso_label\fR\fR
-.ad
-.sp .6
-.RS 4n
-Label/volume name of the ISO image (if \fB-o\fR option is specified).
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fB-o\fR \fIiso_file\fR\fR
-.ad
-.sp .6
-.RS 4n
-Path of the ISO image file to be created. For subcommands \fBupdatemedia\fR and
-\fBmakeiso\fR, it will be a bootable ISO image. This option must be specified
-for subcommand \fBmakeiso\fR.
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fB-R\fR \fImedia_root\fR\fR
-.ad
-.sp .6
-.RS 4n
-Top-level directory of on-disk image of Solaris installation media. This option
-must be specified for subcommand \fBupdatemedia\fR.
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fB-r\fR \fIsolaris_release\fR\fR
-.ad
-.sp .6
-.RS 4n
-Solaris release number for which the Driver Update is intended. It takes the
-form of the output of \fBuname\fR \fB-r\fR, for example, \fB5.10\fR. This
-option must be specified for subcommand \fBmakedu\fR.
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fB-v\fR\fR
-.ad
-.sp .6
-.RS 4n
-Verbose. Multiple \fB-v\fR options increase verbosity.
-.RE
-
-.SH SUB-COMMANDS
-.sp
-.LP
-The \fBitu\fR subcommands are described as follows.
-.SS "\fBmakedu\fR"
-.sp
-.LP
-The \fBmakedu\fR subcommand takes one or more driver packages as input and
-converts them to DU format. At the beginning of an interactive Solaris
-installation session, these driver updates can be applied to the running
-kernel, which will then also automatically apply them to the newly installed
-Solaris at the end of the installation process.
-.sp
-.LP
-The \fB-r\fR option is required to specify the Solaris release number for which
-the driver updates apply. The \fIsolaris_release\fR option argument takes the
-form \fBuname\fR \fB-r\fR output, for example, \fB5.10\fR or \fB5.11\fR.
-.sp
-.LP
-If the \fB-d\fR option is specified, the resulting DU directory tree is placed
-in the directory \fIoutput_dir\fR.
-.sp
-.LP
-If the \fB-o\fR option is specified, a (non-bootable) ISO image of the DU
-directory tree is written in the file \fIiso_file\fR. This ISO image can be
-burned onto a CD/DVD using \fBcdrw\fR(1) or \fBcdrecord(1)\fR (not a SunOS man
-page). See the "Examples" section below for an example of creating a DU on a
-floppy.
-.sp
-.LP
-At least one of \fB-d\fR and \fB-o\fR option must be specified. If both are
-specified, then both an ISO image and a directory tree are generated.
-.SS "\fBupdatemedia\fR"
-.sp
-.LP
-The \fBupdatemedia\fR subcommand takes a list of driver packages as input and
-applies them to the miniroot of a Solaris install media. It also places them in
-a subdirectory called \fBITUs\fR under the Solaris install media's top-level
-directory:
-.sp
-.in +2
-.nf
-\fImedia_root\fR/ITUs
-.fi
-.in -2
-.sp
-
-.sp
-.LP
-When booting a system from the updated media, the packages will be part of the
-booted Solaris image. They will also be applied to the target system being
-installed at the end of the installation process.
-.sp
-.LP
-The \fB-R\fR option must be entered on the command line to specify the Solaris
-install media. Note that the install media must be on a location that is
-writable by \fBitu\fR.
-.sp
-.LP
-If the \fB-o\fR option is specified, a bootable ISO image of the patched
-install media is also created in the file \fIiso_file\fR. The ISO image can
-then be burned onto a CD or DVD.
-.SS "\fBmakeiso\fR"
-.sp
-.LP
-The \fBmakeiso\fR subcommand runs \fBmkisofs(8)\fR to create a bootable Solaris
-ISO image of the Solaris install media \fImedia_root\fR and writes it to the
-file \fIiso_file\fR. The ISO image file can then be burned onto a CD or DVD
-with utilities such as \fBcdrw\fR(1) or \fBcdrecord(1)\fR. (Note that
-\fBmkisofs(8)\fR and \fBcdrecord(1)\fR are not SunOS man pages.)
-.LP
-Caution -
-.sp
-.RS 2
-The Solaris install media \fImedia-root\fR must contain the file
-\fBboot/grub/stage2_eltorito\fR, which will be written to the media boot
-sectors. This file will be modified with some boot information, thus it has to
-be writable. If necessary, first save a copy, prior to running this subcommand.
-.RE
-.SH OPERANDS
-.sp
-.LP
-The following operands are supported:
-.sp
-.ne 2
-.na
-\fB\fIpackage\fR [\fIpackage\fR...]\fR
-.ad
-.sp .6
-.RS 4n
-One or more driver packages.
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fIpkg\fR [\fIpkg\fR...]\fR
-.ad
-.sp .6
-.RS 4n
-One or more packages.
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fImedia_root\fR\fR
-.ad
-.sp .6
-.RS 4n
-The top-level directory of a Solaris install media.
-.RE
-
-.SH EXAMPLES
-.LP
-\fBExample 1 \fRCreating a DU CD/DVD
-.sp
-.LP
-The following commands create a Driver Update CD/DVD containing the packages
-\fBSAMPLEpkg1\fR and \fBSAMPLEpkg2\fR.
-
-.sp
-.in +2
-.nf
-# \fBitu makedu -r 5.10 -o my.iso SAMPLEpkg1 SAMPLEpkg2\fR
-# \fBcdrw -i my.iso\fR
-.fi
-.in -2
-.sp
-
-.LP
-\fBExample 2 \fRCreating a DU Floppy
-.sp
-.LP
-The following commands create a Driver Update floppy containing the driver
-package \fBMYdriver\fR.
-
-.sp
-.in +2
-.nf
-# \fBrmformat -F quick /dev/rdiskette\fR
-# \fBmkfs -F pcfs /dev/rdiskette\fR
-# \fBmount -F pcfs /dev/diskette /mnt\fR
-# \fB/usr/bin/itu makedu -r 5.10 -d /mnt /export/MYdriver\fR
-# \fBumount /mnt\fR
-# \fBdd if=/dev/rdiskette of=floppy.dd\fR
-.fi
-.in -2
-.sp
-
-.sp
-.LP
-The \fBitu\fR command above creates the DU directly onto the floppy mounted on
-\fB/mnt\fR. The \fBdd\fR invocation stores an image of the floppy in the file
-\fBfloppy.dd\fR. This is useful for distributing a DU floppy in file form. From
-the file, the floppy can then be recreated as follows:
-
-.sp
-.in +2
-.nf
-# \fBdd if=floppy.dd of=/dev/rdiskette\fR
-.fi
-.in -2
-.sp
-
-.LP
-\fBExample 3 \fRCreating a Bootable ISO Image
-.sp
-.LP
-The following commands create the bootable ISO image \fBmydvd.iso\fR of the
-Solaris install image \fB/export/solaris-10u1\fR with ISO label
-"\fBSpecial-S10\fR".
-
-.sp
-.in +2
-.nf
-# \fB/usr/bin/itu makeiso -o mydvd.iso -l "Special-S10" \e
- /export/solaris-10u1\fR
-# \fBcdrw -i mydvd.iso\fR
-.fi
-.in -2
-.sp
-
-.SH ATTRIBUTES
-.sp
-.LP
-See \fBattributes\fR(5) for descriptions of the following attributes:
-.sp
-
-.sp
-.TS
-box;
-c | c
-l | l .
-ATTRIBUTE TYPE ATTRIBUTE VALUE
-_
-Interface Stability Committed
-.TE
-
-.SH SEE ALSO
-.sp
-.LP
-\fBcdrw\fR(1), \fBpkgadd\fR(1M), \fBattributes\fR(5)
-.sp
-.LP
-\fBmkisofs(8)\fR, (\fB/usr/share/man/man8/mkisofs.8\fR), in the
-\fBSUNWfsman\fR package (not a SunOS man page)
diff --git a/usr/src/man/man1m/mkbootmedia.1m b/usr/src/man/man1m/mkbootmedia.1m
deleted file mode 100644
index fb78f74a4c..0000000000
--- a/usr/src/man/man1m/mkbootmedia.1m
+++ /dev/null
@@ -1,120 +0,0 @@
-'\" te
-.\" Copyright (c) 2008, Sun Microsystems, Inc. All Rights Reserved
-.\" The contents of this file are subject to the terms of the Common Development and Distribution License (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]
-.TH MKBOOTMEDIA 1M "Sep 23, 2009"
-.SH NAME
-mkbootmedia \- create bootable Solaris ISO image
-.SH SYNOPSIS
-.LP
-.nf
-\fB/usr/bin/mkbootmedia\fR \fB-v\fR [\fB-l\fR \fIlabel\fR] \fImedia-root\fR \fIiso\fR
-.fi
-
-.SH DESCRIPTION
-.sp
-.LP
-The \fBmkbootmedia\fR utility takes \fImedia-root\fR (the root of an on-disk
-Solaris install media) as input and creates a bootable Solaris ISO image in the
-file \fIiso\fR, using \fBmkisofs(8)\fR. The file can then be burned onto a
-CD/DVD with utilities such as \fBcdrw\fR(1) or \fBcdrecord(1)\fR. (Neither
-\fBmkisofs(8)\fR nor \fBcdrecord(1)\fR are SunOS man pages.)
-.LP
-Caution -
-.sp
-.RS 2
-The directory tree \fImedia-root\fR must contain the file
-\fBboot/grub/stage2_eltorito\fR, which will be written to the media boot
-sectors. This file will be modified with some boot information, thus it must be
-writable. If necessary, first save a copy prior to running this utility.
-.RE
-.SH OPTIONS
-.sp
-.LP
-The following options are supported:
-.sp
-.ne 2
-.na
-\fB\fB-l\fR \fIlabel\fR\fR
-.ad
-.sp .6
-.RS 4n
-Sets \fIlabel\fR as the label/volume name of the ISO image.
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fB-v\fR\fR
-.ad
-.sp .6
-.RS 4n
-Verbose. Multiple \fB-v\fR options increase verbosity.
-.RE
-
-.SH OPERANDS
-.sp
-.LP
-The following operands are supported:
-.sp
-.ne 2
-.na
-\fB\fImedia-root\fR\fR
-.ad
-.sp .6
-.RS 4n
-Top-level directory of an on-disk Solaris install media.
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fIiso\fR\fR
-.ad
-.sp .6
-.RS 4n
-Name of the output file which will contain the resulting ISO image.
-.RE
-
-.SH EXAMPLES
-.LP
-\fBExample 1 \fRCreating an ISO Image and Burning a CD/DVD
-.sp
-.LP
-The following commands create an ISO image from the content of \fBs10u1\fR and
-burn the image to a CD/DVD.
-
-.sp
-.in +2
-.nf
-# \fB/usr/bin/mkbootmedia s10u1 s10u1.iso\fR
-# \fB/usr/bin/cdrw -i s10u1.iso\fR
-.fi
-.in -2
-.sp
-
-.SH ATTRIBUTES
-.sp
-.LP
-See \fBattributes\fR(5) for descriptions of the following attributes:
-.sp
-
-.sp
-.TS
-box;
-c | c
-l | l .
-ATTRIBUTE TYPE ATTRIBUTE VALUE
-_
-Interface Stability Committed
-.TE
-
-.SH SEE ALSO
-.sp
-.LP
-\fBcdrw\fR(1), \fBattributes\fR(5)
-.sp
-.LP
-\fBmkisofs(8)\fR, (\fB/usr/share/man/man8/mkisofs.8\fR), in the
-\fBSUNWfsman\fR package (not a SunOS man page)
diff --git a/usr/src/man/man1m/pkg2du.1m b/usr/src/man/man1m/pkg2du.1m
deleted file mode 100644
index 23f9dc1cb6..0000000000
--- a/usr/src/man/man1m/pkg2du.1m
+++ /dev/null
@@ -1,150 +0,0 @@
-'\" te
-.\" Copyright (c) 2008, Sun Microsystems, Inc. All Rights Reserved
-.\" The contents of this file are subject to the terms of the Common Development and Distribution License (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]
-.TH PKG2DU 1M "Sep 23, 2009"
-.SH NAME
-pkg2du \- convert driver packages to Driver Update format
-.SH SYNOPSIS
-.LP
-.nf
-\fB/usr/bin/pkg2du\fR [\fB-f\fR] [\fB-v\fR] [\fB-d\fR \fIdir\fR] [\fB-o\fR \fIiso\fR] [\fB-l\fR \fIlabel\fR]
- [\fB-r\fR \fIrelease\fR] \fIpkg\fR [\fIpkg\fR ...]
-.fi
-
-.SH DESCRIPTION
-.sp
-.LP
-The \fB/usr/bin/pkg2du\fR utility takes one or more packages as input and
-converts them to Driver Update (DU) format. If the \fB-d\fR option is
-specified, the resulting DU directory tree is placed in the directory
-\fIdir\fR. If the \fB-o\fR option is specified, a Solaris ISO image of the DU
-directory tree is written in the file \fIiso\fR. The ISO image can be burned
-onto CD/DVD using \fBcdrw\fR(1) or \fBcdrecord(1)\fR (not a SunOS man page) and
-used during Solaris installation.
-.sp
-.LP
-At least one of the \fB-d\fR and \fB-o\fR options must be specified. If both
-are specified, then both an ISO image and a directory tree are generated.
-.SH OPTIONS
-.sp
-.LP
-The following options are supported:
-.sp
-.ne 2
-.na
-\fB\fB-d\fR \fIdir\fR\fR
-.ad
-.sp .6
-.RS 4n
-Directory where the DU directory should be created.
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fB-o\fR \fIiso\fR\fR
-.ad
-.sp .6
-.RS 4n
-Create a Solaris ISO image of the DU directory.
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fB-f\fR\fR
-.ad
-.sp .6
-.RS 4n
-If \fB\fIdir\fR/DU\fR or \fIiso\fR exists, remove it without asking first.
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fB-l\fR \fIlabel\fR\fR
-.ad
-.sp .6
-.RS 4n
-Label/volume name of the ISO image (if \fB-o\fR option is specified).
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fB-r\fR \fIrelease\fR\fR
-.ad
-.sp .6
-.RS 4n
-Solaris release number to use. It takes the form of the return from \fBuname\fR
-\fB-r\fR command, for example, \fB5.10\fR. If unspecified, the release number
-of the currently running Solaris is used.
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fB-v\fR\fR
-.ad
-.sp .6
-.RS 4n
-Verbose. Multiple \fB-v\fR options increase verbosity.
-.RE
-
-.SH OPERANDS
-.sp
-.LP
-The following operands are supported:
-.sp
-.ne 2
-.na
-\fB\fIpkg\fR [\fIpkg\fR...]\fR
-.ad
-.sp .6
-.RS 4n
-One or more packages to be converted to DU format.
-.RE
-
-.SH EXAMPLES
-.LP
-\fBExample 1 \fRCreating a DU CD/DVD
-.sp
-.LP
-The following commands create a DU CD or DVD containing packages \fBSUNWfoo\fR
-and \fBSUNWbar\fR.
-
-.sp
-.in +2
-.nf
-# \fB/usr/bin/pkg2du -r 5.10 -o my.iso SUNWfoo SUNWbar\fR
-# \fB/usr/bin/cdrw -i my.iso\fR
-.fi
-.in -2
-.sp
-
-.SH ATTRIBUTES
-.sp
-.LP
-See \fBattributes\fR(5) for descriptions of the following attributes:
-.sp
-
-.sp
-.TS
-box;
-c | c
-l | l .
-ATTRIBUTE TYPE ATTRIBUTE VALUE
-_
-Interface Stability Committed
-.TE
-
-.SH SEE ALSO
-.sp
-.LP
-\fBcdrw\fR(1), \fBmkbootmedia\fR(1M), \fBattributes\fR(5)
-.sp
-.LP
-\fBmkisofs(8)\fR, (\fB/usr/share/man/man8/mkisofs.8\fR), in the
-\fBSUNWfsman\fR package (not a SunOS man page)
diff --git a/usr/src/man/man1m/root_archive.1m b/usr/src/man/man1m/root_archive.1m
index ec30a07b35..f4b53fe0ae 100644
--- a/usr/src/man/man1m/root_archive.1m
+++ b/usr/src/man/man1m/root_archive.1m
@@ -3,6 +3,7 @@
.\" The contents of this file are subject to the terms of the Common Development and Distribution License (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]
+.\" Copyright 2012 Nexenta Systems, Inc. All rights reserved.
.TH ROOT_ARCHIVE 1M "Sep 9, 2009"
.SH NAME
root_archive \- manage bootable miniroot archives
@@ -17,35 +18,16 @@ root_archive \- manage bootable miniroot archives
\fB/boot/solaris/bin/root_archive\fR unpack \fIarchive\fR \fIroot\fR
.fi
-.LP
-.nf
-\fB/boot/solaris/bin/root_archive\fR packmedia \fIsolaris_image\fR \fIroot\fR
-.fi
-
-.LP
-.nf
-\fB/boot/solaris/bin/root_archive\fR unpackmedia \fIsolaris_image\fR \fIroot\fR
-.fi
-
.SH DESCRIPTION
.sp
.LP
-The \fBroot_archive\fR utility is used to manipulate boot archives and the
-bootable miniroot(s) in a Solaris install image. The utility can pack and
-unpack boot archives and image miniroots. Both \fBufs\fR and \fBhsfs\fR
+The \fBroot_archive\fR utility is used to manipulate boot archives.
+The utility can pack and unpack boot archives and image miniroots. Both \fBufs\fR and \fBhsfs\fR
(\fBiso9660\fR) format archives can be unpacked, although only \fBufs\fR format
is generated when packing.
.sp
.LP
-For normal, boot-related system administration, \fBbootadm\fR(1M) is
-recommended. \fBroot_archive\fR's primary purpose is to enable OEMs to add or
-update a driver or other component on the Solaris install media.
-.sp
-.LP
-A miniroot and a boot archive is closely associated with the release it is
-intended to boot. To ensure that the tools and system services used to
-construct the miniroot match, miniroot manipulation must be performed only on a
-system running the same release for which the miniroot is intended to install.
+For normal, boot-related system administration, \fBbootadm\fR(1M) is recommended.
.SH SUBCOMMANDS
.sp
.LP
@@ -65,79 +47,11 @@ Pack the contents of the root directory into the boot archive \fIarchive\fR.
\fB\fBunpack\fR \fIarchive\fR \fIroot\fR\fR
.ad
.sp .6
-.RS 4n
+.RS 21n
Unpack the contents of the boot archive named \fIarchive\fR to the directory
named \fIroot\fR.
.RE
-.sp
-.ne 2
-.na
-\fB\fBpackmedia\fR \fIsolaris_image\fR \fIroot\fR\fR
-.ad
-.sp .6
-.RS 4n
-Create and pack the miniroot(s) in \fIsolaris_image\fR from the contents of the
-directory named \fIroot\fR.
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fBunpackmedia\fR \fIsolaris_image\fR \fIroot\fR\fR
-.ad
-.sp .6
-.RS 4n
-Unpack the contents of the miniroot(s) in \fIsolaris_image\fR to the directory
-named \fIroot\fR.
-.RE
-
-.sp
-.LP
-The contents of a miniroot are constructed to need the requirements of the
-release. When unpacking a miniroot, all the contents of the miniroot(s) are
-unpacked. When packing a miniroot, the source directory must contain all the
-necessary components with which to construct a miniroot. In general, this can
-only be achieved by first unpacking an existing miniroot.
-.SH EXAMPLES
-.LP
-\fBExample 1 \fRUnpacking the Miniroots in a Solaris x86 Install Image
-.sp
-.LP
-The following command unpacks the miniroots in a Solaris image to the root
-directory in \fB/export/release/latest\fR.
-
-.sp
-.in +2
-.nf
-# \fBroot_archive unpackmedia \e\fR
-\fB/export/nv/solarisdvd.nvx_dvd/latest /export/release/latest/root\fR
-.fi
-.in -2
-.sp
-
-.sp
-.LP
-In the preceding, \fB/export/nv/solarisdvd.nvx_dvd/latest\fR represents a path
-to a Solaris x86 install image and \fB/export/release/latest/root\fR is a
-directory that will be purged or created, as necessary.
-
-.LP
-\fBExample 2 \fRPacking the Miniroots in a Solaris x86 Install Image
-.sp
-.LP
-The following command creates and packs the miniroot(s) in a Solaris image from
-the contents of the directory \fB/export/release/latest/root\fR.
-
-.sp
-.in +2
-.nf
-# \fBroot_archive packmedia \e\fR
-\fB/export/nv/solarisdvd.nvx_dvd/latest /export/release/latest/root\fR
-.fi
-.in -2
-.sp
-
.SH EXIT STATUS
.sp
.LP
diff --git a/usr/src/man/man1m/updatemedia.1m b/usr/src/man/man1m/updatemedia.1m
deleted file mode 100644
index db782ece2b..0000000000
--- a/usr/src/man/man1m/updatemedia.1m
+++ /dev/null
@@ -1,145 +0,0 @@
-'\" te
-.\" Copyright (c) 2008, Sun Microsystems, Inc. All Rights Reserved
-.\" The contents of this file are subject to the terms of the Common Development and Distribution License (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]
-.TH UPDATEMEDIA 1M "Sep 23, 2009"
-.SH NAME
-updatemedia \- modify Solaris media with patches and packages
-.SH SYNOPSIS
-.LP
-.nf
-\fB/usr/bin/updatemedia\fR \fB-d\fR \fImedia-root\fR [\fB-v\fR] [\fB-o\fR \fIiso\fR] [\fB-l\fR \fIlabel\fR]
- \fIpkg_or_patch\fR [\fIpkg_or_patch\fR ...]
-.fi
-
-.SH DESCRIPTION
-.sp
-.LP
-The \fBupdatemedia\fR utility takes a list of patches and packages as input and
-updates the install miniroot in \fImedia-root\fR (the root directory of an
-on-disk image of a Solaris installation media) to include the specified patches
-and packages. These patches and packages are also placed in a subdirectory
-called \fBDU\fR under the Solaris install image. For example:
-.sp
-.in +2
-.nf
-\fImedia-root\fR/Solaris_10/DU
-.fi
-.in -2
-.sp
-
-.sp
-.LP
-When booting a system from the updated media, the patches and packages will be
-part of the booted Solaris image. They will also be applied to the target
-system being installed at the end of the installation process.
-.sp
-.LP
-If \fB-o\fR is specified, a bootable ISO image is created in the file
-\fBmedia.iso\fR that contains the Solaris install media. The ISO image can then
-be burned onto a CD/DVD with utilities such as \fBcdrw\fR(1) or
-\fBcdrecord(1)\fR. (The latter is not a SunOS man page.)
-.SH OPTIONS
-.sp
-.LP
-The following options are supported:
-.sp
-.ne 2
-.na
-\fB\fB-d\fR \fImedia-root\fR\fR
-.ad
-.sp .6
-.RS 4n
-Top-level directory of on-disk image of Solaris installation media. This is
-option must be specified.
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fB-o\fR \fIiso\fR\fR
-.ad
-.sp .6
-.RS 4n
-Create a Solaris ISO image of \fImedia-root\fR.
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fB-l\fR \fIlabel\fR\fR
-.ad
-.sp .6
-.RS 4n
-Label/volume name of the ISO image (if \fB-o\fR option is specified). If
-\fB-o\fR is not specified, the name of Solaris directory under
-\fImedia-root\fR, for example, \fBSolaris_10\fR, will be used.
-.RE
-
-.sp
-.ne 2
-.na
-\fB\fB-v\fR\fR
-.ad
-.sp .6
-.RS 4n
-Verbose. Multiple \fB-v\fR options increase verbosity.
-.RE
-
-.SH OPERANDS
-.sp
-.LP
-The following operands are supported:
-.sp
-.ne 2
-.na
-\fB\fIpkg_or_patch\fR [\fIpkg_or_patch\fR ...]\fR
-.ad
-.sp .6
-.RS 4n
-One or more patches or packages (you can have both patches and packages in a
-single command) with which the Solaris installation media \fImedia-root\fR will
-be updated.
-.RE
-
-.SH EXAMPLES
-.LP
-\fBExample 1 \fRUpdating a Solaris Install Image with Patch and Package
-.sp
-.LP
-The following command updates the Solaris install image in \fBs10u1\fR by
-adding patch \fB123456-07\fR and package \fBSUNWfoo\fR.
-
-.sp
-.in +2
-.nf
-# \fB/usr/bin/updatemedia -d s10u1 SUNWfoo 123456-07\fR
-.fi
-.in -2
-.sp
-
-.SH ATTRIBUTES
-.sp
-.LP
-See \fBattributes\fR(5) for descriptions of the following attributes:
-.sp
-
-.sp
-.TS
-box;
-c | c
-l | l .
-ATTRIBUTE TYPE ATTRIBUTE VALUE
-_
-Interface Stability Committed
-.TE
-
-.SH SEE ALSO
-.sp
-.LP
-\fBcdrw\fR(1), \fBmkbootmedia\fR(1M), \fBattributes\fR(5)
-.sp
-.LP
-\fBmkisofs(8)\fR, (\fB/usr/share/man/man8/mkisofs.8\fR), in the
-\fBSUNWfsman\fR package (not a SunOS man page)
diff --git a/usr/src/man/man1m/zfs.1m b/usr/src/man/man1m/zfs.1m
index 1866056361..f892c919b7 100644
--- a/usr/src/man/man1m/zfs.1m
+++ b/usr/src/man/man1m/zfs.1m
@@ -3,6 +3,7 @@
.\" Copyright (c) 2012 by Delphix. All rights reserved.
.\" Copyright (c) 2011 Joyent, Inc. All Rights Reserved.
.\" Copyright (c) 2012 Nexenta Systems, Inc. All Rights Reserved.
+.\" Copyright (c) 2012, Joyent, Inc. All rights reserved.
.\" The contents of this file are subject to the terms of the Common Development and Distribution License (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]
@@ -39,7 +40,7 @@ zfs \- configures ZFS file systems
.LP
.nf
\fBzfs\fR \fBsnapshot\fR [\fB-r\fR] [\fB-o\fR \fIproperty\fR=\fIvalue\fR]...
- \fIfilesystem@snapname\fR|\fIvolume@snapname\fR
+ \fIfilesystem@snapname\fR|\fIvolume@snapname\fR...
.fi
.LP
@@ -1840,13 +1841,14 @@ behavior for mounted file systems in use.
.ne 2
.na
\fB\fBzfs snapshot\fR [\fB-r\fR] [\fB-o\fR \fIproperty\fR=\fIvalue\fR] ...
-\fIfilesystem@snapname\fR|\fIvolume@snapname\fR\fR
+\fIfilesystem@snapname\fR|\fIvolume@snapname\fR\fR...
.ad
.sp .6
.RS 4n
-Creates a snapshot with the given name. All previous modifications by
-successful system calls to the file system are part of the snapshot. See the
-"Snapshots" section for details.
+Creates snapshots with the given names. All previous modifications by
+successful system calls to the file system are part of the snapshots.
+Snapshots are taken atomically, so that all snapshots correspond to the same
+moment in time. See the "Snapshots" section for details.
.sp
.ne 2
.na
@@ -1854,9 +1856,7 @@ successful system calls to the file system are part of the snapshot. See the
.ad
.sp .6
.RS 4n
-Recursively create snapshots of all descendent datasets. Snapshots are taken
-atomically, so that all recursive snapshots correspond to the same moment in
-time.
+Recursively create snapshots of all descendent datasets
.RE
.sp
@@ -2873,7 +2873,8 @@ Print machine-parsable verbose information about the stream package generated.
.ad
.sp .6
.RS 4n
-Print verbose information about the stream package generated.
+Print verbose information about the stream package generated. This information
+includes a per-second report of how much data has been sent.
.RE
The format of the stream is committed. You will be able to receive your streams
diff --git a/usr/src/man/man1m/zpool.1m b/usr/src/man/man1m/zpool.1m
index feb9c313ed..a55ca387cc 100644
--- a/usr/src/man/man1m/zpool.1m
+++ b/usr/src/man/man1m/zpool.1m
@@ -2,11 +2,20 @@
.\" Copyright (c) 2007, Sun Microsystems, Inc. All Rights Reserved.
.\" Copyright (c) 2011, Joyent, Inc. All Rights Reserved.
.\" Copyright 2011, Nexenta Systems, Inc. All Rights Reserved.
-.\" Copyright (c) 2012 by Delphix. All Rights Reserved.
-.\" The contents of this file are subject to the terms of the Common Development and Distribution License (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]
-.TH ZPOOL 1M "Nov 14, 2011"
+.\" Copyright (c) 2012 by Delphix. All rights reserved.
+.\" The contents of this file are subject to the terms of the Common Development
+.\" and Distribution License (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]
+.TH ZPOOL 1M "Mar 16, 2012"
.SH NAME
zpool \- configures ZFS storage pools
.SH SYNOPSIS
@@ -32,7 +41,7 @@ zpool \- configures ZFS storage pools
.LP
.nf
-\fBzpool create\fR [\fB-fn\fR] [\fB-o\fR \fIproperty=value\fR] ... [\fB-O\fR \fIfile-system-property=value\fR]
+\fBzpool create\fR [\fB-fnd\fR] [\fB-o\fR \fIproperty=value\fR] ... [\fB-O\fR \fIfile-system-property=value\fR]
... [\fB-m\fR \fImountpoint\fR] [\fB-R\fR \fIroot\fR] \fIpool\fR \fIvdev\fR ...
.fi
@@ -548,24 +557,34 @@ shortened column name, "cap".
.sp
.ne 2
.na
-\fB\fBcomment\fR\fR
+\fB\fBexpandsize\fR\fR
.ad
.RS 20n
-A text string consisting of printable ASCII characters that will be stored
-such that it is available even if the pool becomes faulted. An administrator
-can provide additional information about a pool using this property.
+Amount of uninitialized space within the pool or device that can be used to
+increase the total capacity of the pool. Uninitialized space consists of
+any space on an EFI labeled vdev which has not been brought online
+(i.e. zpool online -e). This space occurs when a LUN is dynamically expanded.
.RE
.sp
.ne 2
.na
-\fB\fBexpandsize\fR\fR
+\fB\fBfree\fR\fR
.ad
.RS 20n
-Amount of uninitialized space within the pool or device that can be used to
-increase the total capacity of the pool. Uninitialized space consists of
-any space on an EFI labeled vdev which has not been brought online
-(i.e. zpool online -e). This space occurs when a LUN is dynamically expanded.
+The amount of free space available in the pool.
+.RE
+
+.sp
+.ne 2
+.na
+\fB\fBfreeing\fR\fR
+.ad
+.RS 20n
+After a file system or snapshot is destroyed, the space it was using is
+returned to the pool asynchronously. \fB\fBfreeing\fR\fR is the amount of
+space remaining to be reclaimed. Over time \fB\fBfreeing\fR\fR will decrease
+while \fB\fBfree\fR\fR increases.
.RE
.sp
@@ -599,6 +618,16 @@ Total size of the storage pool.
.sp
.ne 2
.na
+\fB\fBunsupported@\fR\fIfeature_guid\fR\fR
+.ad
+.RS 20n
+Information about unsupported features that are enabled on the pool. See
+\fBzpool-features\fR(5) for details.
+.RE
+
+.sp
+.ne 2
+.na
\fB\fBused\fR\fR
.ad
.RS 20n
@@ -607,7 +636,7 @@ Amount of storage space used within the pool.
.sp
.LP
-These space usage properties report actual physical space available to the
+The space usage properties report actual physical space available to the
storage pool. The physical space can be different from the total amount of
space that any contained datasets can actually use. The amount of space used in
a \fBraidz\fR configuration depends on the characteristics of the data being
@@ -706,6 +735,17 @@ exported or destroyed, the file is removed.
.sp
.ne 2
.na
+\fB\fBcomment\fR=\fB\fItext\fR\fR
+.ad
+.RS 4n
+A text string consisting of printable ASCII characters that will be stored
+such that it is available even if the pool becomes faulted. An administrator
+can provide additional information about a pool using this property.
+.RE
+
+.sp
+.ne 2
+.na
\fB\fBdelegation\fR=\fBon\fR | \fBoff\fR\fR
.ad
.sp .6
@@ -761,6 +801,18 @@ Prints out a message to the console and generates a system crash dump.
.sp
.ne 2
.na
+\fB\fBfeature@\fR\fIfeature_name\fR=\fBenabled\fR\fR
+.ad
+.RS 4n
+The value of this property is the current state of \fIfeature_name\fR. The
+only valid value when setting this property is \fBenabled\fR which moves
+\fIfeature_name\fR to the enabled state. See \fBzpool-features\fR(5) for
+details on feature states.
+.RE
+
+.sp
+.ne 2
+.na
\fB\fBlistsnaps\fR=on | off\fR
.ad
.sp .6
@@ -780,8 +832,8 @@ value is "off".
The current on-disk version of the pool. This can be increased, but never
decreased. The preferred method of updating pools is with the "\fBzpool
upgrade\fR" command, though this property can be used when a specific version
-is needed for backwards compatibility. This property can be any number between
-1 and the current version reported by "\fBzpool upgrade -v\fR".
+is needed for backwards compatibility. Once feature flags is enabled on a
+pool this property will no longer have a value.
.RE
.SS "Subcommands"
@@ -882,7 +934,7 @@ those errors associated with the specified device or devices are cleared.
.sp
.ne 2
.na
-\fB\fBzpool create\fR [\fB-fn\fR] [\fB-o\fR \fIproperty=value\fR] ... [\fB-O\fR
+\fB\fBzpool create\fR [\fB-fnd\fR] [\fB-o\fR \fIproperty=value\fR] ... [\fB-O\fR
\fIfile-system-property=value\fR] ... [\fB-m\fR \fImountpoint\fR] [\fB-R\fR
\fIroot\fR] \fIpool\fR \fIvdev\fR ...\fR
.ad
@@ -912,6 +964,9 @@ Unless the \fB-R\fR option is specified, the default mount point is
root dataset cannot be mounted. This can be overridden with the \fB-m\fR
option.
.sp
+By default all supported features are enabled on the new pool unless the
+\fB-d\fR option is specified.
+.sp
.ne 2
.na
\fB\fB-f\fR\fR
@@ -937,6 +992,18 @@ device sharing.
.sp
.ne 2
.na
+\fB\fB-d\fR\fR
+.ad
+.sp .6
+.RS 4n
+Do not enable any features on the new pool. Individual features can be enabled
+by setting their corresponding properties to \fBenabled\fR with the \fB-o\fR
+option. See \fBzpool-features\fR(5) for details about feature properties.
+.RE
+
+.sp
+.ne 2
+.na
\fB\fB-o\fR \fIproperty=value\fR [\fB-o\fR \fIproperty=value\fR] ...\fR
.ad
.sp .6
@@ -1649,11 +1716,10 @@ data errors since the last complete pool scrub.
.ad
.sp .6
.RS 4n
-Displays all pools formatted using a different \fBZFS\fR on-disk version. Older
-versions can continue to be used, but some features may not be available. These
-pools can be upgraded using "\fBzpool upgrade -a\fR". Pools that are formatted
-with a more recent version are also displayed, although these pools will be
-inaccessible on the system.
+Displays pools which do not have all supported features enabled and pools
+formatted using a legacy ZFS version number. These pools can continue to be
+used, but some features may not be available. Use "\fBzpool upgrade -a\fR"
+to enable all features on all pools.
.RE
.sp
@@ -1663,9 +1729,9 @@ inaccessible on the system.
.ad
.sp .6
.RS 4n
-Displays \fBZFS\fR versions supported by the current software. The current
-\fBZFS\fR versions and all previous supported versions are displayed, along
-with an explanation of the features provided with each version.
+Displays legacy \fBZFS\fR versions supported by the current software. See
+\fBzfs-features\fR(5) for a description of feature flags features supported
+by the current software.
.RE
.sp
@@ -1675,16 +1741,18 @@ with an explanation of the features provided with each version.
.ad
.sp .6
.RS 4n
-Upgrades the given pool to the latest on-disk version. Once this is done, the
-pool will no longer be accessible on systems running older versions of the
-software.
+Enables all supported features on the given pool. Once this is done, the
+pool will no longer be accessible on systems that do not support feature
+flags. See \fBzfs-features\fR(5) for details on compatability with systems
+that support feature flags, but do not support all features enabled on the
+pool.
.sp
.ne 2
.na
\fB\fB-a\fR\fR
.ad
.RS 14n
-Upgrades all pools.
+Enables all supported features on all pools.
.RE
.sp
@@ -1693,10 +1761,9 @@ Upgrades all pools.
\fB\fB-V\fR \fIversion\fR\fR
.ad
.RS 14n
-Upgrade to the specified version. If the \fB-V\fR flag is not specified, the
-pool is upgraded to the most recent version. This option can only be used to
-increase the version number, and only up to the most recent version supported
-by this software.
+Upgrade to the specified legacy version. If the \fB-V\fR flag is specified, no
+features will be enabled on the pool. This option can only be used to increase
+the version number up to the last supported legacy version number.
.RE
.RE
@@ -2083,4 +2150,4 @@ Interface Stability Evolving
.SH SEE ALSO
.sp
.LP
-\fBzfs\fR(1M), \fBattributes\fR(5)
+\fBzfs\fR(1M), \fBzpool-features\fR(5), \fBattributes\fR(5)
diff --git a/usr/src/man/man3malloc/umem_alloc.3malloc b/usr/src/man/man3malloc/umem_alloc.3malloc
index eb6b270398..d8680ca083 100644
--- a/usr/src/man/man3malloc/umem_alloc.3malloc
+++ b/usr/src/man/man3malloc/umem_alloc.3malloc
@@ -188,6 +188,31 @@ the thread exits. The efficacy of the per-thread cache can be determined with
the \fB::umastat\fR \fBmdb\fR(1) \fIdcmd\fR debugger command.
.RE
+.ne 2
+.na
+\fB\fBallocator\fR=\fBbest\fR\fR
+.ad
+.br
+.na
+\fB\fBallocator\fR=\fBfirst\fR\fR
+.ad
+.br
+.na
+\fB\fBallocator\fR=\fBinstant\fR\fR
+.ad
+.br
+.na
+\fB\fBallocator\fR=\fBnext\fR\fR
+.ad
+.RS 16n
+Set the underlying allocation strategy. The \fBbest\fR fit strategy tells
+libumem to use the smallest free segment possible. The \fBinstant\fR fit
+strategy approximates the best fit strategy in constant cpu time. The
+\fBfirst\fR fit strategy takes the first free segment that can honor the
+allocation. The \fBnext\fR fit strategy uses the next free segment after the
+previously allocated one.
+.RE
+
.RE
.SH EXAMPLES
diff --git a/usr/src/man/man5/Makefile b/usr/src/man/man5/Makefile
index c08328e409..ba5acbd1d4 100644
--- a/usr/src/man/man5/Makefile
+++ b/usr/src/man/man5/Makefile
@@ -9,109 +9,113 @@
# at http://www.illumos.org/license/CDDL.
#
+#
# Copyright 2011, Richard Lowe
+# Copyright (c) 2012 by Delphix. All rights reserved.
+#
include ../../Makefile.master
-MANSECT = 5
-
-MANFILES = Intro.5 \
- acl.5 \
- ad.5 \
- ascii.5 \
- attributes.5 \
- audit_binfile.5 \
- audit_remote.5 \
- audit_syslog.5 \
- brands.5 \
- cancellation.5 \
- charmap.5 \
- condition.5 \
- crypt_bsdbf.5 \
- crypt_bsdmd5.5 \
- crypt_sha256.5 \
- crypt_sha512.5 \
- crypt_sunmd5.5 \
- crypt_unix.5 \
- device_clean.5 \
- dhcp.5 \
- dhcp_modules.5 \
- environ.5 \
- eqnchar.5 \
- extendedFILE.5 \
- filesystem.5 \
- fnmatch.5 \
- formats.5 \
- fsattr.5 \
- grub.5 \
- gss_auth_rules.5 \
- hal.5 \
- iconv.5 \
- iconv_unicode.5 \
- ieee802.11.5 \
- ipfilter.5 \
- isalist.5 \
- kerberos.5 \
- krb5_auth_rules.5 \
- krb5envvar.5 \
- largefile.5 \
- lf64.5 \
- lfcompile.5 \
- lfcompile64.5 \
- locale.5 \
- man.5 \
- mansun.5 \
- me.5 \
- mech_spnego.5 \
- mm.5 \
- ms.5 \
- mutex.5 \
- nfssec.5 \
- pam_allow.5 \
- pam_authtok_check.5 \
- pam_authtok_get.5 \
- pam_authtok_store.5 \
- pam_deny.5 \
- pam_dhkeys.5 \
- pam_dial_auth.5 \
- pam_krb5.5 \
- pam_krb5_migrate.5 \
- pam_ldap.5 \
- pam_list.5 \
- pam_passwd_auth.5 \
- pam_rhosts_auth.5 \
- pam_roles.5 \
- pam_sample.5 \
- pam_smb_passwd.5 \
- pam_smbfs_login.5 \
- pam_tsol_account.5 \
- pam_unix_account.5 \
- pam_unix_auth.5 \
- pam_unix_cred.5 \
- pam_unix_session.5 \
- pkcs11_kernel.5 \
- pkcs11_softtoken.5 \
- pkcs11_tpm.5 \
- privileges.5 \
- prof.5 \
- rbac.5 \
- regex.5 \
- regexp.5 \
- resource_controls.5 \
- smf.5 \
- smf_bootstrap.5 \
- smf_method.5 \
- smf_restarter.5 \
- smf_security.5 \
- smf_template.5 \
- standards.5 \
- sticky.5 \
- tecla.5 \
- term.5 \
- threads.5 \
- trusted_extensions.5 \
- vgrindefs.5 \
- zones.5
+MANSECT = 5
+
+MANFILES = Intro.5 \
+ acl.5 \
+ ad.5 \
+ ascii.5 \
+ attributes.5 \
+ audit_binfile.5 \
+ audit_remote.5 \
+ audit_syslog.5 \
+ brands.5 \
+ cancellation.5 \
+ charmap.5 \
+ condition.5 \
+ crypt_bsdbf.5 \
+ crypt_bsdmd5.5 \
+ crypt_sha256.5 \
+ crypt_sha512.5 \
+ crypt_sunmd5.5 \
+ crypt_unix.5 \
+ device_clean.5 \
+ dhcp.5 \
+ dhcp_modules.5 \
+ environ.5 \
+ eqnchar.5 \
+ extendedFILE.5 \
+ filesystem.5 \
+ fnmatch.5 \
+ formats.5 \
+ fsattr.5 \
+ grub.5 \
+ gss_auth_rules.5 \
+ hal.5 \
+ iconv.5 \
+ iconv_unicode.5 \
+ ieee802.11.5 \
+ ipfilter.5 \
+ isalist.5 \
+ kerberos.5 \
+ krb5_auth_rules.5 \
+ krb5envvar.5 \
+ largefile.5 \
+ lf64.5 \
+ lfcompile.5 \
+ lfcompile64.5 \
+ locale.5 \
+ man.5 \
+ mansun.5 \
+ me.5 \
+ mech_spnego.5 \
+ mm.5 \
+ ms.5 \
+ mutex.5 \
+ nfssec.5 \
+ pam_allow.5 \
+ pam_authtok_check.5 \
+ pam_authtok_get.5 \
+ pam_authtok_store.5 \
+ pam_deny.5 \
+ pam_dhkeys.5 \
+ pam_dial_auth.5 \
+ pam_krb5.5 \
+ pam_krb5_migrate.5 \
+ pam_ldap.5 \
+ pam_list.5 \
+ pam_passwd_auth.5 \
+ pam_rhosts_auth.5 \
+ pam_roles.5 \
+ pam_sample.5 \
+ pam_smb_passwd.5 \
+ pam_smbfs_login.5 \
+ pam_tsol_account.5 \
+ pam_unix_account.5 \
+ pam_unix_auth.5 \
+ pam_unix_cred.5 \
+ pam_unix_session.5 \
+ pkcs11_kernel.5 \
+ pkcs11_softtoken.5 \
+ pkcs11_tpm.5 \
+ privileges.5 \
+ prof.5 \
+ rbac.5 \
+ regex.5 \
+ regexp.5 \
+ resource_controls.5 \
+ smf.5 \
+ smf_bootstrap.5 \
+ smf_method.5 \
+ smf_restarter.5 \
+ smf_security.5 \
+ smf_template.5 \
+ standards.5 \
+ sticky.5 \
+ tecla.5 \
+ term.5 \
+ threads.5 \
+ trusted_extensions.5 \
+ vgrindefs.5 \
+ zones.5 \
+ zpool-features.5
MANSOFILES = ANSI.5 \
C++.5 \
diff --git a/usr/src/man/man5/zpool-features.5 b/usr/src/man/man5/zpool-features.5
new file mode 100644
index 0000000000..3c1930c35a
--- /dev/null
+++ b/usr/src/man/man5/zpool-features.5
@@ -0,0 +1,173 @@
+'\" te
+.\" Copyright (c) 2012 by Delphix. All rights reserved.
+.\" The contents of this file are subject to the terms of the Common Development
+.\" and Distribution License (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]
+.TH ZPOOL-FEATURES 5 "Mar 16, 2012"
+.SH NAME
+zpool\-features \- ZFS pool feature descriptions
+.SH DESCRIPTION
+.sp
+.LP
+ZFS pool on\-disk format versions are specified via "features" which replace
+the old on\-disk format numbers (the last supported on\-disk format number is
+28). To enable a feature on a pool use the \fBupgrade\fR subcommand of the
+\fBzpool\fR(1M) command, or set the \fBfeature@\fR\fIfeature_name\fR property
+to \fBenabled\fR.
+.sp
+.LP
+The pool format does not affect file system version compatibility or the ability
+to send file systems between pools.
+.sp
+.LP
+Since most features can be enabled independently of each other the on\-disk
+format of the pool is specified by the set of all features marked as
+\fBactive\fR on the pool. If the pool was created by another software version
+this set may include unsupported features.
+.SS "Identifying features"
+.sp
+.LP
+Every feature has a guid of the form \fIcom.example:feature_name\fR. The reverse
+DNS name ensures that the feature's guid is unique across all ZFS
+implementations. When unsupported features are encountered on a pool they will
+be identified by their guids. Refer to the documentation for the ZFS
+implementation that created the pool for information about those features.
+.sp
+.LP
+Each supported feature also has a short name. By convention a feature's short
+name is the portion of its guid which follows the ':' (e.g.
+\fIcom.example:feature_name\fR would have the short name \fIfeature_name\fR),
+however a feature's short name may differ across ZFS implementations if
+following the convention would result in name conflicts.
+.SS "Feature states"
+.sp
+.LP
+Features can be in one of three states:
+.sp
+.ne 2
+.na
+\fB\fBactive\fR\fR
+.ad
+.RS 12n
+This feature's on\-disk format changes are in effect on the pool. Support for
+this feature is required to import the pool in read\-write mode. If this
+feature is not read-only compatible, support is also required to import the pool
+in read\-only mode (see "Read\-only compatibility").
+.RE
+
+.sp
+.ne 2
+.na
+\fB\fBenabled\fR\fR
+.ad
+.RS 12n
+An administrator has marked this feature as enabled on the pool, but the
+feature's on\-disk format changes have not been made yet. The pool can still be
+imported by software that does not support this feature, but changes may be made
+to the on\-disk format at any time which will move the feature to the
+\fBactive\fR state. Some features may support returning to the \fBenabled\fR
+state after becoming \fBactive\fR. See feature\-specific documentation for
+details.
+.RE
+
+.sp
+.ne 2
+.na
+\fBdisabled\fR
+.ad
+.RS 12n
+This feature's on\-disk format changes have not been made and will not be made
+unless an administrator moves the feature to the \fBenabled\fR state. Features
+cannot be disabled once they have been enabled.
+.RE
+
+.sp
+.LP
+The state of supported features is exposed through pool properties of the form
+\fIfeature@short_name\fR.
+.SS "Read\-only compatibility"
+.sp
+.LP
+Some features may make on\-disk format changes that do not interfere with other
+software's ability to read from the pool. These features are referred to as
+"read\-only compatible". If all unsupported features on a pool are read\-only
+compatible, the pool can be imported in read\-only mode by setting the
+\fBreadonly\fR property during import (see \fBzpool\fR(1M) for details on
+importing pools).
+.SS "Unsupported features"
+.sp
+.LP
+For each unsupported feature enabled on an imported pool a pool property
+named \fIunsupported@feature_guid\fR will indicate why the import was allowed
+despite the unsupported feature. Possible values for this property are:
+
+.sp
+.ne 2
+.na
+\fB\fBinactive\fR\fR
+.ad
+.RS 12n
+The feature is in the \fBenabled\fR state and therefore the pool's on\-disk
+format is still compatible with software that does not support this feature.
+.RE
+
+.sp
+.ne 2
+.na
+\fB\fBreadonly\fR\fR
+.ad
+.RS 12n
+The feature is read\-only compatible and the pool has been imported in
+read\-only mode.
+.RE
+
+.SS "Feature dependencies"
+.sp
+.LP
+Some features depend on other features being enabled in order to function
+properly. Enabling a feature will automatically enable any features it
+depends on.
+.SH FEATURES
+.sp
+.LP
+The following features are supported on this system:
+.sp
+.ne 2
+.na
+\fB\fBasync_destroy\fR\fR
+.ad
+.RS 4n
+.TS
+l l .
+GUID com.delphix:async_destroy
+READ\-ONLY COMPATIBLE yes
+DEPENDENCIES none
+.TE
+
+Destroying a file system requires traversing all of its data in order to
+return its used space to the pool. Without \fBasync_destroy\fR the file system
+is not fully removed until all space has been reclaimed. If the destroy
+operation is interrupted by a reboot or power outage the next attempt to open
+the pool will need to complete the destroy operation synchronously.
+
+When \fBasync_destroy\fR is enabled the file system's data will be reclaimed
+by a background process, allowing the destroy operation to complete without
+traversing the entire file system. The background process is able to resume
+interrupted destroys after the pool has been opened, eliminating the need
+to finish interrupted destroys as part of the open operation. The amount
+of space remaining to be reclaimed by the background process is available
+through the \fBfreeing\fR property.
+
+This feature is only \fBactive\fR while \fBfreeing\fR is non\-zero.
+.RE
+.SH "SEE ALSO"
+\fBzpool\fR(1M)
diff --git a/usr/src/pkg/manifests/SUNWarbel.mf b/usr/src/pkg/manifests/SUNWarbel.mf
index f28062f9e5..c847d3a2a6 100644
--- a/usr/src/pkg/manifests/SUNWarbel.mf
+++ b/usr/src/pkg/manifests/SUNWarbel.mf
@@ -23,7 +23,8 @@
# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
#
-set name=pkg.fmri value=pkg:/SUNWarbel@0.5.11,5.11-0.133
-set name=pkg.renamed value=true
+# Was renamed to pkg:/driver/network/arbel, both are obsolete.
+# This is made obsolete at $(PKGVERS) to match it.
+set name=pkg.fmri value=pkg:/SUNWarbel@$(PKGVERS)
+set name=pkg.obsolete value=true
set name=variant.arch value=$(ARCH)
-depend fmri=pkg:/driver/network/arbel@0.5.11,5.11-0.133 type=require
diff --git a/usr/src/pkg/manifests/SUNWcs.man1m.inc b/usr/src/pkg/manifests/SUNWcs.man1m.inc
index a3061fbf19..2b3792e569 100644
--- a/usr/src/pkg/manifests/SUNWcs.man1m.inc
+++ b/usr/src/pkg/manifests/SUNWcs.man1m.inc
@@ -10,6 +10,7 @@
#
# Copyright 2011, Richard Lowe
+# Copyright 2012 Nexenta Systems, Inc. All rights reserved.
file path=usr/share/man/man1m/6to4relay.1m
file path=usr/share/man/man1m/Intro.1m
@@ -138,7 +139,6 @@ file path=usr/share/man/man1m/ipmpstat.1m
file path=usr/share/man/man1m/ipsecalgs.1m
file path=usr/share/man/man1m/ipsecconf.1m
file path=usr/share/man/man1m/ipseckey.1m
-file path=usr/share/man/man1m/itu.1m
file path=usr/share/man/man1m/keyserv.1m
file path=usr/share/man/man1m/killall.1m
file path=usr/share/man/man1m/ksslcfg.1m
@@ -155,7 +155,6 @@ file path=usr/share/man/man1m/logadm.1m
file path=usr/share/man/man1m/logins.1m
file path=usr/share/man/man1m/mail.local.1m
file path=usr/share/man/man1m/makedbm.1m
-file path=usr/share/man/man1m/mkbootmedia.1m
file path=usr/share/man/man1m/mkdevalloc.1m
file path=usr/share/man/man1m/mkdevmaps.1m
file path=usr/share/man/man1m/mkfile.1m
@@ -186,7 +185,6 @@ file path=usr/share/man/man1m/nscd.1m
file path=usr/share/man/man1m/nwamd.1m
file path=usr/share/man/man1m/passmgmt.1m
file path=usr/share/man/man1m/pbind.1m
-file path=usr/share/man/man1m/pkg2du.1m
file path=usr/share/man/man1m/pmadm.1m
file path=usr/share/man/man1m/ports.1m
file path=usr/share/man/man1m/poweroff.1m
@@ -278,7 +276,6 @@ file path=usr/share/man/man1m/unshare.1m
file path=usr/share/man/man1m/unshare_nfs.1m
file path=usr/share/man/man1m/unshareall.1m
file path=usr/share/man/man1m/update_drv.1m
-file path=usr/share/man/man1m/updatemedia.1m
file path=usr/share/man/man1m/useradd.1m
file path=usr/share/man/man1m/userdel.1m
file path=usr/share/man/man1m/usermod.1m
diff --git a/usr/src/pkg/manifests/SUNWcs.mf b/usr/src/pkg/manifests/SUNWcs.mf
index c3426243c6..81c40c9aed 100644
--- a/usr/src/pkg/manifests/SUNWcs.mf
+++ b/usr/src/pkg/manifests/SUNWcs.mf
@@ -21,7 +21,7 @@
#
# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
-# Copyright 2011 Nexenta Systems, Inc. All rights reserved.
+# Copyright 2012 Nexenta Systems, Inc. All rights reserved.
#
<include SUNWcs.man1.inc>
@@ -785,7 +785,6 @@ file path=usr/bin/infocmp mode=0555
file path=usr/bin/iostat mode=0555
file path=usr/bin/isainfo mode=0555
file path=usr/bin/isalist mode=0555
-file path=usr/bin/itu mode=0555
file path=usr/bin/kbd mode=0555
file path=usr/bin/keylogin mode=0555
file path=usr/bin/keylogout mode=0555
@@ -805,7 +804,6 @@ file path=usr/bin/mail group=mail mode=2511
file path=usr/bin/mailx group=mail mode=2511
file path=usr/bin/makedev mode=0555
file path=usr/bin/mesg mode=0555
-file path=usr/bin/mkbootmedia mode=0555
file path=usr/bin/mkdir mode=0555
file path=usr/bin/mkpwdict mode=0555
file path=usr/bin/mktemp mode=0555
@@ -824,7 +822,6 @@ file path=usr/bin/pax mode=0555
file path=usr/bin/pfexec mode=0555
file path=usr/bin/pg mode=0555
file path=usr/bin/pgrep mode=0555
-file path=usr/bin/pkg2du mode=0555
file path=usr/bin/pktool mode=0555
file path=usr/bin/pr mode=0555
file path=usr/bin/printf mode=0555
@@ -863,7 +860,6 @@ file path=usr/bin/tr mode=0555
file path=usr/bin/true mode=0555
file path=usr/bin/tty mode=0555
file path=usr/bin/tzselect mode=0555
-file path=usr/bin/updatemedia mode=0555
file path=usr/bin/userattr mode=0555
file path=usr/bin/vmstat mode=0555
file path=usr/bin/which mode=0555
diff --git a/usr/src/pkg/manifests/driver-network-arbel.mf b/usr/src/pkg/manifests/driver-network-arbel.mf
index 7b78dfda33..74aa9065c8 100644
--- a/usr/src/pkg/manifests/driver-network-arbel.mf
+++ b/usr/src/pkg/manifests/driver-network-arbel.mf
@@ -30,13 +30,5 @@
#
<include global_zone_only_component>
set name=pkg.fmri value=pkg:/driver/network/arbel@$(PKGVERS)
-set name=pkg.description value="Arbel HCA Driver"
-set name=pkg.summary value="Sun IB Arbel HCA driver"
-set name=info.classification \
- value="org.opensolaris.category.2008:Drivers/Other Peripherals"
+set name=pkg.obsolete value=true
set name=variant.arch value=$(ARCH)
-dir path=kernel group=sys
-dir path=kernel/drv group=sys
-dir path=kernel/drv/$(ARCH64) group=sys
-legacy pkg=SUNWarbel desc="Arbel HCA Driver" name="Sun IB Arbel HCA driver"
-license cr_Sun license=cr_Sun
diff --git a/usr/src/pkg/manifests/driver-network-ixgbe.mf b/usr/src/pkg/manifests/driver-network-ixgbe.mf
index 5da492ee16..2923f246fe 100644
--- a/usr/src/pkg/manifests/driver-network-ixgbe.mf
+++ b/usr/src/pkg/manifests/driver-network-ixgbe.mf
@@ -59,7 +59,9 @@ driver name=ixgbe clone_perms="ixgbe 0666 root sys" perms="* 0666 root sys" \
alias=pciex8086,150b \
alias=pciex8086,1514 \
alias=pciex8086,1517 \
- alias=pciex8086,151c
+ alias=pciex8086,151c \
+ alias=pciex8086,154d \
+ alias=pciex8086,1557
file path=kernel/drv/$(ARCH64)/ixgbe group=sys
$(i386_ONLY)file path=kernel/drv/ixgbe group=sys
file path=kernel/drv/ixgbe.conf group=sys \
diff --git a/usr/src/pkg/manifests/driver-network-yge.mf b/usr/src/pkg/manifests/driver-network-yge.mf
index c50fe92e7f..f2e1d07eb0 100644
--- a/usr/src/pkg/manifests/driver-network-yge.mf
+++ b/usr/src/pkg/manifests/driver-network-yge.mf
@@ -42,6 +42,7 @@ dir path=kernel/drv/$(ARCH64) group=sys
dir path=usr/share/man
dir path=usr/share/man/man7d
driver name=yge perms="* 0666 root sys" \
+ alias=pciex1148,9e00 \
alias=pciex1186,4b00 \
alias=pciex11ab,4354 \
alias=pciex11ab,4355 \
diff --git a/usr/src/pkg/manifests/driver-serial-usbftdi.mf b/usr/src/pkg/manifests/driver-serial-usbftdi.mf
index 6b563308e9..2a248dc611 100644
--- a/usr/src/pkg/manifests/driver-serial-usbftdi.mf
+++ b/usr/src/pkg/manifests/driver-serial-usbftdi.mf
@@ -63,7 +63,8 @@ driver name=usbftdi perms="* 0666 root sys" \
alias=usb7cc,0421 \
alias=usb856,ac01 \
alias=usb93c,0601 \
- alias=usb93c,0701
+ alias=usb93c,0701 \
+ alias=usbif9e88,9e8f.config1.1
file path=kernel/drv/$(ARCH64)/usbftdi group=sys
$(i386_ONLY)file path=kernel/drv/usbftdi group=sys
file path=kernel/drv/usbftdi.conf group=sys \
diff --git a/usr/src/pkg/manifests/service-file-system-nfs.mf b/usr/src/pkg/manifests/service-file-system-nfs.mf
index afe0eb83c2..7b7e89eacf 100644
--- a/usr/src/pkg/manifests/service-file-system-nfs.mf
+++ b/usr/src/pkg/manifests/service-file-system-nfs.mf
@@ -21,6 +21,7 @@
#
# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright 2012 Nexenta Systems, Inc. All rights reserved.
#
set name=pkg.fmri value=pkg:/service/file-system/nfs@$(PKGVERS)
@@ -62,6 +63,7 @@ file path=etc/nfs/nfslog.conf group=sys \
original_name=SUNWnfss:etc/nfs/nfslog.conf preserve=true
file path=kernel/misc/$(ARCH64)/nfssrv group=sys mode=0755
$(i386_ONLY)file path=kernel/misc/nfssrv group=sys mode=0755
+file path=lib/svc/manifest/network/nfs/nfslogd.xml group=sys mode=0444
file path=lib/svc/manifest/network/nfs/rquota.xml group=sys mode=0444
file path=lib/svc/manifest/network/nfs/server.xml group=sys mode=0444
file path=lib/svc/method/nfs-server mode=0555
diff --git a/usr/src/pkg/manifests/system-dtrace-tests.mf b/usr/src/pkg/manifests/system-dtrace-tests.mf
index f609e2793a..8b58c5a342 100644
--- a/usr/src/pkg/manifests/system-dtrace-tests.mf
+++ b/usr/src/pkg/manifests/system-dtrace-tests.mf
@@ -21,7 +21,7 @@
#
# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
-# Copyright (c) 2011 by Delphix. All rights reserved.
+# Copyright (c) 2012 by Delphix. All rights reserved.
#
set name=pkg.fmri value=pkg:/system/dtrace/tests@$(PKGVERS)
@@ -52,6 +52,7 @@ dir path=opt/SUNWdtrt/tst/common/begin
dir path=opt/SUNWdtrt/tst/common/bitfields
dir path=opt/SUNWdtrt/tst/common/buffering
dir path=opt/SUNWdtrt/tst/common/builtinvar
+dir path=opt/SUNWdtrt/tst/common/cg
dir path=opt/SUNWdtrt/tst/common/clauses
dir path=opt/SUNWdtrt/tst/common/cpc
dir path=opt/SUNWdtrt/tst/common/decls
@@ -59,6 +60,7 @@ dir path=opt/SUNWdtrt/tst/common/drops
dir path=opt/SUNWdtrt/tst/common/dtraceUtil
dir path=opt/SUNWdtrt/tst/common/end
dir path=opt/SUNWdtrt/tst/common/enum
+dir path=opt/SUNWdtrt/tst/common/env
dir path=opt/SUNWdtrt/tst/common/error
dir path=opt/SUNWdtrt/tst/common/exit
dir path=opt/SUNWdtrt/tst/common/fbtprovider
@@ -333,6 +335,8 @@ file path=opt/SUNWdtrt/tst/common/aggs/tst.signedkeys.d mode=0444
file path=opt/SUNWdtrt/tst/common/aggs/tst.signedkeys.d.out mode=0444
file path=opt/SUNWdtrt/tst/common/aggs/tst.signedkeyspos.d mode=0444
file path=opt/SUNWdtrt/tst/common/aggs/tst.signedkeyspos.d.out mode=0444
+file path=opt/SUNWdtrt/tst/common/aggs/tst.sizedkeys.d mode=0444
+file path=opt/SUNWdtrt/tst/common/aggs/tst.sizedkeys.d.out mode=0444
file path=opt/SUNWdtrt/tst/common/aggs/tst.stddev.d mode=0444
file path=opt/SUNWdtrt/tst/common/aggs/tst.stddev.d.out mode=0444
file path=opt/SUNWdtrt/tst/common/aggs/tst.subr.d mode=0444
@@ -357,7 +361,14 @@ file path=opt/SUNWdtrt/tst/common/arithmetic/err.D_SYNTAX.divmin.d mode=0444
file path=opt/SUNWdtrt/tst/common/arithmetic/err.D_SYNTAX.muladd.d mode=0444
file path=opt/SUNWdtrt/tst/common/arithmetic/err.D_SYNTAX.muldiv.d mode=0444
file path=opt/SUNWdtrt/tst/common/arithmetic/tst.basics.d mode=0444
-file path=opt/SUNWdtrt/tst/common/arithmetic/tst.complex.d mode=0444
+file path=opt/SUNWdtrt/tst/common/arithmetic/tst.basics.d.out mode=0444
+file path=opt/SUNWdtrt/tst/common/arithmetic/tst.compcast.d mode=0444
+file path=opt/SUNWdtrt/tst/common/arithmetic/tst.compcast.d.out mode=0444
+file path=opt/SUNWdtrt/tst/common/arithmetic/tst.compnarrowassign.d mode=0444
+file path=opt/SUNWdtrt/tst/common/arithmetic/tst.compnarrowassign.d.out \
+ mode=0444
+file path=opt/SUNWdtrt/tst/common/arithmetic/tst.execcast.d mode=0444
+file path=opt/SUNWdtrt/tst/common/arithmetic/tst.execcast.d.out mode=0444
file path=opt/SUNWdtrt/tst/common/arrays/err.D_ARR_BADREF.bad.d mode=0444
file path=opt/SUNWdtrt/tst/common/arrays/err.D_DECL_ARRBIG.toobig.d mode=0444
file path=opt/SUNWdtrt/tst/common/arrays/err.D_DECL_ARRNULL.bad.d mode=0444
@@ -474,6 +485,8 @@ file path=opt/SUNWdtrt/tst/common/builtinvar/tst.tid.d mode=0444
file path=opt/SUNWdtrt/tst/common/builtinvar/tst.tid1.d mode=0444
file path=opt/SUNWdtrt/tst/common/builtinvar/tst.timestamp.d mode=0444
file path=opt/SUNWdtrt/tst/common/builtinvar/tst.vtimestamp.d mode=0444
+file path=opt/SUNWdtrt/tst/common/cg/err.D_NOREG.noreg.d mode=0444
+file path=opt/SUNWdtrt/tst/common/cg/err.baddif.d mode=0444
file path=opt/SUNWdtrt/tst/common/clauses/err.D_IDENT_UNDEF.aggfun.d mode=0444
file path=opt/SUNWdtrt/tst/common/clauses/err.D_IDENT_UNDEF.aggtup.d mode=0444
file path=opt/SUNWdtrt/tst/common/clauses/err.D_IDENT_UNDEF.arrtup.d mode=0444
@@ -720,6 +733,20 @@ file path=opt/SUNWdtrt/tst/common/enum/err.D_UNKNOWN.RepeatIdentifiers.d \
file path=opt/SUNWdtrt/tst/common/enum/tst.EnumEquality.d mode=0444
file path=opt/SUNWdtrt/tst/common/enum/tst.EnumSameValue.d mode=0444
file path=opt/SUNWdtrt/tst/common/enum/tst.EnumValAssign.d mode=0444
+file path=opt/SUNWdtrt/tst/common/env/err.D_PRAGMA_OPTSET.setfromscript.d \
+ mode=0444
+file path=opt/SUNWdtrt/tst/common/env/err.D_PRAGMA_OPTSET.unsetfromscript.d \
+ mode=0444
+file path=opt/SUNWdtrt/tst/common/env/tst.ld_nolazyload.ksh mode=0444
+file path=opt/SUNWdtrt/tst/common/env/tst.ld_nolazyload.ksh.out mode=0444
+file path=opt/SUNWdtrt/tst/common/env/tst.setenv1.ksh mode=0444
+file path=opt/SUNWdtrt/tst/common/env/tst.setenv1.ksh.out mode=0444
+file path=opt/SUNWdtrt/tst/common/env/tst.setenv2.ksh mode=0444
+file path=opt/SUNWdtrt/tst/common/env/tst.setenv2.ksh.out mode=0444
+file path=opt/SUNWdtrt/tst/common/env/tst.unsetenv1.ksh mode=0444
+file path=opt/SUNWdtrt/tst/common/env/tst.unsetenv1.ksh.out mode=0444
+file path=opt/SUNWdtrt/tst/common/env/tst.unsetenv2.ksh mode=0444
+file path=opt/SUNWdtrt/tst/common/env/tst.unsetenv2.ksh.out mode=0444
file path=opt/SUNWdtrt/tst/common/error/tst.DTRACEFLT_BADADDR.d mode=0444
file path=opt/SUNWdtrt/tst/common/error/tst.DTRACEFLT_DIVZERO.d mode=0444
file path=opt/SUNWdtrt/tst/common/error/tst.DTRACEFLT_UNKNOWN.d mode=0444
@@ -1153,6 +1180,8 @@ file path=opt/SUNWdtrt/tst/common/pointers/tst.PointerAssignment.d mode=0444
file path=opt/SUNWdtrt/tst/common/pointers/tst.ValidPointer1.d mode=0444
file path=opt/SUNWdtrt/tst/common/pointers/tst.ValidPointer2.d mode=0444
file path=opt/SUNWdtrt/tst/common/pointers/tst.VoidCast.d mode=0444
+file path=opt/SUNWdtrt/tst/common/pointers/tst.assigncast1.d mode=0444
+file path=opt/SUNWdtrt/tst/common/pointers/tst.assigncast2.d mode=0444
file path=opt/SUNWdtrt/tst/common/pointers/tst.basic1.d mode=0444
file path=opt/SUNWdtrt/tst/common/pointers/tst.basic2.d mode=0444
file path=opt/SUNWdtrt/tst/common/pragma/err.D_PRAGERR.d mode=0444
@@ -1168,6 +1197,9 @@ file path=opt/SUNWdtrt/tst/common/pragma/tst.libdep.ksh mode=0444
file path=opt/SUNWdtrt/tst/common/pragma/tst.libdepfullyconnected.ksh \
mode=0444
file path=opt/SUNWdtrt/tst/common/pragma/tst.libdepsepdir.ksh mode=0444
+file path=opt/SUNWdtrt/tst/common/pragma/tst.temporal.ksh mode=0444
+file path=opt/SUNWdtrt/tst/common/pragma/tst.temporal2.ksh mode=0444
+file path=opt/SUNWdtrt/tst/common/pragma/tst.temporal3.d mode=0444
file path=opt/SUNWdtrt/tst/common/predicates/err.D_PRED_SCALAR.NonScalarPred.d \
mode=0444
file path=opt/SUNWdtrt/tst/common/predicates/err.D_SYNTAX.invalid.d mode=0444
@@ -1177,7 +1209,6 @@ file path=opt/SUNWdtrt/tst/common/predicates/tst.basics.d mode=0444
file path=opt/SUNWdtrt/tst/common/predicates/tst.basics.d.out mode=0444
file path=opt/SUNWdtrt/tst/common/predicates/tst.complex.d mode=0444
file path=opt/SUNWdtrt/tst/common/predicates/tst.complex.d.out mode=0444
-file path=opt/SUNWdtrt/tst/common/predicates/tst.predcache.ksh mode=0444
file path=opt/SUNWdtrt/tst/common/preprocessor/err.D_IDENT_UNDEF.afterprobe.d \
mode=0444
file path=opt/SUNWdtrt/tst/common/preprocessor/err.D_PRAGCTL_INVAL.tabdefine.d \
@@ -1222,17 +1253,19 @@ file path=opt/SUNWdtrt/tst/common/preprocessor/tst.preexpifelse.d mode=0444
file path=opt/SUNWdtrt/tst/common/preprocessor/tst.preexpifelse.d.out \
mode=0444
file path=opt/SUNWdtrt/tst/common/preprocessor/tst.withinprobe.d mode=0444
-file path=opt/SUNWdtrt/tst/common/print/err.D_PRINT_DYN.bad.d mode=0444
file path=opt/SUNWdtrt/tst/common/print/err.D_PRINT_VOID.bad.d mode=0444
file path=opt/SUNWdtrt/tst/common/print/err.D_PROTO_LEN.bad.d mode=0444
file path=opt/SUNWdtrt/tst/common/print/tst.array.d mode=0444
file path=opt/SUNWdtrt/tst/common/print/tst.array.d.out mode=0444
file path=opt/SUNWdtrt/tst/common/print/tst.bitfield.d mode=0444
file path=opt/SUNWdtrt/tst/common/print/tst.bitfield.d.out mode=0444
+file path=opt/SUNWdtrt/tst/common/print/tst.dyn.d mode=0444
file path=opt/SUNWdtrt/tst/common/print/tst.primitive.d mode=0444
file path=opt/SUNWdtrt/tst/common/print/tst.primitive.d.out mode=0444
file path=opt/SUNWdtrt/tst/common/print/tst.struct.d mode=0444
file path=opt/SUNWdtrt/tst/common/print/tst.struct.d.out mode=0444
+file path=opt/SUNWdtrt/tst/common/print/tst.xlate.d mode=0444
+file path=opt/SUNWdtrt/tst/common/print/tst.xlate.d.out mode=0444
file path=opt/SUNWdtrt/tst/common/printa/err.D_PRINTA_AGGARG.badagg.d \
mode=0444
file path=opt/SUNWdtrt/tst/common/printa/err.D_PRINTA_AGGARG.badfmt.d \
@@ -1313,6 +1346,8 @@ file path=opt/SUNWdtrt/tst/common/printf/tst.printgG.d mode=0444
file path=opt/SUNWdtrt/tst/common/printf/tst.printgG.d.out mode=0444
file path=opt/SUNWdtrt/tst/common/printf/tst.rawfmt.d mode=0444
file path=opt/SUNWdtrt/tst/common/printf/tst.rawfmt.d.out mode=0444
+file path=opt/SUNWdtrt/tst/common/printf/tst.signs.d mode=0444
+file path=opt/SUNWdtrt/tst/common/printf/tst.signs.d.out mode=0444
file path=opt/SUNWdtrt/tst/common/printf/tst.str.d mode=0444
file path=opt/SUNWdtrt/tst/common/printf/tst.str.d.out mode=0444
file path=opt/SUNWdtrt/tst/common/printf/tst.sym.d mode=0444
@@ -1766,8 +1801,8 @@ file path=opt/SUNWdtrt/tst/common/tick-n/tst.tickus.d.out mode=0444
file path=opt/SUNWdtrt/tst/common/tick-n/tst.tickusec.d mode=0444
file path=opt/SUNWdtrt/tst/common/tick-n/tst.tickusec.d.out mode=0444
file path=opt/SUNWdtrt/tst/common/trace/err.D_PROTO_LEN.bad.d mode=0444
-file path=opt/SUNWdtrt/tst/common/trace/err.D_TRACE_DYN.bad.d mode=0444
file path=opt/SUNWdtrt/tst/common/trace/err.D_TRACE_VOID.bad.d mode=0444
+file path=opt/SUNWdtrt/tst/common/trace/tst.dyn.d mode=0444
file path=opt/SUNWdtrt/tst/common/trace/tst.misc.d mode=0444
file path=opt/SUNWdtrt/tst/common/trace/tst.qstring.d mode=0444
file path=opt/SUNWdtrt/tst/common/trace/tst.qstring.d.out mode=0444
@@ -1838,6 +1873,14 @@ file path=opt/SUNWdtrt/tst/common/translators/tst.SimultaneousTranslators.d \
mode=0444
file path=opt/SUNWdtrt/tst/common/translators/tst.StructureAssignment.d \
mode=0444
+file path=opt/SUNWdtrt/tst/common/translators/tst.TestTransStability1.ksh \
+ mode=0444
+file path=opt/SUNWdtrt/tst/common/translators/tst.TestTransStability1.ksh.out \
+ mode=0444
+file path=opt/SUNWdtrt/tst/common/translators/tst.TestTransStability2.ksh \
+ mode=0444
+file path=opt/SUNWdtrt/tst/common/translators/tst.TestTransStability2.ksh.out \
+ mode=0444
file path=opt/SUNWdtrt/tst/common/translators/tst.TransNonPointer.d mode=0444
file path=opt/SUNWdtrt/tst/common/translators/tst.TransOutputPointer.d \
mode=0444
diff --git a/usr/src/pkg/manifests/system-file-system-zfs-tests.mf b/usr/src/pkg/manifests/system-file-system-zfs-tests.mf
index a0f2eef596..a9afe1fa0b 100644
--- a/usr/src/pkg/manifests/system-file-system-zfs-tests.mf
+++ b/usr/src/pkg/manifests/system-file-system-zfs-tests.mf
@@ -21,6 +21,7 @@
#
# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2012 by Delphix. All rights reserved.
#
set name=pkg.fmri value=pkg:/system/file-system/zfs/tests@$(PKGVERS)
@@ -55,10 +56,13 @@ file path=usr/bin/$(ARCH64)/zlook mode=0555
file path=usr/bin/$(ARCH64)/ztest mode=0555
file path=usr/include/sys/fs/zut.h
file path=usr/lib/devfsadm/linkmod/SUNW_zut_link.so group=sys
+$(i386_ONLY)file path=usr/sbin/$(ARCH32)/zhack mode=0555
$(i386_ONLY)file path=usr/sbin/$(ARCH32)/zinject mode=0555
+file path=usr/sbin/$(ARCH64)/zhack mode=0555
file path=usr/sbin/$(ARCH64)/zinject mode=0555
hardlink path=usr/bin/zlook target=../../usr/lib/isaexec
hardlink path=usr/bin/ztest target=../../usr/lib/isaexec
+hardlink path=usr/sbin/zhack target=../../usr/lib/isaexec
hardlink path=usr/sbin/zinject target=../../usr/lib/isaexec
legacy pkg=SUNWonzfs desc="ZFS test commands" name="ZFS unbundled utilities"
legacy pkg=SUNWonzfsr desc="ZFS test driver" name="ZFS unbundled driver"
diff --git a/usr/src/pkg/manifests/system-file-system-zfs.mf b/usr/src/pkg/manifests/system-file-system-zfs.mf
index f7f4412803..315d6f2415 100644
--- a/usr/src/pkg/manifests/system-file-system-zfs.mf
+++ b/usr/src/pkg/manifests/system-file-system-zfs.mf
@@ -21,6 +21,7 @@
#
# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2012 by Delphix. All rights reserved.
#
set name=pkg.fmri value=pkg:/system/file-system/zfs@$(PKGVERS)
@@ -84,10 +85,15 @@ file path=kernel/drv/zfs.conf group=sys
file path=kernel/kmdb/$(ARCH64)/zfs group=sys mode=0555
$(i386_ONLY)file path=kernel/kmdb/zfs group=sys mode=0555
file path=lib/$(ARCH64)/libzfs.so.1
+file path=lib/$(ARCH64)/libzfs_core.so.1
file path=lib/$(ARCH64)/llib-lzfs.ln
+file path=lib/$(ARCH64)/llib-lzfs_core.ln
file path=lib/libzfs.so.1
+file path=lib/libzfs_core.so.1
file path=lib/llib-lzfs
file path=lib/llib-lzfs.ln
+file path=lib/llib-lzfs_core
+file path=lib/llib-lzfs_core.ln
file path=sbin/zfs mode=0555
file path=sbin/zpool mode=0555
file path=usr/lib/$(ARCH64)/libzfs_jni.so.1
@@ -131,6 +137,7 @@ file path=usr/share/man/man1m/zdb.1m
file path=usr/share/man/man1m/zfs.1m
file path=usr/share/man/man1m/zpool.1m
file path=usr/share/man/man1m/zstreamdump.1m
+file path=usr/share/man/man5/zpool-features.5
hardlink path=kernel/fs/$(ARCH64)/zfs target=../../../kernel/drv/$(ARCH64)/zfs
$(i386_ONLY)hardlink path=kernel/fs/zfs target=../../kernel/drv/zfs
hardlink path=usr/lib/fs/zfs/fstyp target=../../../sbin/fstyp
@@ -144,23 +151,35 @@ license lic_CDDL license=lic_CDDL
link path=etc/fs/zfs/mount target=../../../sbin/zfs
link path=etc/fs/zfs/umount target=../../../sbin/zfs
link path=lib/$(ARCH64)/libzfs.so target=libzfs.so.1
+link path=lib/$(ARCH64)/libzfs_core.so target=libzfs_core.so.1
link path=lib/libzfs.so target=libzfs.so.1
+link path=lib/libzfs_core.so target=libzfs_core.so.1
link path=usr/lib/$(ARCH64)/libzfs.so \
target=../../../lib/$(ARCH64)/libzfs.so.1
link path=usr/lib/$(ARCH64)/libzfs.so.1 \
target=../../../lib/$(ARCH64)/libzfs.so.1
+link path=usr/lib/$(ARCH64)/libzfs_core.so \
+ target=../../../lib/$(ARCH64)/libzfs_core.so.1
+link path=usr/lib/$(ARCH64)/libzfs_core.so.1 \
+ target=../../../lib/$(ARCH64)/libzfs_core.so.1
link path=usr/lib/$(ARCH64)/libzfs_jni.so target=libzfs_jni.so.1
link path=usr/lib/$(ARCH64)/libzpool.so target=libzpool.so.1
link path=usr/lib/$(ARCH64)/llib-lzfs.ln \
target=../../../lib/$(ARCH64)/llib-lzfs.ln
+link path=usr/lib/$(ARCH64)/llib-lzfs_core.ln \
+ target=../../../lib/$(ARCH64)/llib-lzfs_core.ln
link path=usr/lib/fs/zfs/mount target=../../../../sbin/zfs
link path=usr/lib/fs/zfs/umount target=../../../../sbin/zfs
link path=usr/lib/libzfs.so target=../../lib/libzfs.so.1
link path=usr/lib/libzfs.so.1 target=../../lib/libzfs.so.1
+link path=usr/lib/libzfs_core.so target=../../lib/libzfs_core.so.1
+link path=usr/lib/libzfs_core.so.1 target=../../lib/libzfs_core.so.1
link path=usr/lib/libzfs_jni.so target=libzfs_jni.so.1
$(i386_ONLY)link path=usr/lib/libzpool.so target=libzpool.so.1
link path=usr/lib/llib-lzfs target=../../lib/llib-lzfs
link path=usr/lib/llib-lzfs.ln target=../../lib/llib-lzfs.ln
+link path=usr/lib/llib-lzfs_core target=../../lib/llib-lzfs_core
+link path=usr/lib/llib-lzfs_core.ln target=../../lib/llib-lzfs_core.ln
link path=usr/sbin/zfs target=../../sbin/zfs
link path=usr/sbin/zpool target=../../sbin/zpool
depend fmri=runtime/python-26 type=require
diff --git a/usr/src/pkg/manifests/system-header.mf b/usr/src/pkg/manifests/system-header.mf
index ddc527f31b..baffee6182 100644
--- a/usr/src/pkg/manifests/system-header.mf
+++ b/usr/src/pkg/manifests/system-header.mf
@@ -22,6 +22,7 @@
#
# Copyright 2011 Nexenta Systems, Inc. All rights reserved.
# Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+# Copyright (c) 2012 by Delphix. All rights reserved.
#
set name=pkg.fmri value=pkg:/system/header@$(PKGVERS)
@@ -505,6 +506,7 @@ file path=usr/include/libtsnet.h
$(sparc_ONLY)file path=usr/include/libv12n.h
file path=usr/include/libw.h
file path=usr/include/libzfs.h
+file path=usr/include/libzfs_core.h
file path=usr/include/libzoneinfo.h
file path=usr/include/limits.h
file path=usr/include/linenum.h
diff --git a/usr/src/pkg/manifests/system-library.mf b/usr/src/pkg/manifests/system-library.mf
index 846962beac..86fa0e29f7 100644
--- a/usr/src/pkg/manifests/system-library.mf
+++ b/usr/src/pkg/manifests/system-library.mf
@@ -334,7 +334,6 @@ file path=usr/lib/$(ARCH64)/libipp.so.1
file path=usr/lib/$(ARCH64)/libipsecutil.so.1
file path=usr/lib/$(ARCH64)/libkvm.so.1
file path=usr/lib/$(ARCH64)/libl.so.1
-file path=usr/lib/$(ARCH64)/libldap.so.4
file path=usr/lib/$(ARCH64)/libldap.so.5
file path=usr/lib/$(ARCH64)/liblgrp.so.1
file path=usr/lib/$(ARCH64)/liblm.so.1
@@ -405,7 +404,6 @@ file path=usr/lib/libipp.so.1
file path=usr/lib/libipsecutil.so.1
file path=usr/lib/libkvm.so.1
file path=usr/lib/libl.so.1
-file path=usr/lib/libldap.so.4
file path=usr/lib/libldap.so.5
file path=usr/lib/liblgrp.so.1
file path=usr/lib/liblm.so.1
@@ -556,8 +554,6 @@ license usr/src/lib/libinetutil/common/THIRDPARTYLICENSE \
license=usr/src/lib/libinetutil/common/THIRDPARTYLICENSE
license usr/src/lib/libkmf/THIRDPARTYLICENSE \
license=usr/src/lib/libkmf/THIRDPARTYLICENSE
-license usr/src/lib/libldap4/THIRDPARTYLICENSE \
- license=usr/src/lib/libldap4/THIRDPARTYLICENSE
license usr/src/lib/libldap5/THIRDPARTYLICENSE \
license=usr/src/lib/libldap5/THIRDPARTYLICENSE
license usr/src/lib/libmp/common/THIRDPARTYLICENSE \
diff --git a/usr/src/tools/ctf/cvt/dwarf.c b/usr/src/tools/ctf/cvt/dwarf.c
index ce8f6f9601..e261818d3a 100644
--- a/usr/src/tools/ctf/cvt/dwarf.c
+++ b/usr/src/tools/ctf/cvt/dwarf.c
@@ -22,6 +22,10 @@
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
+/*
+ * Copyright 2012 Jason King. All rights reserved.
+ * Use is subject to license terms.
+ */
/*
* DWARF to tdata conversion
@@ -360,6 +364,37 @@ die_attr_form(dwarf_t *dw, Dwarf_Attribute attr)
return (0);
}
+/*
+ * the following functions lookup the value of an attribute in a DIE:
+ *
+ * die_signed
+ * die_unsigned
+ * die_bool
+ * die_string
+ *
+ * They all take the same parameters (with the exception of valp which is
+ * a pointer to the type of the attribute we are looking up):
+ *
+ * dw - the dwarf object to look in
+ * die - the DIE we're interested in
+ * name - the name of the attribute to lookup
+ * valp - pointer to where the value of the attribute is placed
+ * req - if the value is required (0 / non-zero)
+ *
+ * If the attribute is not found, one of the following happens:
+ * - program terminates (req is non-zero)
+ * - function returns 0
+ *
+ * If the value is found, and in a form (class) we can handle, the function
+ * returns 1.
+ *
+ * Currently, we can only handle attribute values that are stored as
+ * constants (immediate value). If an attribute has a form we cannot
+ * handle (for example VLAs may store the dimensions of the array
+ * as a DWARF expression that can compute it at runtime by reading
+ * values off the stack or other locations in memory), it is treated
+ * the same as if the attribute does not exist.
+ */
static int
die_signed(dwarf_t *dw, Dwarf_Die die, Dwarf_Half name, Dwarf_Signed *valp,
int req)
@@ -371,6 +406,9 @@ die_signed(dwarf_t *dw, Dwarf_Die die, Dwarf_Half name, Dwarf_Signed *valp,
return (0); /* die_attr will terminate for us if necessary */
if (dwarf_formsdata(attr, &val, &dw->dw_err) != DW_DLV_OK) {
+ if (req == 0)
+ return (0);
+
terminate("die %llu: failed to get signed (form 0x%x)\n",
die_off(dw, die), die_attr_form(dw, attr));
}
@@ -392,6 +430,9 @@ die_unsigned(dwarf_t *dw, Dwarf_Die die, Dwarf_Half name, Dwarf_Unsigned *valp,
return (0); /* die_attr will terminate for us if necessary */
if (dwarf_formudata(attr, &val, &dw->dw_err) != DW_DLV_OK) {
+ if (req == 0)
+ return (0);
+
terminate("die %llu: failed to get unsigned (form 0x%x)\n",
die_off(dw, die), die_attr_form(dw, attr));
}
@@ -412,6 +453,9 @@ die_bool(dwarf_t *dw, Dwarf_Die die, Dwarf_Half name, Dwarf_Bool *valp, int req)
return (0); /* die_attr will terminate for us if necessary */
if (dwarf_formflag(attr, &val, &dw->dw_err) != DW_DLV_OK) {
+ if (req == 0)
+ return (0);
+
terminate("die %llu: failed to get bool (form 0x%x)\n",
die_off(dw, die), die_attr_form(dw, attr));
}
@@ -432,6 +476,9 @@ die_string(dwarf_t *dw, Dwarf_Die die, Dwarf_Half name, char **strp, int req)
return (0); /* die_attr will terminate for us if necessary */
if (dwarf_formstring(attr, &str, &dw->dw_err) != DW_DLV_OK) {
+ if (req == 0)
+ return (0);
+
terminate("die %llu: failed to get string (form 0x%x)\n",
die_off(dw, die), die_attr_form(dw, attr));
}
@@ -1791,6 +1838,59 @@ die_resolve(dwarf_t *dw)
} while (dw->dw_nunres != 0);
}
+/*
+ * Any object containing a function or object symbol at any scope should also
+ * contain DWARF data.
+ */
+static boolean_t
+should_have_dwarf(Elf *elf)
+{
+ Elf_Scn *scn = NULL;
+ Elf_Data *data = NULL;
+ GElf_Shdr shdr;
+ GElf_Sym sym;
+ uint32_t symdx = 0;
+ size_t nsyms = 0;
+ boolean_t found = B_FALSE;
+
+ while ((scn = elf_nextscn(elf, scn)) != NULL) {
+ gelf_getshdr(scn, &shdr);
+
+ if (shdr.sh_type == SHT_SYMTAB) {
+ found = B_TRUE;
+ break;
+ }
+ }
+
+ if (!found)
+ terminate("cannot convert stripped objects\n");
+
+ data = elf_getdata(scn, NULL);
+ nsyms = shdr.sh_size / shdr.sh_entsize;
+
+ for (symdx = 0; symdx < nsyms; symdx++) {
+ gelf_getsym(data, symdx, &sym);
+
+ if ((GELF_ST_TYPE(sym.st_info) == STT_FUNC) ||
+ (GELF_ST_TYPE(sym.st_info) == STT_TLS) ||
+ (GELF_ST_TYPE(sym.st_info) == STT_OBJECT)) {
+ char *name;
+
+ name = elf_strptr(elf, shdr.sh_link, sym.st_name);
+
+ /* Studio emits these local symbols regardless */
+ if ((strcmp(name, "Bbss.bss") != 0) &&
+ (strcmp(name, "Ttbss.bss") != 0) &&
+ (strcmp(name, "Ddata.data") != 0) &&
+ (strcmp(name, "Ttdata.data") != 0) &&
+ (strcmp(name, "Drodata.rodata") != 0))
+ return (B_TRUE);
+ }
+ }
+
+ return (B_FALSE);
+}
+
/*ARGSUSED*/
int
dw_read(tdata_t *td, Elf *elf, const char *filename)
@@ -1814,8 +1914,12 @@ dw_read(tdata_t *td, Elf *elf, const char *filename)
if ((rc = dwarf_elf_init(elf, DW_DLC_READ, NULL, NULL, &dw.dw_dw,
&dw.dw_err)) == DW_DLV_NO_ENTRY) {
- errno = ENOENT;
- return (-1);
+ if (should_have_dwarf(elf)) {
+ errno = ENOENT;
+ return (-1);
+ } else {
+ return (0);
+ }
} else if (rc != DW_DLV_OK) {
if (dwarf_errno(dw.dw_err) == DW_DLE_DEBUG_INFO_NULL) {
/*
@@ -1834,10 +1938,18 @@ dw_read(tdata_t *td, Elf *elf, const char *filename)
terminate("file does not contain valid DWARF data: %s\n",
dwarf_errmsg(dw.dw_err));
+ /*
+ * Some compilers emit no DWARF for empty files, others emit an empty
+ * compilation unit.
+ */
if ((cu = die_sibling(&dw, NULL)) == NULL ||
- (child = die_child(&dw, cu)) == NULL)
+ ((child = die_child(&dw, cu)) == NULL) &&
+ should_have_dwarf(elf)) {
terminate("file does not contain dwarf type data "
"(try compiling with -g)\n");
+ } else if (child == NULL) {
+ return (0);
+ }
dw.dw_maxoff = nxthdr - 1;
diff --git a/usr/src/tools/cw/Makefile b/usr/src/tools/cw/Makefile
index 70f9a20c2a..73a3c3ca57 100644
--- a/usr/src/tools/cw/Makefile
+++ b/usr/src/tools/cw/Makefile
@@ -37,10 +37,12 @@ $(__GNUC)sparc_CC= $(GCC_ROOT)/bin/gcc
CFLAGS += $(CCVERBOSE)
-# Override CFLAGS when building with gcc. This is needed only for bootstrap
-# of cw.
+# Override CFLAGS. This is needed only for bootstrap of cw.
$(__GNUC)CFLAGS= -O -D__sun -Wall -Wno-unknown-pragmas -Werror \
-std=gnu89 -nodefaultlibs
+$(__SUNC)CFLAGS= -xspace -Xa -xildoff -errtags=yes -errwarn=%all \
+ -xc99=%none -W0,-xglobalstatic -v
+
$(__GNUC)LDLIBS += -lc
$(__GNUC)LDFLAGS= $(MAPFILE.NES:%=-Wl,-M%)
diff --git a/usr/src/tools/cw/cw.c b/usr/src/tools/cw/cw.c
index 135a7b363b..7e27294770 100644
--- a/usr/src/tools/cw/cw.c
+++ b/usr/src/tools/cw/cw.c
@@ -1140,11 +1140,6 @@ do_gcc(cw_ictx_t *ctx)
break;
}
#if defined(__x86)
- if (strcmp(arg, "-Wu,-no_got_reloc") == 0) {
- newae(ctx->i_ae, "-fno-jump-tables");
- newae(ctx->i_ae, "-fno-constant-pools");
- break;
- }
if (strcmp(arg, "-Wu,-xmodel=kernel") == 0) {
newae(ctx->i_ae, "-ffreestanding");
newae(ctx->i_ae, "-mno-red-zone");
diff --git a/usr/src/tools/env/illumos.sh b/usr/src/tools/env/illumos.sh
index 9276217c03..23d7a35565 100644
--- a/usr/src/tools/env/illumos.sh
+++ b/usr/src/tools/env/illumos.sh
@@ -226,3 +226,6 @@ export SPRO_VROOT="$SPRO_ROOT"
# POST_NIGHTLY can be any command to be run at the end of nightly. See
# nightly(1) for interactions between environment variables and this command.
#POST_NIGHTLY=
+
+# Uncomment this to disable support for SMB printing.
+# export ENABLE_SMB_PRINTING='#'
diff --git a/usr/src/tools/scripts/git-pbchk.py b/usr/src/tools/scripts/git-pbchk.py
index 59af2f3832..74be6a4818 100644
--- a/usr/src/tools/scripts/git-pbchk.py
+++ b/usr/src/tools/scripts/git-pbchk.py
@@ -24,6 +24,7 @@ import os
import re
import subprocess
import sys
+import tempfile
from cStringIO import StringIO
@@ -62,15 +63,24 @@ def git(command):
command = ["git"] + command
- p = subprocess.Popen(command,
- stdout=subprocess.PIPE,
- stderr=subprocess.STDOUT)
+ try:
+ tmpfile = tempfile.TemporaryFile(prefix="git-nits")
+ except EnvironmentError, e:
+ raise GitError("Could not create temporary file: %s\n" % e)
+
+ try:
+ p = subprocess.Popen(command,
+ stdout=tmpfile,
+ stderr=subprocess.STDOUT)
+ except OSError, e:
+ raise GitError("could not execute %s: %s\n" (command, e))
err = p.wait()
if err != 0:
raise GitError(p.stdout.read())
- return p.stdout
+ tmpfile.seek(0)
+ return tmpfile
def git_root():
diff --git a/usr/src/ucbhead/setjmp.h b/usr/src/ucbhead/setjmp.h
index 1757f760fb..a5d5a70478 100644
--- a/usr/src/ucbhead/setjmp.h
+++ b/usr/src/ucbhead/setjmp.h
@@ -47,8 +47,6 @@
#ifndef _SETJMP_H
#define _SETJMP_H
-#pragma ident "%Z%%M% %I% %E% SMI"
-
#include <sys/types.h>
#include <sys/signal.h>
#include <sys/ucontext.h>
@@ -110,21 +108,21 @@ typedef long sigjmp_buf[_SIGJBLEN];
#if defined(__STDC__)
-extern int _sigsetjmp(sigjmp_buf, int);
+extern int _sigsetjmp(sigjmp_buf, int) __RETURNS_TWICE;
#pragma unknown_control_flow(_sigsetjmp)
extern void _siglongjmp(sigjmp_buf, int) __NORETURN;
-extern int sigsetjmp(sigjmp_buf, int);
+extern int sigsetjmp(sigjmp_buf, int) __RETURNS_TWICE;
#pragma unknown_control_flow(sigsetjmp)
extern void siglongjmp(sigjmp_buf, int) __NORETURN;
#else
-extern int _sigsetjmp();
+extern int _sigsetjmp() __RETURNS_TWICE;
#pragma unknown_control_flow(_sigsetjmp)
extern void _siglongjmp();
-extern int sigsetjmp();
+extern int sigsetjmp() __RETURNS_TWICE;
#pragma unknown_control_flow(sigsetjmp)
extern void siglongjmp();
diff --git a/usr/src/uts/Makefile.uts b/usr/src/uts/Makefile.uts
index 9107d00708..bbcdd0fe15 100644
--- a/usr/src/uts/Makefile.uts
+++ b/usr/src/uts/Makefile.uts
@@ -223,6 +223,7 @@ CFLAGS_uts += $(ILDOFF)
CFLAGS_uts += $(XAOPT)
CFLAGS_uts += $(CTF_FLAGS)
CFLAGS_uts += $(CERRWARN)
+CFLAGS_uts += $(CCNOAUTOINLINE)
CFLAGS_uts += $(CGLOBALSTATIC)
CFLAGS_uts += $(EXTRA_CFLAGS)
diff --git a/usr/src/uts/common/Makefile.files b/usr/src/uts/common/Makefile.files
index a76edeca13..754ae3e230 100644
--- a/usr/src/uts/common/Makefile.files
+++ b/usr/src/uts/common/Makefile.files
@@ -21,11 +21,9 @@
#
# Copyright (c) 1991, 2010, Oracle and/or its affiliates. All rights reserved.
-#
-
-#
# Copyright 2011 Nexenta Systems, Inc. All rights reserved.
# Copyright (c) 2012 Joyent, Inc. All rights reserved.
+# Copyright (c) 2012 by Delphix. All rights reserved.
#
#
@@ -246,6 +244,7 @@ GENUNIX_OBJS += \
nvpair.o \
nvpair_alloc_system.o \
nvpair_alloc_fixed.o \
+ fnvpair.o \
octet.o \
open.o \
p_online.o \
@@ -1089,7 +1088,7 @@ DRM_OBJS += drm_sunmod.o drm_kstat.o drm_agpsupport.o \
drm_auth.o drm_bufs.o drm_context.o drm_dma.o \
drm_drawable.o drm_drv.o drm_fops.o drm_ioctl.o drm_irq.o \
drm_lock.o drm_memory.o drm_msg.o drm_pci.o drm_scatter.o \
- drm_cache.o drm_gem.o drm_mm.o ati_pcigart.o
+ drm_cache.o drm_gem.o drm_mm.o ati_pcigart.o
FM_OBJS += devfm.o devfm_machdep.o
@@ -1336,6 +1335,7 @@ ZFS_COMMON_OBJS += \
arc.o \
bplist.o \
bpobj.o \
+ bptree.o \
dbuf.o \
ddt.o \
ddt_zap.o \
@@ -1357,6 +1357,7 @@ ZFS_COMMON_OBJS += \
dsl_deleg.o \
dsl_prop.o \
dsl_scan.o \
+ zfeature.o \
gzip.o \
lzjb.o \
metaslab.o \
@@ -1400,11 +1401,12 @@ ZFS_COMMON_OBJS += \
zrlock.o
ZFS_SHARED_OBJS += \
- zfs_namecheck.o \
- zfs_deleg.o \
- zfs_prop.o \
+ zfeature_common.o \
zfs_comutil.o \
+ zfs_deleg.o \
zfs_fletcher.o \
+ zfs_namecheck.o \
+ zfs_prop.o \
zpool_prop.o \
zprop_common.o
@@ -1562,7 +1564,7 @@ SWRANDPROV_OBJS += swrand.o
#
# kernel SSL
#
-KSSL_OBJS += kssl.o ksslioctl.o
+KSSL_OBJS += kssl.o ksslioctl.o
KSSL_SOCKFIL_MOD_OBJS += ksslfilter.o ksslapi.o ksslrec.o
diff --git a/usr/src/uts/common/dtrace/dtrace.c b/usr/src/uts/common/dtrace/dtrace.c
index 8538331d59..32d0967772 100644
--- a/usr/src/uts/common/dtrace/dtrace.c
+++ b/usr/src/uts/common/dtrace/dtrace.c
@@ -22,6 +22,7 @@
/*
* Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012, Joyent, Inc. All rights reserved.
+ * Copyright (c) 2012 by Delphix. All rights reserved.
*/
/*
@@ -2513,9 +2514,10 @@ dtrace_speculation_commit(dtrace_state_t *state, processorid_t cpu,
{
dtrace_speculation_t *spec;
dtrace_buffer_t *src, *dest;
- uintptr_t daddr, saddr, dlimit;
+ uintptr_t daddr, saddr, dlimit, slimit;
dtrace_speculation_state_t current, new;
intptr_t offs;
+ uint64_t timestamp;
if (which == 0)
return;
@@ -2591,7 +2593,37 @@ dtrace_speculation_commit(dtrace_state_t *state, processorid_t cpu,
}
/*
- * We have the space; copy the buffer across. (Note that this is a
+ * We have sufficient space to copy the speculative buffer into the
+ * primary buffer. First, modify the speculative buffer, filling
+ * in the timestamp of all entries with the current time. The data
+ * must have the commit() time rather than the time it was traced,
+ * so that all entries in the primary buffer are in timestamp order.
+ */
+ timestamp = dtrace_gethrtime();
+ saddr = (uintptr_t)src->dtb_tomax;
+ slimit = saddr + src->dtb_offset;
+ while (saddr < slimit) {
+ size_t size;
+ dtrace_rechdr_t *dtrh = (dtrace_rechdr_t *)saddr;
+
+ if (dtrh->dtrh_epid == DTRACE_EPIDNONE) {
+ saddr += sizeof (dtrace_epid_t);
+ continue;
+ }
+ ASSERT3U(dtrh->dtrh_epid, <=, state->dts_necbs);
+ size = state->dts_ecbs[dtrh->dtrh_epid - 1]->dte_size;
+
+ ASSERT3U(saddr + size, <=, slimit);
+ ASSERT3U(size, >=, sizeof (dtrace_rechdr_t));
+ ASSERT3U(DTRACE_RECORD_LOAD_TIMESTAMP(dtrh), ==, UINT64_MAX);
+
+ DTRACE_RECORD_STORE_TIMESTAMP(dtrh, timestamp);
+
+ saddr += size;
+ }
+
+ /*
+ * Copy the buffer across. (Note that this is a
* highly subobtimal bcopy(); in the unlikely event that this becomes
* a serious performance issue, a high-performance DTrace-specific
* bcopy() should obviously be invented.)
@@ -6085,7 +6117,7 @@ dtrace_probe(dtrace_id_t id, uintptr_t arg0, uintptr_t arg1,
if (now - state->dts_alive > dtrace_deadman_timeout) {
/*
* We seem to be dead. Unless we (a) have kernel
- * destructive permissions (b) have expicitly enabled
+ * destructive permissions (b) have explicitly enabled
* destructive actions and (c) destructive actions have
* not been disabled, we're going to transition into
* the KILLED state, from which no further processing
@@ -6113,8 +6145,18 @@ dtrace_probe(dtrace_id_t id, uintptr_t arg0, uintptr_t arg1,
tomax = buf->dtb_tomax;
ASSERT(tomax != NULL);
- if (ecb->dte_size != 0)
- DTRACE_STORE(uint32_t, tomax, offs, ecb->dte_epid);
+ if (ecb->dte_size != 0) {
+ dtrace_rechdr_t dtrh;
+ if (!(mstate.dtms_present & DTRACE_MSTATE_TIMESTAMP)) {
+ mstate.dtms_timestamp = dtrace_gethrtime();
+ mstate.dtms_present |= DTRACE_MSTATE_TIMESTAMP;
+ }
+ ASSERT3U(ecb->dte_size, >=, sizeof (dtrace_rechdr_t));
+ dtrh.dtrh_epid = ecb->dte_epid;
+ DTRACE_RECORD_STORE_TIMESTAMP(&dtrh,
+ mstate.dtms_timestamp);
+ *((dtrace_rechdr_t *)(tomax + offs)) = dtrh;
+ }
mstate.dtms_epid = ecb->dte_epid;
mstate.dtms_present |= DTRACE_MSTATE_EPID;
@@ -6278,7 +6320,9 @@ dtrace_probe(dtrace_id_t id, uintptr_t arg0, uintptr_t arg1,
continue;
switch (act->dta_kind) {
- case DTRACEACT_SPECULATE:
+ case DTRACEACT_SPECULATE: {
+ dtrace_rechdr_t *dtrh;
+
ASSERT(buf == &state->dts_buffer[cpuid]);
buf = dtrace_speculation_buffer(state,
cpuid, val);
@@ -6300,10 +6344,23 @@ dtrace_probe(dtrace_id_t id, uintptr_t arg0, uintptr_t arg1,
tomax = buf->dtb_tomax;
ASSERT(tomax != NULL);
- if (ecb->dte_size != 0)
- DTRACE_STORE(uint32_t, tomax, offs,
- ecb->dte_epid);
+ if (ecb->dte_size == 0)
+ continue;
+
+ ASSERT3U(ecb->dte_size, >=,
+ sizeof (dtrace_rechdr_t));
+ dtrh = ((void *)(tomax + offs));
+ dtrh->dtrh_epid = ecb->dte_epid;
+ /*
+ * When the speculation is committed, all of
+ * the records in the speculative buffer will
+ * have their timestamps set to the commit
+ * time. Until then, it is set to a sentinel
+ * value, for debugability.
+ */
+ DTRACE_RECORD_STORE_TIMESTAMP(dtrh, UINT64_MAX);
continue;
+ }
case DTRACEACT_CHILL:
if (dtrace_priv_kernel_destructive(state))
@@ -9532,9 +9589,9 @@ dtrace_ecb_add(dtrace_state_t *state, dtrace_probe_t *probe)
/*
* The default size is the size of the default action: recording
- * the epid.
+ * the header.
*/
- ecb->dte_size = ecb->dte_needed = sizeof (dtrace_epid_t);
+ ecb->dte_size = ecb->dte_needed = sizeof (dtrace_rechdr_t);
ecb->dte_alignment = sizeof (dtrace_epid_t);
epid = state->dts_epid++;
@@ -9633,122 +9690,89 @@ dtrace_ecb_enable(dtrace_ecb_t *ecb)
static void
dtrace_ecb_resize(dtrace_ecb_t *ecb)
{
- uint32_t maxalign = sizeof (dtrace_epid_t);
- uint32_t align = sizeof (uint8_t), offs, diff;
dtrace_action_t *act;
- int wastuple = 0;
+ uint32_t curneeded = UINT32_MAX;
uint32_t aggbase = UINT32_MAX;
- dtrace_state_t *state = ecb->dte_state;
/*
- * If we record anything, we always record the epid. (And we always
- * record it first.)
+ * If we record anything, we always record the dtrace_rechdr_t. (And
+ * we always record it first.)
*/
- offs = sizeof (dtrace_epid_t);
- ecb->dte_size = ecb->dte_needed = sizeof (dtrace_epid_t);
+ ecb->dte_size = sizeof (dtrace_rechdr_t);
+ ecb->dte_alignment = sizeof (dtrace_epid_t);
for (act = ecb->dte_action; act != NULL; act = act->dta_next) {
dtrace_recdesc_t *rec = &act->dta_rec;
+ ASSERT(rec->dtrd_size > 0 || rec->dtrd_alignment == 1);
- if ((align = rec->dtrd_alignment) > maxalign)
- maxalign = align;
-
- if (!wastuple && act->dta_intuple) {
- /*
- * This is the first record in a tuple. Align the
- * offset to be at offset 4 in an 8-byte aligned
- * block.
- */
- diff = offs + sizeof (dtrace_aggid_t);
-
- if (diff = (diff & (sizeof (uint64_t) - 1)))
- offs += sizeof (uint64_t) - diff;
-
- aggbase = offs - sizeof (dtrace_aggid_t);
- ASSERT(!(aggbase & (sizeof (uint64_t) - 1)));
- }
-
- /*LINTED*/
- if (rec->dtrd_size != 0 && (diff = (offs & (align - 1)))) {
- /*
- * The current offset is not properly aligned; align it.
- */
- offs += align - diff;
- }
-
- rec->dtrd_offset = offs;
-
- if (offs + rec->dtrd_size > ecb->dte_needed) {
- ecb->dte_needed = offs + rec->dtrd_size;
-
- if (ecb->dte_needed > state->dts_needed)
- state->dts_needed = ecb->dte_needed;
- }
+ ecb->dte_alignment = MAX(ecb->dte_alignment,
+ rec->dtrd_alignment);
if (DTRACEACT_ISAGG(act->dta_kind)) {
dtrace_aggregation_t *agg = (dtrace_aggregation_t *)act;
- dtrace_action_t *first = agg->dtag_first, *prev;
- ASSERT(rec->dtrd_size != 0 && first != NULL);
- ASSERT(wastuple);
+ ASSERT(rec->dtrd_size != 0);
+ ASSERT(agg->dtag_first != NULL);
+ ASSERT(act->dta_prev->dta_intuple);
ASSERT(aggbase != UINT32_MAX);
+ ASSERT(curneeded != UINT32_MAX);
agg->dtag_base = aggbase;
- while ((prev = first->dta_prev) != NULL &&
- DTRACEACT_ISAGG(prev->dta_kind)) {
- agg = (dtrace_aggregation_t *)prev;
- first = agg->dtag_first;
- }
+ curneeded = P2ROUNDUP(curneeded, rec->dtrd_alignment);
+ rec->dtrd_offset = curneeded;
+ curneeded += rec->dtrd_size;
+ ecb->dte_needed = MAX(ecb->dte_needed, curneeded);
- if (prev != NULL) {
- offs = prev->dta_rec.dtrd_offset +
- prev->dta_rec.dtrd_size;
- } else {
- offs = sizeof (dtrace_epid_t);
- }
- wastuple = 0;
+ aggbase = UINT32_MAX;
+ curneeded = UINT32_MAX;
+ } else if (act->dta_intuple) {
+ if (curneeded == UINT32_MAX) {
+ /*
+ * This is the first record in a tuple. Align
+ * curneeded to be at offset 4 in an 8-byte
+ * aligned block.
+ */
+ ASSERT(act->dta_prev == NULL ||
+ !act->dta_prev->dta_intuple);
+ ASSERT3U(aggbase, ==, UINT32_MAX);
+ curneeded = P2PHASEUP(ecb->dte_size,
+ sizeof (uint64_t), sizeof (dtrace_aggid_t));
+
+ aggbase = curneeded - sizeof (dtrace_aggid_t);
+ ASSERT(IS_P2ALIGNED(aggbase,
+ sizeof (uint64_t)));
+ }
+ curneeded = P2ROUNDUP(curneeded, rec->dtrd_alignment);
+ rec->dtrd_offset = curneeded;
+ curneeded += rec->dtrd_size;
} else {
- if (!act->dta_intuple)
- ecb->dte_size = offs + rec->dtrd_size;
+ /* tuples must be followed by an aggregation */
+ ASSERT(act->dta_prev == NULL ||
+ !act->dta_prev->dta_intuple);
- offs += rec->dtrd_size;
+ ecb->dte_size = P2ROUNDUP(ecb->dte_size,
+ rec->dtrd_alignment);
+ rec->dtrd_offset = ecb->dte_size;
+ ecb->dte_size += rec->dtrd_size;
+ ecb->dte_needed = MAX(ecb->dte_needed, ecb->dte_size);
}
-
- wastuple = act->dta_intuple;
}
if ((act = ecb->dte_action) != NULL &&
!(act->dta_kind == DTRACEACT_SPECULATE && act->dta_next == NULL) &&
- ecb->dte_size == sizeof (dtrace_epid_t)) {
+ ecb->dte_size == sizeof (dtrace_rechdr_t)) {
/*
- * If the size is still sizeof (dtrace_epid_t), then all
+ * If the size is still sizeof (dtrace_rechdr_t), then all
* actions store no data; set the size to 0.
*/
- ecb->dte_alignment = maxalign;
ecb->dte_size = 0;
-
- /*
- * If the needed space is still sizeof (dtrace_epid_t), then
- * all actions need no additional space; set the needed
- * size to 0.
- */
- if (ecb->dte_needed == sizeof (dtrace_epid_t))
- ecb->dte_needed = 0;
-
- return;
}
- /*
- * Set our alignment, and make sure that the dte_size and dte_needed
- * are aligned to the size of an EPID.
- */
- ecb->dte_alignment = maxalign;
- ecb->dte_size = (ecb->dte_size + (sizeof (dtrace_epid_t) - 1)) &
- ~(sizeof (dtrace_epid_t) - 1);
- ecb->dte_needed = (ecb->dte_needed + (sizeof (dtrace_epid_t) - 1)) &
- ~(sizeof (dtrace_epid_t) - 1);
- ASSERT(ecb->dte_size <= ecb->dte_needed);
+ ecb->dte_size = P2ROUNDUP(ecb->dte_size, sizeof (dtrace_epid_t));
+ ecb->dte_needed = P2ROUNDUP(ecb->dte_needed, (sizeof (dtrace_epid_t)));
+ ecb->dte_state->dts_needed = MAX(ecb->dte_state->dts_needed,
+ ecb->dte_needed);
}
static dtrace_action_t *
@@ -10118,7 +10142,7 @@ dtrace_ecb_action_add(dtrace_ecb_t *ecb, dtrace_actdesc_t *desc)
break;
case DTRACEACT_SPECULATE:
- if (ecb->dte_size > sizeof (dtrace_epid_t))
+ if (ecb->dte_size > sizeof (dtrace_rechdr_t))
return (EINVAL);
if (dp == NULL)
@@ -10231,7 +10255,7 @@ dtrace_ecb_action_remove(dtrace_ecb_t *ecb)
ecb->dte_action = NULL;
ecb->dte_action_last = NULL;
- ecb->dte_size = sizeof (dtrace_epid_t);
+ ecb->dte_size = 0;
}
static void
@@ -10502,12 +10526,13 @@ dtrace_buffer_switch(dtrace_buffer_t *buf)
caddr_t tomax = buf->dtb_tomax;
caddr_t xamot = buf->dtb_xamot;
dtrace_icookie_t cookie;
- hrtime_t now = dtrace_gethrtime();
+ hrtime_t now;
ASSERT(!(buf->dtb_flags & DTRACEBUF_NOSWITCH));
ASSERT(!(buf->dtb_flags & DTRACEBUF_RING));
cookie = dtrace_interrupt_disable();
+ now = dtrace_gethrtime();
buf->dtb_tomax = xamot;
buf->dtb_xamot = tomax;
buf->dtb_xamot_drops = buf->dtb_drops;
@@ -10802,7 +10827,7 @@ dtrace_buffer_reserve(dtrace_buffer_t *buf, size_t needed, size_t align,
if (epid == DTRACE_EPIDNONE) {
size = sizeof (uint32_t);
} else {
- ASSERT(epid <= state->dts_necbs);
+ ASSERT3U(epid, <=, state->dts_necbs);
ASSERT(state->dts_ecbs[epid - 1] != NULL);
size = state->dts_ecbs[epid - 1]->dte_size;
@@ -15837,6 +15862,7 @@ dtrace_ioctl(dev_t dev, int cmd, intptr_t arg, int md, cred_t *cr, int *rv)
desc.dtbd_drops = buf->dtb_drops;
desc.dtbd_errors = buf->dtb_errors;
desc.dtbd_oldest = buf->dtb_xamot_offset;
+ desc.dtbd_timestamp = dtrace_gethrtime();
mutex_exit(&dtrace_lock);
@@ -15889,6 +15915,7 @@ dtrace_ioctl(dev_t dev, int cmd, intptr_t arg, int md, cred_t *cr, int *rv)
desc.dtbd_drops = buf->dtb_xamot_drops;
desc.dtbd_errors = buf->dtb_xamot_errors;
desc.dtbd_oldest = 0;
+ desc.dtbd_timestamp = buf->dtb_switched;
mutex_exit(&dtrace_lock);
diff --git a/usr/src/uts/common/fs/hsfs/hsfs_vfsops.c b/usr/src/uts/common/fs/hsfs/hsfs_vfsops.c
index 9b11f3bddf..8286dc11ac 100644
--- a/usr/src/uts/common/fs/hsfs/hsfs_vfsops.c
+++ b/usr/src/uts/common/fs/hsfs/hsfs_vfsops.c
@@ -1156,8 +1156,7 @@ hs_findisovol(struct hsfs *fsp, struct vnode *vp,
* To avoid that we read the whole medium in case that someone prepares
* a malicious "fs image", we read at most 32 blocks.
*/
- for (n = 0; n < 32 &&
- (enum iso_voldesc_type) ISO_DESC_TYPE(volp) != ISO_VD_EOV; n++) {
+ for (n = 0; n < 32 && ISO_DESC_TYPE(volp) != ISO_VD_EOV; n++) {
for (i = 0; i < ISO_ID_STRLEN; i++)
if (ISO_STD_ID(volp)[i] != ISO_ID_STRING[i])
goto cantfind;
diff --git a/usr/src/uts/common/fs/nfs/nfs4_state.c b/usr/src/uts/common/fs/nfs/nfs4_state.c
index 9c300ec5d0..d148d45ff3 100644
--- a/usr/src/uts/common/fs/nfs/nfs4_state.c
+++ b/usr/src/uts/common/fs/nfs/nfs4_state.c
@@ -20,6 +20,7 @@
*/
/*
* Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright 2012 Nexenta Systems, Inc. All rights reserved.
*/
#include <sys/systm.h>
@@ -2021,15 +2022,12 @@ openowner_mkkey(rfs4_entry_t u_entry)
return (&oo->ro_owner);
}
+/* ARGSUSED */
static bool_t
rfs4_openowner_expiry(rfs4_entry_t u_entry)
{
- rfs4_openowner_t *oo = (rfs4_openowner_t *)u_entry;
-
- if (rfs4_dbe_is_invalid(oo->ro_dbe))
- return (TRUE);
- return ((gethrestime_sec() - oo->ro_client->rc_last_access
- > rfs4_lease_time));
+ /* openstateid held us and did all needed delay */
+ return (TRUE);
}
static void
diff --git a/usr/src/uts/common/fs/smbsrv/smb_print.c b/usr/src/uts/common/fs/smbsrv/smb_print.c
index b3bbedfd1b..4838401047 100644
--- a/usr/src/uts/common/fs/smbsrv/smb_print.c
+++ b/usr/src/uts/common/fs/smbsrv/smb_print.c
@@ -20,7 +20,7 @@
*/
/*
* Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
+ * Copyright 2012 Nexenta Systems, Inc. All rights reserved.
*/
/*
@@ -183,8 +183,12 @@ smb_com_close_print_file(smb_request_t *sr)
{
smb_sdrc_t rc;
- if (sr->sr_server->sv_cfg.skc_print_enable == 0 ||
- !STYPE_ISPRN(sr->tid_tree->t_res_type)) {
+ /*
+ * If sv_cfg.skc_print_enable somehow went false while
+ * we have a print FID open, close the FID. In this
+ * situation, smb_spool_add_fid() will do nothing.
+ */
+ if (!STYPE_ISPRN(sr->tid_tree->t_res_type)) {
smbsr_error(sr, NT_STATUS_BAD_DEVICE_TYPE,
ERRDOS, ERROR_BAD_DEV_TYPE);
cmn_err(CE_WARN, "smb_com_close_print_file: SDRC_ERROR");
@@ -192,8 +196,7 @@ smb_com_close_print_file(smb_request_t *sr)
}
rc = smb_com_close(sr);
- (void) smb_spool_add_fid(sr->smb_fid);
- cv_broadcast(&sr->sr_server->sp_info.sp_cv);
+ smb_spool_add_fid(sr->sr_server, sr->smb_fid);
return (rc);
}
diff --git a/usr/src/uts/common/fs/smbsrv/smb_server.c b/usr/src/uts/common/fs/smbsrv/smb_server.c
index 813031c327..e3bcec5ba6 100644
--- a/usr/src/uts/common/fs/smbsrv/smb_server.c
+++ b/usr/src/uts/common/fs/smbsrv/smb_server.c
@@ -20,7 +20,7 @@
*/
/*
* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
+ * Copyright 2012 Nexenta Systems, Inc. All rights reserved.
*/
/*
@@ -2156,17 +2156,14 @@ smb_spool_lookup_doc_byfid(smb_server_t *sv, uint16_t fid,
*
*/
-int
-smb_spool_add_fid(uint16_t fid)
+void
+smb_spool_add_fid(smb_server_t *sv, uint16_t fid)
{
smb_llist_t *fidlist;
- smb_server_t *sv;
smb_spoolfid_t *sf;
- int rc = 0;
- rc = smb_server_lookup(&sv);
- if (rc)
- return (rc);
+ if (sv->sv_cfg.skc_print_enable == 0)
+ return;
sf = kmem_zalloc(sizeof (smb_spoolfid_t), KM_SLEEP);
fidlist = &sv->sp_info.sp_fidlist;
@@ -2174,8 +2171,7 @@ smb_spool_add_fid(uint16_t fid)
sf->sf_fid = fid;
smb_llist_insert_tail(fidlist, sf);
smb_llist_exit(fidlist);
- smb_server_release(sv);
- return (rc);
+ cv_broadcast(&sv->sp_info.sp_cv);
}
/*
diff --git a/usr/src/uts/common/fs/zfs/arc.c b/usr/src/uts/common/fs/zfs/arc.c
index 98aad58025..4946567fad 100644
--- a/usr/src/uts/common/fs/zfs/arc.c
+++ b/usr/src/uts/common/fs/zfs/arc.c
@@ -21,8 +21,8 @@
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright 2011 Nexenta Systems, Inc. All rights reserved.
- * Copyright (c) 2011 by Delphix. All rights reserved.
* Copyright (c) 2012, Joyent, Inc. All rights reserved.
+ * Copyright (c) 2012 by Delphix. All rights reserved.
*/
/*
@@ -81,9 +81,9 @@
* types of locks: 1) the hash table lock array, and 2) the
* arc list locks.
*
- * Buffers do not have their own mutexs, rather they rely on the
- * hash table mutexs for the bulk of their protection (i.e. most
- * fields in the arc_buf_hdr_t are protected by these mutexs).
+ * Buffers do not have their own mutexes, rather they rely on the
+ * hash table mutexes for the bulk of their protection (i.e. most
+ * fields in the arc_buf_hdr_t are protected by these mutexes).
*
* buf_hash_find() returns the appropriate mutex (held) when it
* locates the requested buffer in the hash table. It returns
@@ -1984,6 +1984,11 @@ arc_shrink(void)
arc_adjust();
}
+/*
+ * Determine if the system is under memory pressure and is asking
+ * to reclaim memory. A return value of 1 indicates that the system
+ * is under memory pressure and that the arc should adjust accordingly.
+ */
static int
arc_reclaim_needed(void)
{
@@ -2041,11 +2046,24 @@ arc_reclaim_needed(void)
* heap is allocated. (Or, in the calculation, if less than 1/4th is
* free)
*/
- if (btop(vmem_size(heap_arena, VMEM_FREE)) <
- (btop(vmem_size(heap_arena, VMEM_FREE | VMEM_ALLOC)) >> 2))
+ if (vmem_size(heap_arena, VMEM_FREE) <
+ (vmem_size(heap_arena, VMEM_FREE | VMEM_ALLOC) >> 2))
return (1);
#endif
+ /*
+ * If zio data pages are being allocated out of a separate heap segment,
+ * then enforce that the size of available vmem for this arena remains
+ * above about 1/16th free.
+ *
+ * Note: The 1/16th arena free requirement was put in place
+ * to aggressively evict memory from the arc in order to avoid
+ * memory fragmentation issues.
+ */
+ if (zio_arena != NULL &&
+ vmem_size(zio_arena, VMEM_FREE) <
+ (vmem_size(zio_arena, VMEM_ALLOC) >> 4))
+ return (1);
#else
if (spa_get_random(100) == 0)
return (1);
@@ -2097,6 +2115,13 @@ arc_kmem_reap_now(arc_reclaim_strategy_t strat)
}
kmem_cache_reap_now(buf_cache);
kmem_cache_reap_now(hdr_cache);
+
+ /*
+ * Ask the vmem areana to reclaim unused memory from its
+ * quantum caches.
+ */
+ if (zio_arena != NULL && strat == ARC_RECLAIM_AGGR)
+ vmem_qcache_reap(zio_arena);
}
static void
@@ -2230,18 +2255,6 @@ arc_evict_needed(arc_buf_contents_t type)
if (type == ARC_BUFC_METADATA && arc_meta_used >= arc_meta_limit)
return (1);
-#ifdef _KERNEL
- /*
- * If zio data pages are being allocated out of a separate heap segment,
- * then enforce that the size of available vmem for this area remains
- * above about 1/32nd free.
- */
- if (type == ARC_BUFC_DATA && zio_arena != NULL &&
- vmem_size(zio_arena, VMEM_FREE) <
- (vmem_size(zio_arena, VMEM_ALLOC) >> 5))
- return (1);
-#endif
-
if (arc_reclaim_needed())
return (1);
@@ -2546,9 +2559,11 @@ arc_read_done(zio_t *zio)
callback_list = hdr->b_acb;
ASSERT(callback_list != NULL);
if (BP_SHOULD_BYTESWAP(zio->io_bp) && zio->io_error == 0) {
+ dmu_object_byteswap_t bswap =
+ DMU_OT_BYTESWAP(BP_GET_TYPE(zio->io_bp));
arc_byteswap_func_t *func = BP_GET_LEVEL(zio->io_bp) > 0 ?
byteswap_uint64_array :
- dmu_ot[BP_GET_TYPE(zio->io_bp)].ot_byteswap;
+ dmu_ot_byteswap[bswap].ob_func;
func(buf->b_data, hdr->b_size);
}
@@ -2633,7 +2648,7 @@ arc_read_done(zio_t *zio)
}
/*
- * "Read" the block block at the specified DVA (in bp) via the
+ * "Read" the block at the specified DVA (in bp) via the
* cache. If the block is found in the cache, invoke the provided
* callback immediately and return. Note that the `zio' parameter
* in the callback will be NULL in this case, since no IO was
diff --git a/usr/src/uts/common/fs/zfs/bptree.c b/usr/src/uts/common/fs/zfs/bptree.c
new file mode 100644
index 0000000000..8c5a7d40ef
--- /dev/null
+++ b/usr/src/uts/common/fs/zfs/bptree.c
@@ -0,0 +1,224 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (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) 2012 by Delphix. All rights reserved.
+ */
+
+#include <sys/arc.h>
+#include <sys/bptree.h>
+#include <sys/dmu.h>
+#include <sys/dmu_objset.h>
+#include <sys/dmu_tx.h>
+#include <sys/dmu_traverse.h>
+#include <sys/dsl_dataset.h>
+#include <sys/dsl_dir.h>
+#include <sys/dsl_pool.h>
+#include <sys/dnode.h>
+#include <sys/refcount.h>
+#include <sys/spa.h>
+
+/*
+ * A bptree is a queue of root block pointers from destroyed datasets. When a
+ * dataset is destroyed its root block pointer is put on the end of the pool's
+ * bptree queue so the dataset's blocks can be freed asynchronously by
+ * dsl_scan_sync. This allows the delete operation to finish without traversing
+ * all the dataset's blocks.
+ *
+ * Note that while bt_begin and bt_end are only ever incremented in this code
+ * they are effectively reset to 0 every time the entire bptree is freed because
+ * the bptree's object is destroyed and re-created.
+ */
+
+struct bptree_args {
+ bptree_phys_t *ba_phys; /* data in bonus buffer, dirtied if freeing */
+ boolean_t ba_free; /* true if freeing during traversal */
+
+ bptree_itor_t *ba_func; /* function to call for each blockpointer */
+ void *ba_arg; /* caller supplied argument to ba_func */
+ dmu_tx_t *ba_tx; /* caller supplied tx, NULL if not freeing */
+} bptree_args_t;
+
+uint64_t
+bptree_alloc(objset_t *os, dmu_tx_t *tx)
+{
+ uint64_t obj;
+ dmu_buf_t *db;
+ bptree_phys_t *bt;
+
+ obj = dmu_object_alloc(os, DMU_OTN_UINT64_METADATA,
+ SPA_MAXBLOCKSIZE, DMU_OTN_UINT64_METADATA,
+ sizeof (bptree_phys_t), tx);
+
+ /*
+ * Bonus buffer contents are already initialized to 0, but for
+ * readability we make it explicit.
+ */
+ VERIFY3U(0, ==, dmu_bonus_hold(os, obj, FTAG, &db));
+ dmu_buf_will_dirty(db, tx);
+ bt = db->db_data;
+ bt->bt_begin = 0;
+ bt->bt_end = 0;
+ bt->bt_bytes = 0;
+ bt->bt_comp = 0;
+ bt->bt_uncomp = 0;
+ dmu_buf_rele(db, FTAG);
+
+ return (obj);
+}
+
+int
+bptree_free(objset_t *os, uint64_t obj, dmu_tx_t *tx)
+{
+ dmu_buf_t *db;
+ bptree_phys_t *bt;
+
+ VERIFY3U(0, ==, dmu_bonus_hold(os, obj, FTAG, &db));
+ bt = db->db_data;
+ ASSERT3U(bt->bt_begin, ==, bt->bt_end);
+ ASSERT3U(bt->bt_bytes, ==, 0);
+ ASSERT3U(bt->bt_comp, ==, 0);
+ ASSERT3U(bt->bt_uncomp, ==, 0);
+ dmu_buf_rele(db, FTAG);
+
+ return (dmu_object_free(os, obj, tx));
+}
+
+void
+bptree_add(objset_t *os, uint64_t obj, blkptr_t *bp, uint64_t birth_txg,
+ uint64_t bytes, uint64_t comp, uint64_t uncomp, dmu_tx_t *tx)
+{
+ dmu_buf_t *db;
+ bptree_phys_t *bt;
+ bptree_entry_phys_t bte;
+
+ /*
+ * bptree objects are in the pool mos, therefore they can only be
+ * modified in syncing context. Furthermore, this is only modified
+ * by the sync thread, so no locking is necessary.
+ */
+ ASSERT(dmu_tx_is_syncing(tx));
+
+ VERIFY3U(0, ==, dmu_bonus_hold(os, obj, FTAG, &db));
+ bt = db->db_data;
+
+ bte.be_birth_txg = birth_txg;
+ bte.be_bp = *bp;
+ bzero(&bte.be_zb, sizeof (bte.be_zb));
+ dmu_write(os, obj, bt->bt_end * sizeof (bte), sizeof (bte), &bte, tx);
+
+ dmu_buf_will_dirty(db, tx);
+ bt->bt_end++;
+ bt->bt_bytes += bytes;
+ bt->bt_comp += comp;
+ bt->bt_uncomp += uncomp;
+ dmu_buf_rele(db, FTAG);
+}
+
+/* ARGSUSED */
+static int
+bptree_visit_cb(spa_t *spa, zilog_t *zilog, const blkptr_t *bp, arc_buf_t *pbuf,
+ const zbookmark_t *zb, const dnode_phys_t *dnp, void *arg)
+{
+ int err;
+ struct bptree_args *ba = arg;
+
+ if (bp == NULL)
+ return (0);
+
+ err = ba->ba_func(ba->ba_arg, bp, ba->ba_tx);
+ if (err == 0 && ba->ba_free) {
+ ba->ba_phys->bt_bytes -= bp_get_dsize_sync(spa, bp);
+ ba->ba_phys->bt_comp -= BP_GET_PSIZE(bp);
+ ba->ba_phys->bt_uncomp -= BP_GET_UCSIZE(bp);
+ }
+ return (err);
+}
+
+int
+bptree_iterate(objset_t *os, uint64_t obj, boolean_t free, bptree_itor_t func,
+ void *arg, dmu_tx_t *tx)
+{
+ int err;
+ uint64_t i;
+ dmu_buf_t *db;
+ struct bptree_args ba;
+
+ ASSERT(!free || dmu_tx_is_syncing(tx));
+
+ err = dmu_bonus_hold(os, obj, FTAG, &db);
+ if (err != 0)
+ return (err);
+
+ if (free)
+ dmu_buf_will_dirty(db, tx);
+
+ ba.ba_phys = db->db_data;
+ ba.ba_free = free;
+ ba.ba_func = func;
+ ba.ba_arg = arg;
+ ba.ba_tx = tx;
+
+ err = 0;
+ for (i = ba.ba_phys->bt_begin; i < ba.ba_phys->bt_end; i++) {
+ bptree_entry_phys_t bte;
+
+ ASSERT(!free || i == ba.ba_phys->bt_begin);
+
+ err = dmu_read(os, obj, i * sizeof (bte), sizeof (bte),
+ &bte, DMU_READ_NO_PREFETCH);
+ if (err != 0)
+ break;
+
+ err = traverse_dataset_destroyed(os->os_spa, &bte.be_bp,
+ bte.be_birth_txg, &bte.be_zb, TRAVERSE_POST,
+ bptree_visit_cb, &ba);
+ if (free) {
+ ASSERT(err == 0 || err == ERESTART);
+ if (err != 0) {
+ /* save bookmark for future resume */
+ ASSERT3U(bte.be_zb.zb_objset, ==,
+ ZB_DESTROYED_OBJSET);
+ ASSERT3U(bte.be_zb.zb_level, ==, 0);
+ dmu_write(os, obj, i * sizeof (bte),
+ sizeof (bte), &bte, tx);
+ break;
+ } else {
+ ba.ba_phys->bt_begin++;
+ (void) dmu_free_range(os, obj,
+ i * sizeof (bte), sizeof (bte), tx);
+ }
+ }
+ }
+
+ ASSERT(!free || err != 0 || ba.ba_phys->bt_begin == ba.ba_phys->bt_end);
+
+ /* if all blocks are free there should be no used space */
+ if (ba.ba_phys->bt_begin == ba.ba_phys->bt_end) {
+ ASSERT3U(ba.ba_phys->bt_bytes, ==, 0);
+ ASSERT3U(ba.ba_phys->bt_comp, ==, 0);
+ ASSERT3U(ba.ba_phys->bt_uncomp, ==, 0);
+ }
+
+ dmu_buf_rele(db, FTAG);
+
+ return (err);
+}
diff --git a/usr/src/uts/common/fs/zfs/dbuf.c b/usr/src/uts/common/fs/zfs/dbuf.c
index 16e42b951a..627d0ba49b 100644
--- a/usr/src/uts/common/fs/zfs/dbuf.c
+++ b/usr/src/uts/common/fs/zfs/dbuf.c
@@ -21,6 +21,7 @@
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright 2011 Nexenta Systems, Inc. All rights reserved.
+ * Copyright (c) 2012 by Delphix. All rights reserved.
*/
#include <sys/zfs_context.h>
@@ -227,7 +228,7 @@ dbuf_is_metadata(dmu_buf_impl_t *db)
boolean_t is_metadata;
DB_DNODE_ENTER(db);
- is_metadata = dmu_ot[DB_DNODE(db)->dn_type].ot_metadata;
+ is_metadata = DMU_OT_IS_METADATA(DB_DNODE(db)->dn_type);
DB_DNODE_EXIT(db);
return (is_metadata);
diff --git a/usr/src/uts/common/fs/zfs/ddt.c b/usr/src/uts/common/fs/zfs/ddt.c
index 7183314967..b3ec3ccbd2 100644
--- a/usr/src/uts/common/fs/zfs/ddt.c
+++ b/usr/src/uts/common/fs/zfs/ddt.c
@@ -21,6 +21,7 @@
/*
* Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012 by Delphix. All rights reserved.
*/
#include <sys/zfs_context.h>
@@ -1061,11 +1062,9 @@ ddt_sync_table(ddt_t *ddt, dmu_tx_t *tx, uint64_t txg)
ASSERT(spa->spa_uberblock.ub_version >= SPA_VERSION_DEDUP);
if (spa->spa_ddt_stat_object == 0) {
- spa->spa_ddt_stat_object = zap_create(ddt->ddt_os,
- DMU_OT_DDT_STATS, DMU_OT_NONE, 0, tx);
- VERIFY(zap_add(ddt->ddt_os, DMU_POOL_DIRECTORY_OBJECT,
- DMU_POOL_DDT_STATS, sizeof (uint64_t), 1,
- &spa->spa_ddt_stat_object, tx) == 0);
+ spa->spa_ddt_stat_object = zap_create_link(ddt->ddt_os,
+ DMU_OT_DDT_STATS, DMU_POOL_DIRECTORY_OBJECT,
+ DMU_POOL_DDT_STATS, tx);
}
while ((dde = avl_destroy_nodes(&ddt->ddt_tree, &cookie)) != NULL) {
diff --git a/usr/src/uts/common/fs/zfs/dmu.c b/usr/src/uts/common/fs/zfs/dmu.c
index 743f5c4656..e0688e74b4 100644
--- a/usr/src/uts/common/fs/zfs/dmu.c
+++ b/usr/src/uts/common/fs/zfs/dmu.c
@@ -21,6 +21,7 @@
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright 2011, Joyent, Inc. All rights reserved.
+ * Copyright (c) 2012 by Delphix. All rights reserved.
*/
#include <sys/dmu.h>
@@ -47,60 +48,73 @@
#endif
const dmu_object_type_info_t dmu_ot[DMU_OT_NUMTYPES] = {
- { byteswap_uint8_array, TRUE, "unallocated" },
- { zap_byteswap, TRUE, "object directory" },
- { byteswap_uint64_array, TRUE, "object array" },
- { byteswap_uint8_array, TRUE, "packed nvlist" },
- { byteswap_uint64_array, TRUE, "packed nvlist size" },
- { byteswap_uint64_array, TRUE, "bpobj" },
- { byteswap_uint64_array, TRUE, "bpobj header" },
- { byteswap_uint64_array, TRUE, "SPA space map header" },
- { byteswap_uint64_array, TRUE, "SPA space map" },
- { byteswap_uint64_array, TRUE, "ZIL intent log" },
- { dnode_buf_byteswap, TRUE, "DMU dnode" },
- { dmu_objset_byteswap, TRUE, "DMU objset" },
- { byteswap_uint64_array, TRUE, "DSL directory" },
- { zap_byteswap, TRUE, "DSL directory child map"},
- { zap_byteswap, TRUE, "DSL dataset snap map" },
- { zap_byteswap, TRUE, "DSL props" },
- { byteswap_uint64_array, TRUE, "DSL dataset" },
- { zfs_znode_byteswap, TRUE, "ZFS znode" },
- { zfs_oldacl_byteswap, TRUE, "ZFS V0 ACL" },
- { byteswap_uint8_array, FALSE, "ZFS plain file" },
- { zap_byteswap, TRUE, "ZFS directory" },
- { zap_byteswap, TRUE, "ZFS master node" },
- { zap_byteswap, TRUE, "ZFS delete queue" },
- { byteswap_uint8_array, FALSE, "zvol object" },
- { zap_byteswap, TRUE, "zvol prop" },
- { byteswap_uint8_array, FALSE, "other uint8[]" },
- { byteswap_uint64_array, FALSE, "other uint64[]" },
- { zap_byteswap, TRUE, "other ZAP" },
- { zap_byteswap, TRUE, "persistent error log" },
- { byteswap_uint8_array, TRUE, "SPA history" },
- { byteswap_uint64_array, TRUE, "SPA history offsets" },
- { zap_byteswap, TRUE, "Pool properties" },
- { zap_byteswap, TRUE, "DSL permissions" },
- { zfs_acl_byteswap, TRUE, "ZFS ACL" },
- { byteswap_uint8_array, TRUE, "ZFS SYSACL" },
- { byteswap_uint8_array, TRUE, "FUID table" },
- { byteswap_uint64_array, TRUE, "FUID table size" },
- { zap_byteswap, TRUE, "DSL dataset next clones"},
- { zap_byteswap, TRUE, "scan work queue" },
- { zap_byteswap, TRUE, "ZFS user/group used" },
- { zap_byteswap, TRUE, "ZFS user/group quota" },
- { zap_byteswap, TRUE, "snapshot refcount tags"},
- { zap_byteswap, TRUE, "DDT ZAP algorithm" },
- { zap_byteswap, TRUE, "DDT statistics" },
- { byteswap_uint8_array, TRUE, "System attributes" },
- { zap_byteswap, TRUE, "SA master node" },
- { zap_byteswap, TRUE, "SA attr registration" },
- { zap_byteswap, TRUE, "SA attr layouts" },
- { zap_byteswap, TRUE, "scan translations" },
- { byteswap_uint8_array, FALSE, "deduplicated block" },
- { zap_byteswap, TRUE, "DSL deadlist map" },
- { byteswap_uint64_array, TRUE, "DSL deadlist map hdr" },
- { zap_byteswap, TRUE, "DSL dir clones" },
- { byteswap_uint64_array, TRUE, "bpobj subobj" },
+ { DMU_BSWAP_UINT8, TRUE, "unallocated" },
+ { DMU_BSWAP_ZAP, TRUE, "object directory" },
+ { DMU_BSWAP_UINT64, TRUE, "object array" },
+ { DMU_BSWAP_UINT8, TRUE, "packed nvlist" },
+ { DMU_BSWAP_UINT64, TRUE, "packed nvlist size" },
+ { DMU_BSWAP_UINT64, TRUE, "bpobj" },
+ { DMU_BSWAP_UINT64, TRUE, "bpobj header" },
+ { DMU_BSWAP_UINT64, TRUE, "SPA space map header" },
+ { DMU_BSWAP_UINT64, TRUE, "SPA space map" },
+ { DMU_BSWAP_UINT64, TRUE, "ZIL intent log" },
+ { DMU_BSWAP_DNODE, TRUE, "DMU dnode" },
+ { DMU_BSWAP_OBJSET, TRUE, "DMU objset" },
+ { DMU_BSWAP_UINT64, TRUE, "DSL directory" },
+ { DMU_BSWAP_ZAP, TRUE, "DSL directory child map"},
+ { DMU_BSWAP_ZAP, TRUE, "DSL dataset snap map" },
+ { DMU_BSWAP_ZAP, TRUE, "DSL props" },
+ { DMU_BSWAP_UINT64, TRUE, "DSL dataset" },
+ { DMU_BSWAP_ZNODE, TRUE, "ZFS znode" },
+ { DMU_BSWAP_OLDACL, TRUE, "ZFS V0 ACL" },
+ { DMU_BSWAP_UINT8, FALSE, "ZFS plain file" },
+ { DMU_BSWAP_ZAP, TRUE, "ZFS directory" },
+ { DMU_BSWAP_ZAP, TRUE, "ZFS master node" },
+ { DMU_BSWAP_ZAP, TRUE, "ZFS delete queue" },
+ { DMU_BSWAP_UINT8, FALSE, "zvol object" },
+ { DMU_BSWAP_ZAP, TRUE, "zvol prop" },
+ { DMU_BSWAP_UINT8, FALSE, "other uint8[]" },
+ { DMU_BSWAP_UINT64, FALSE, "other uint64[]" },
+ { DMU_BSWAP_ZAP, TRUE, "other ZAP" },
+ { DMU_BSWAP_ZAP, TRUE, "persistent error log" },
+ { DMU_BSWAP_UINT8, TRUE, "SPA history" },
+ { DMU_BSWAP_UINT64, TRUE, "SPA history offsets" },
+ { DMU_BSWAP_ZAP, TRUE, "Pool properties" },
+ { DMU_BSWAP_ZAP, TRUE, "DSL permissions" },
+ { DMU_BSWAP_ACL, TRUE, "ZFS ACL" },
+ { DMU_BSWAP_UINT8, TRUE, "ZFS SYSACL" },
+ { DMU_BSWAP_UINT8, TRUE, "FUID table" },
+ { DMU_BSWAP_UINT64, TRUE, "FUID table size" },
+ { DMU_BSWAP_ZAP, TRUE, "DSL dataset next clones"},
+ { DMU_BSWAP_ZAP, TRUE, "scan work queue" },
+ { DMU_BSWAP_ZAP, TRUE, "ZFS user/group used" },
+ { DMU_BSWAP_ZAP, TRUE, "ZFS user/group quota" },
+ { DMU_BSWAP_ZAP, TRUE, "snapshot refcount tags"},
+ { DMU_BSWAP_ZAP, TRUE, "DDT ZAP algorithm" },
+ { DMU_BSWAP_ZAP, TRUE, "DDT statistics" },
+ { DMU_BSWAP_UINT8, TRUE, "System attributes" },
+ { DMU_BSWAP_ZAP, TRUE, "SA master node" },
+ { DMU_BSWAP_ZAP, TRUE, "SA attr registration" },
+ { DMU_BSWAP_ZAP, TRUE, "SA attr layouts" },
+ { DMU_BSWAP_ZAP, TRUE, "scan translations" },
+ { DMU_BSWAP_UINT8, FALSE, "deduplicated block" },
+ { DMU_BSWAP_ZAP, TRUE, "DSL deadlist map" },
+ { DMU_BSWAP_UINT64, TRUE, "DSL deadlist map hdr" },
+ { DMU_BSWAP_ZAP, TRUE, "DSL dir clones" },
+ { DMU_BSWAP_UINT64, TRUE, "bpobj subobj" }
+};
+
+const dmu_object_byteswap_info_t dmu_ot_byteswap[DMU_BSWAP_NUMFUNCS] = {
+ { byteswap_uint8_array, "uint8" },
+ { byteswap_uint16_array, "uint16" },
+ { byteswap_uint32_array, "uint32" },
+ { byteswap_uint64_array, "uint64" },
+ { zap_byteswap, "zap" },
+ { dnode_buf_byteswap, "dnode" },
+ { dmu_objset_byteswap, "objset" },
+ { zfs_znode_byteswap, "znode" },
+ { zfs_oldacl_byteswap, "oldacl" },
+ { zfs_acl_byteswap, "acl" }
};
int
@@ -177,7 +191,7 @@ dmu_set_bonustype(dmu_buf_t *db_fake, dmu_object_type_t type, dmu_tx_t *tx)
DB_DNODE_ENTER(db);
dn = DB_DNODE(db);
- if (type > DMU_OT_NUMTYPES) {
+ if (!DMU_OT_IS_VALID(type)) {
error = EINVAL;
} else if (dn->dn_bonus != db) {
error = EINVAL;
@@ -1505,7 +1519,7 @@ void
dmu_write_policy(objset_t *os, dnode_t *dn, int level, int wp, zio_prop_t *zp)
{
dmu_object_type_t type = dn ? dn->dn_type : DMU_OT_OBJSET;
- boolean_t ismd = (level > 0 || dmu_ot[type].ot_metadata ||
+ boolean_t ismd = (level > 0 || DMU_OT_IS_METADATA(type) ||
(wp & WP_SPILL));
enum zio_checksum checksum = os->os_checksum;
enum zio_compress compress = os->os_compress;
diff --git a/usr/src/uts/common/fs/zfs/dmu_objset.c b/usr/src/uts/common/fs/zfs/dmu_objset.c
index 7caebd979f..09c4ecf4dd 100644
--- a/usr/src/uts/common/fs/zfs/dmu_objset.c
+++ b/usr/src/uts/common/fs/zfs/dmu_objset.c
@@ -20,6 +20,7 @@
*/
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012 by Delphix. All rights reserved.
*/
/* Portions Copyright 2010 Robert Milkowski */
@@ -699,30 +700,33 @@ dmu_objset_create_sync(void *arg1, void *arg2, dmu_tx_t *tx)
spa_t *spa = dd->dd_pool->dp_spa;
struct oscarg *oa = arg2;
uint64_t obj;
+ dsl_dataset_t *ds;
+ blkptr_t *bp;
ASSERT(dmu_tx_is_syncing(tx));
obj = dsl_dataset_create_sync(dd, oa->lastname,
oa->clone_origin, oa->flags, oa->cr, tx);
- if (oa->clone_origin == NULL) {
- dsl_pool_t *dp = dd->dd_pool;
- dsl_dataset_t *ds;
- blkptr_t *bp;
- objset_t *os;
-
- VERIFY3U(0, ==, dsl_dataset_hold_obj(dp, obj, FTAG, &ds));
- bp = dsl_dataset_get_blkptr(ds);
- ASSERT(BP_IS_HOLE(bp));
-
- os = dmu_objset_create_impl(spa, ds, bp, oa->type, tx);
+ VERIFY3U(0, ==, dsl_dataset_hold_obj(dd->dd_pool, obj, FTAG, &ds));
+ bp = dsl_dataset_get_blkptr(ds);
+ if (BP_IS_HOLE(bp)) {
+ objset_t *os =
+ dmu_objset_create_impl(spa, ds, bp, oa->type, tx);
if (oa->userfunc)
oa->userfunc(os, oa->userarg, oa->cr, tx);
- dsl_dataset_rele(ds, FTAG);
}
- spa_history_log_internal(LOG_DS_CREATE, spa, tx, "dataset = %llu", obj);
+ if (oa->clone_origin == NULL) {
+ spa_history_log_internal_ds(ds, "create", tx, "");
+ } else {
+ char namebuf[MAXNAMELEN];
+ dsl_dataset_name(oa->clone_origin, namebuf);
+ spa_history_log_internal_ds(ds, "clone", tx,
+ "origin=%s (%llu)", namebuf, oa->clone_origin->ds_object);
+ }
+ dsl_dataset_rele(ds, FTAG);
}
int
@@ -799,34 +803,40 @@ dmu_objset_destroy(const char *name, boolean_t defer)
return (error);
}
-struct snaparg {
- dsl_sync_task_group_t *dstg;
- char *snapname;
- char *htag;
- char failed[MAXPATHLEN];
- boolean_t recursive;
- boolean_t needsuspend;
- boolean_t temporary;
- nvlist_t *props;
- struct dsl_ds_holdarg *ha; /* only needed in the temporary case */
- dsl_dataset_t *newds;
-};
+typedef struct snapallarg {
+ dsl_sync_task_group_t *saa_dstg;
+ boolean_t saa_needsuspend;
+ nvlist_t *saa_props;
+
+ /* the following are used only if 'temporary' is set: */
+ boolean_t saa_temporary;
+ const char *saa_htag;
+ struct dsl_ds_holdarg *saa_ha;
+ dsl_dataset_t *saa_newds;
+} snapallarg_t;
+
+typedef struct snaponearg {
+ const char *soa_longname; /* long snap name */
+ const char *soa_snapname; /* short snap name */
+ snapallarg_t *soa_saa;
+} snaponearg_t;
static int
snapshot_check(void *arg1, void *arg2, dmu_tx_t *tx)
{
objset_t *os = arg1;
- struct snaparg *sn = arg2;
+ snaponearg_t *soa = arg2;
+ snapallarg_t *saa = soa->soa_saa;
int error;
/* The props have already been checked by zfs_check_userprops(). */
error = dsl_dataset_snapshot_check(os->os_dsl_dataset,
- sn->snapname, tx);
+ soa->soa_snapname, tx);
if (error)
return (error);
- if (sn->temporary) {
+ if (saa->saa_temporary) {
/*
* Ideally we would just call
* dsl_dataset_user_hold_check() and
@@ -844,12 +854,13 @@ snapshot_check(void *arg1, void *arg2, dmu_tx_t *tx)
* Not checking number of tags because the tag will be
* unique, as it will be the only tag.
*/
- if (strlen(sn->htag) + MAX_TAG_PREFIX_LEN >= MAXNAMELEN)
+ if (strlen(saa->saa_htag) + MAX_TAG_PREFIX_LEN >= MAXNAMELEN)
return (E2BIG);
- sn->ha = kmem_alloc(sizeof (struct dsl_ds_holdarg), KM_SLEEP);
- sn->ha->temphold = B_TRUE;
- sn->ha->htag = sn->htag;
+ saa->saa_ha = kmem_alloc(sizeof (struct dsl_ds_holdarg),
+ KM_SLEEP);
+ saa->saa_ha->temphold = B_TRUE;
+ saa->saa_ha->htag = saa->saa_htag;
}
return (error);
}
@@ -859,24 +870,25 @@ snapshot_sync(void *arg1, void *arg2, dmu_tx_t *tx)
{
objset_t *os = arg1;
dsl_dataset_t *ds = os->os_dsl_dataset;
- struct snaparg *sn = arg2;
+ snaponearg_t *soa = arg2;
+ snapallarg_t *saa = soa->soa_saa;
- dsl_dataset_snapshot_sync(ds, sn->snapname, tx);
+ dsl_dataset_snapshot_sync(ds, soa->soa_snapname, tx);
- if (sn->props) {
+ if (saa->saa_props != NULL) {
dsl_props_arg_t pa;
- pa.pa_props = sn->props;
+ pa.pa_props = saa->saa_props;
pa.pa_source = ZPROP_SRC_LOCAL;
dsl_props_set_sync(ds->ds_prev, &pa, tx);
}
- if (sn->temporary) {
+ if (saa->saa_temporary) {
struct dsl_ds_destroyarg da;
- dsl_dataset_user_hold_sync(ds->ds_prev, sn->ha, tx);
- kmem_free(sn->ha, sizeof (struct dsl_ds_holdarg));
- sn->ha = NULL;
- sn->newds = ds->ds_prev;
+ dsl_dataset_user_hold_sync(ds->ds_prev, saa->saa_ha, tx);
+ kmem_free(saa->saa_ha, sizeof (struct dsl_ds_holdarg));
+ saa->saa_ha = NULL;
+ saa->saa_newds = ds->ds_prev;
da.ds = ds->ds_prev;
da.defer = B_TRUE;
@@ -885,131 +897,180 @@ snapshot_sync(void *arg1, void *arg2, dmu_tx_t *tx)
}
static int
-dmu_objset_snapshot_one(const char *name, void *arg)
+snapshot_one_impl(const char *snapname, void *arg)
{
- struct snaparg *sn = arg;
+ char fsname[MAXPATHLEN];
+ snapallarg_t *saa = arg;
+ snaponearg_t *soa;
objset_t *os;
int err;
- char *cp;
-
- /*
- * If the objset starts with a '%', then ignore it unless it was
- * explicitly named (ie, not recursive). These hidden datasets
- * are always inconsistent, and by not opening them here, we can
- * avoid a race with dsl_dir_destroy_check().
- */
- cp = strrchr(name, '/');
- if (cp && cp[1] == '%' && sn->recursive)
- return (0);
- (void) strcpy(sn->failed, name);
-
- /*
- * Check permissions if we are doing a recursive snapshot. The
- * permission checks for the starting dataset have already been
- * performed in zfs_secpolicy_snapshot()
- */
- if (sn->recursive && (err = zfs_secpolicy_snapshot_perms(name, CRED())))
- return (err);
+ (void) strlcpy(fsname, snapname, sizeof (fsname));
+ strchr(fsname, '@')[0] = '\0';
- err = dmu_objset_hold(name, sn, &os);
+ err = dmu_objset_hold(fsname, saa, &os);
if (err != 0)
return (err);
/*
* If the objset is in an inconsistent state (eg, in the process
- * of being destroyed), don't snapshot it. As with %hidden
- * datasets, we return EBUSY if this name was explicitly
- * requested (ie, not recursive), and otherwise ignore it.
+ * of being destroyed), don't snapshot it.
*/
if (os->os_dsl_dataset->ds_phys->ds_flags & DS_FLAG_INCONSISTENT) {
- dmu_objset_rele(os, sn);
- return (sn->recursive ? 0 : EBUSY);
+ dmu_objset_rele(os, saa);
+ return (EBUSY);
}
- if (sn->needsuspend) {
+ if (saa->saa_needsuspend) {
err = zil_suspend(dmu_objset_zil(os));
if (err) {
- dmu_objset_rele(os, sn);
+ dmu_objset_rele(os, saa);
return (err);
}
}
- dsl_sync_task_create(sn->dstg, snapshot_check, snapshot_sync,
- os, sn, 3);
+
+ soa = kmem_zalloc(sizeof (*soa), KM_SLEEP);
+ soa->soa_saa = saa;
+ soa->soa_longname = snapname;
+ soa->soa_snapname = strchr(snapname, '@') + 1;
+
+ dsl_sync_task_create(saa->saa_dstg, snapshot_check, snapshot_sync,
+ os, soa, 3);
return (0);
}
+/*
+ * The snapshots must all be in the same pool.
+ */
int
-dmu_objset_snapshot(char *fsname, char *snapname, char *tag,
- nvlist_t *props, boolean_t recursive, boolean_t temporary, int cleanup_fd)
+dmu_objset_snapshot(nvlist_t *snaps, nvlist_t *props, nvlist_t *errors)
{
dsl_sync_task_t *dst;
- struct snaparg sn;
+ snapallarg_t saa = { 0 };
spa_t *spa;
- minor_t minor;
+ int rv = 0;
int err;
+ nvpair_t *pair;
- (void) strcpy(sn.failed, fsname);
+ pair = nvlist_next_nvpair(snaps, NULL);
+ if (pair == NULL)
+ return (0);
- err = spa_open(fsname, &spa, FTAG);
+ err = spa_open(nvpair_name(pair), &spa, FTAG);
if (err)
return (err);
-
- if (temporary) {
- if (cleanup_fd < 0) {
- spa_close(spa, FTAG);
- return (EINVAL);
+ saa.saa_dstg = dsl_sync_task_group_create(spa_get_dsl(spa));
+ saa.saa_props = props;
+ saa.saa_needsuspend = (spa_version(spa) < SPA_VERSION_FAST_SNAP);
+
+ for (pair = nvlist_next_nvpair(snaps, NULL); pair != NULL;
+ pair = nvlist_next_nvpair(snaps, pair)) {
+ err = snapshot_one_impl(nvpair_name(pair), &saa);
+ if (err != 0) {
+ if (errors != NULL) {
+ fnvlist_add_int32(errors,
+ nvpair_name(pair), err);
+ }
+ rv = err;
}
- if ((err = zfs_onexit_fd_hold(cleanup_fd, &minor)) != 0) {
- spa_close(spa, FTAG);
- return (err);
+ }
+
+ /*
+ * If any call to snapshot_one_impl() failed, don't execute the
+ * sync task. The error handling code below will clean up the
+ * snaponearg_t from any successful calls to
+ * snapshot_one_impl().
+ */
+ if (rv == 0)
+ err = dsl_sync_task_group_wait(saa.saa_dstg);
+ if (err != 0)
+ rv = err;
+
+ for (dst = list_head(&saa.saa_dstg->dstg_tasks); dst;
+ dst = list_next(&saa.saa_dstg->dstg_tasks, dst)) {
+ objset_t *os = dst->dst_arg1;
+ snaponearg_t *soa = dst->dst_arg2;
+ if (dst->dst_err != 0) {
+ if (errors != NULL) {
+ fnvlist_add_int32(errors,
+ soa->soa_longname, dst->dst_err);
+ }
+ rv = dst->dst_err;
}
+
+ if (saa.saa_needsuspend)
+ zil_resume(dmu_objset_zil(os));
+ dmu_objset_rele(os, &saa);
+ kmem_free(soa, sizeof (*soa));
}
- sn.dstg = dsl_sync_task_group_create(spa_get_dsl(spa));
- sn.snapname = snapname;
- sn.htag = tag;
- sn.props = props;
- sn.recursive = recursive;
- sn.needsuspend = (spa_version(spa) < SPA_VERSION_FAST_SNAP);
- sn.temporary = temporary;
- sn.ha = NULL;
- sn.newds = NULL;
-
- if (recursive) {
- err = dmu_objset_find(fsname,
- dmu_objset_snapshot_one, &sn, DS_FIND_CHILDREN);
- } else {
- err = dmu_objset_snapshot_one(fsname, &sn);
+ dsl_sync_task_group_destroy(saa.saa_dstg);
+ spa_close(spa, FTAG);
+ return (rv);
+}
+
+int
+dmu_objset_snapshot_one(const char *fsname, const char *snapname)
+{
+ int err;
+ char *longsnap = kmem_asprintf("%s@%s", fsname, snapname);
+ nvlist_t *snaps = fnvlist_alloc();
+
+ fnvlist_add_boolean(snaps, longsnap);
+ err = dmu_objset_snapshot(snaps, NULL, NULL);
+ fnvlist_free(snaps);
+ strfree(longsnap);
+ return (err);
+}
+
+int
+dmu_objset_snapshot_tmp(const char *snapname, const char *tag, int cleanup_fd)
+{
+ dsl_sync_task_t *dst;
+ snapallarg_t saa = { 0 };
+ spa_t *spa;
+ minor_t minor;
+ int err;
+
+ err = spa_open(snapname, &spa, FTAG);
+ if (err)
+ return (err);
+ saa.saa_dstg = dsl_sync_task_group_create(spa_get_dsl(spa));
+ saa.saa_htag = tag;
+ saa.saa_needsuspend = (spa_version(spa) < SPA_VERSION_FAST_SNAP);
+ saa.saa_temporary = B_TRUE;
+
+ if (cleanup_fd < 0) {
+ spa_close(spa, FTAG);
+ return (EINVAL);
+ }
+ if ((err = zfs_onexit_fd_hold(cleanup_fd, &minor)) != 0) {
+ spa_close(spa, FTAG);
+ return (err);
}
+ err = snapshot_one_impl(snapname, &saa);
+
if (err == 0)
- err = dsl_sync_task_group_wait(sn.dstg);
+ err = dsl_sync_task_group_wait(saa.saa_dstg);
- for (dst = list_head(&sn.dstg->dstg_tasks); dst;
- dst = list_next(&sn.dstg->dstg_tasks, dst)) {
+ for (dst = list_head(&saa.saa_dstg->dstg_tasks); dst;
+ dst = list_next(&saa.saa_dstg->dstg_tasks, dst)) {
objset_t *os = dst->dst_arg1;
- dsl_dataset_t *ds = os->os_dsl_dataset;
- if (dst->dst_err) {
- dsl_dataset_name(ds, sn.failed);
- } else if (temporary) {
- dsl_register_onexit_hold_cleanup(sn.newds, tag, minor);
- }
- if (sn.needsuspend)
+ dsl_register_onexit_hold_cleanup(saa.saa_newds, tag, minor);
+ if (saa.saa_needsuspend)
zil_resume(dmu_objset_zil(os));
- dmu_objset_rele(os, &sn);
+ dmu_objset_rele(os, &saa);
}
- if (err)
- (void) strcpy(fsname, sn.failed);
- if (temporary)
- zfs_onexit_fd_rele(cleanup_fd);
- dsl_sync_task_group_destroy(sn.dstg);
+ zfs_onexit_fd_rele(cleanup_fd);
+ dsl_sync_task_group_destroy(saa.saa_dstg);
spa_close(spa, FTAG);
return (err);
}
+
static void
dmu_objset_sync_dnodes(list_t *list, list_t *newlist, dmu_tx_t *tx)
{
diff --git a/usr/src/uts/common/fs/zfs/dmu_send.c b/usr/src/uts/common/fs/zfs/dmu_send.c
index fc94f35805..5a2c6e2ce7 100644
--- a/usr/src/uts/common/fs/zfs/dmu_send.c
+++ b/usr/src/uts/common/fs/zfs/dmu_send.c
@@ -20,11 +20,9 @@
*/
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2011 by Delphix. All rights reserved.
- */
-/*
* Copyright 2011 Nexenta Systems, Inc. All rights reserved.
- * Copyright (c) 2011 by Delphix. All rights reserved.
+ * Copyright (c) 2012 by Delphix. All rights reserved.
+ * Copyright (c) 2012, Joyent, Inc. All rights reserved.
*/
#include <sys/dmu.h>
@@ -54,48 +52,33 @@ int zfs_send_corrupt_data = B_FALSE;
static char *dmu_recv_tag = "dmu_recv_tag";
-/*
- * The list of data whose inclusion in a send stream can be pending from
- * one call to backup_cb to another. Multiple calls to dump_free() and
- * dump_freeobjects() can be aggregated into a single DRR_FREE or
- * DRR_FREEOBJECTS replay record.
- */
-typedef enum {
- PENDING_NONE,
- PENDING_FREE,
- PENDING_FREEOBJECTS
-} pendop_t;
-
-struct backuparg {
- dmu_replay_record_t *drr;
- vnode_t *vp;
- offset_t *off;
- objset_t *os;
- zio_cksum_t zc;
- uint64_t toguid;
- int err;
- pendop_t pending_op;
-};
-
static int
-dump_bytes(struct backuparg *ba, void *buf, int len)
+dump_bytes(dmu_sendarg_t *dsp, void *buf, int len)
{
+ dsl_dataset_t *ds = dsp->dsa_os->os_dsl_dataset;
ssize_t resid; /* have to get resid to get detailed errno */
ASSERT3U(len % 8, ==, 0);
- fletcher_4_incremental_native(buf, len, &ba->zc);
- ba->err = vn_rdwr(UIO_WRITE, ba->vp,
+ fletcher_4_incremental_native(buf, len, &dsp->dsa_zc);
+ dsp->dsa_err = vn_rdwr(UIO_WRITE, dsp->dsa_vp,
(caddr_t)buf, len,
0, UIO_SYSSPACE, FAPPEND, RLIM64_INFINITY, CRED(), &resid);
- *ba->off += len;
- return (ba->err);
+
+ mutex_enter(&ds->ds_sendstream_lock);
+ *dsp->dsa_off += len;
+ mutex_exit(&ds->ds_sendstream_lock);
+
+ return (dsp->dsa_err);
}
static int
-dump_free(struct backuparg *ba, uint64_t object, uint64_t offset,
+dump_free(dmu_sendarg_t *dsp, uint64_t object, uint64_t offset,
uint64_t length)
{
- struct drr_free *drrf = &(ba->drr->drr_u.drr_free);
+ struct drr_free *drrf = &(dsp->dsa_drr->drr_u.drr_free);
+
+ if (length != -1ULL && offset + length < offset)
+ length = -1ULL;
/*
* If there is a pending op, but it's not PENDING_FREE, push it out,
@@ -104,13 +87,15 @@ dump_free(struct backuparg *ba, uint64_t object, uint64_t offset,
* other DRR_FREE records. DRR_FREEOBJECTS records can only be
* aggregated with other DRR_FREEOBJECTS records.
*/
- if (ba->pending_op != PENDING_NONE && ba->pending_op != PENDING_FREE) {
- if (dump_bytes(ba, ba->drr, sizeof (dmu_replay_record_t)) != 0)
+ if (dsp->dsa_pending_op != PENDING_NONE &&
+ dsp->dsa_pending_op != PENDING_FREE) {
+ if (dump_bytes(dsp, dsp->dsa_drr,
+ sizeof (dmu_replay_record_t)) != 0)
return (EINTR);
- ba->pending_op = PENDING_NONE;
+ dsp->dsa_pending_op = PENDING_NONE;
}
- if (ba->pending_op == PENDING_FREE) {
+ if (dsp->dsa_pending_op == PENDING_FREE) {
/*
* There should never be a PENDING_FREE if length is -1
* (because dump_dnode is the only place where this
@@ -128,34 +113,35 @@ dump_free(struct backuparg *ba, uint64_t object, uint64_t offset,
return (0);
} else {
/* not a continuation. Push out pending record */
- if (dump_bytes(ba, ba->drr,
+ if (dump_bytes(dsp, dsp->dsa_drr,
sizeof (dmu_replay_record_t)) != 0)
return (EINTR);
- ba->pending_op = PENDING_NONE;
+ dsp->dsa_pending_op = PENDING_NONE;
}
}
/* create a FREE record and make it pending */
- bzero(ba->drr, sizeof (dmu_replay_record_t));
- ba->drr->drr_type = DRR_FREE;
+ bzero(dsp->dsa_drr, sizeof (dmu_replay_record_t));
+ dsp->dsa_drr->drr_type = DRR_FREE;
drrf->drr_object = object;
drrf->drr_offset = offset;
drrf->drr_length = length;
- drrf->drr_toguid = ba->toguid;
+ drrf->drr_toguid = dsp->dsa_toguid;
if (length == -1ULL) {
- if (dump_bytes(ba, ba->drr, sizeof (dmu_replay_record_t)) != 0)
+ if (dump_bytes(dsp, dsp->dsa_drr,
+ sizeof (dmu_replay_record_t)) != 0)
return (EINTR);
} else {
- ba->pending_op = PENDING_FREE;
+ dsp->dsa_pending_op = PENDING_FREE;
}
return (0);
}
static int
-dump_data(struct backuparg *ba, dmu_object_type_t type,
+dump_data(dmu_sendarg_t *dsp, dmu_object_type_t type,
uint64_t object, uint64_t offset, int blksz, const blkptr_t *bp, void *data)
{
- struct drr_write *drrw = &(ba->drr->drr_u.drr_write);
+ struct drr_write *drrw = &(dsp->dsa_drr->drr_u.drr_write);
/*
@@ -164,19 +150,20 @@ dump_data(struct backuparg *ba, dmu_object_type_t type,
* the stream, since aggregation can't be done across operations
* of different types.
*/
- if (ba->pending_op != PENDING_NONE) {
- if (dump_bytes(ba, ba->drr, sizeof (dmu_replay_record_t)) != 0)
+ if (dsp->dsa_pending_op != PENDING_NONE) {
+ if (dump_bytes(dsp, dsp->dsa_drr,
+ sizeof (dmu_replay_record_t)) != 0)
return (EINTR);
- ba->pending_op = PENDING_NONE;
+ dsp->dsa_pending_op = PENDING_NONE;
}
/* write a DATA record */
- bzero(ba->drr, sizeof (dmu_replay_record_t));
- ba->drr->drr_type = DRR_WRITE;
+ bzero(dsp->dsa_drr, sizeof (dmu_replay_record_t));
+ dsp->dsa_drr->drr_type = DRR_WRITE;
drrw->drr_object = object;
drrw->drr_type = type;
drrw->drr_offset = offset;
drrw->drr_length = blksz;
- drrw->drr_toguid = ba->toguid;
+ drrw->drr_toguid = dsp->dsa_toguid;
drrw->drr_checksumtype = BP_GET_CHECKSUM(bp);
if (zio_checksum_table[drrw->drr_checksumtype].ci_dedup)
drrw->drr_checksumflags |= DRR_CHECKSUM_DEDUP;
@@ -185,42 +172,43 @@ dump_data(struct backuparg *ba, dmu_object_type_t type,
DDK_SET_COMPRESS(&drrw->drr_key, BP_GET_COMPRESS(bp));
drrw->drr_key.ddk_cksum = bp->blk_cksum;
- if (dump_bytes(ba, ba->drr, sizeof (dmu_replay_record_t)) != 0)
+ if (dump_bytes(dsp, dsp->dsa_drr, sizeof (dmu_replay_record_t)) != 0)
return (EINTR);
- if (dump_bytes(ba, data, blksz) != 0)
+ if (dump_bytes(dsp, data, blksz) != 0)
return (EINTR);
return (0);
}
static int
-dump_spill(struct backuparg *ba, uint64_t object, int blksz, void *data)
+dump_spill(dmu_sendarg_t *dsp, uint64_t object, int blksz, void *data)
{
- struct drr_spill *drrs = &(ba->drr->drr_u.drr_spill);
+ struct drr_spill *drrs = &(dsp->dsa_drr->drr_u.drr_spill);
- if (ba->pending_op != PENDING_NONE) {
- if (dump_bytes(ba, ba->drr, sizeof (dmu_replay_record_t)) != 0)
+ if (dsp->dsa_pending_op != PENDING_NONE) {
+ if (dump_bytes(dsp, dsp->dsa_drr,
+ sizeof (dmu_replay_record_t)) != 0)
return (EINTR);
- ba->pending_op = PENDING_NONE;
+ dsp->dsa_pending_op = PENDING_NONE;
}
/* write a SPILL record */
- bzero(ba->drr, sizeof (dmu_replay_record_t));
- ba->drr->drr_type = DRR_SPILL;
+ bzero(dsp->dsa_drr, sizeof (dmu_replay_record_t));
+ dsp->dsa_drr->drr_type = DRR_SPILL;
drrs->drr_object = object;
drrs->drr_length = blksz;
- drrs->drr_toguid = ba->toguid;
+ drrs->drr_toguid = dsp->dsa_toguid;
- if (dump_bytes(ba, ba->drr, sizeof (dmu_replay_record_t)))
+ if (dump_bytes(dsp, dsp->dsa_drr, sizeof (dmu_replay_record_t)))
return (EINTR);
- if (dump_bytes(ba, data, blksz))
+ if (dump_bytes(dsp, data, blksz))
return (EINTR);
return (0);
}
static int
-dump_freeobjects(struct backuparg *ba, uint64_t firstobj, uint64_t numobjs)
+dump_freeobjects(dmu_sendarg_t *dsp, uint64_t firstobj, uint64_t numobjs)
{
- struct drr_freeobjects *drrfo = &(ba->drr->drr_u.drr_freeobjects);
+ struct drr_freeobjects *drrfo = &(dsp->dsa_drr->drr_u.drr_freeobjects);
/*
* If there is a pending op, but it's not PENDING_FREEOBJECTS,
@@ -229,13 +217,14 @@ dump_freeobjects(struct backuparg *ba, uint64_t firstobj, uint64_t numobjs)
* aggregated with other DRR_FREE records. DRR_FREEOBJECTS records
* can only be aggregated with other DRR_FREEOBJECTS records.
*/
- if (ba->pending_op != PENDING_NONE &&
- ba->pending_op != PENDING_FREEOBJECTS) {
- if (dump_bytes(ba, ba->drr, sizeof (dmu_replay_record_t)) != 0)
+ if (dsp->dsa_pending_op != PENDING_NONE &&
+ dsp->dsa_pending_op != PENDING_FREEOBJECTS) {
+ if (dump_bytes(dsp, dsp->dsa_drr,
+ sizeof (dmu_replay_record_t)) != 0)
return (EINTR);
- ba->pending_op = PENDING_NONE;
+ dsp->dsa_pending_op = PENDING_NONE;
}
- if (ba->pending_op == PENDING_FREEOBJECTS) {
+ if (dsp->dsa_pending_op == PENDING_FREEOBJECTS) {
/*
* See whether this free object array can be aggregated
* with pending one
@@ -245,42 +234,43 @@ dump_freeobjects(struct backuparg *ba, uint64_t firstobj, uint64_t numobjs)
return (0);
} else {
/* can't be aggregated. Push out pending record */
- if (dump_bytes(ba, ba->drr,
+ if (dump_bytes(dsp, dsp->dsa_drr,
sizeof (dmu_replay_record_t)) != 0)
return (EINTR);
- ba->pending_op = PENDING_NONE;
+ dsp->dsa_pending_op = PENDING_NONE;
}
}
/* write a FREEOBJECTS record */
- bzero(ba->drr, sizeof (dmu_replay_record_t));
- ba->drr->drr_type = DRR_FREEOBJECTS;
+ bzero(dsp->dsa_drr, sizeof (dmu_replay_record_t));
+ dsp->dsa_drr->drr_type = DRR_FREEOBJECTS;
drrfo->drr_firstobj = firstobj;
drrfo->drr_numobjs = numobjs;
- drrfo->drr_toguid = ba->toguid;
+ drrfo->drr_toguid = dsp->dsa_toguid;
- ba->pending_op = PENDING_FREEOBJECTS;
+ dsp->dsa_pending_op = PENDING_FREEOBJECTS;
return (0);
}
static int
-dump_dnode(struct backuparg *ba, uint64_t object, dnode_phys_t *dnp)
+dump_dnode(dmu_sendarg_t *dsp, uint64_t object, dnode_phys_t *dnp)
{
- struct drr_object *drro = &(ba->drr->drr_u.drr_object);
+ struct drr_object *drro = &(dsp->dsa_drr->drr_u.drr_object);
if (dnp == NULL || dnp->dn_type == DMU_OT_NONE)
- return (dump_freeobjects(ba, object, 1));
+ return (dump_freeobjects(dsp, object, 1));
- if (ba->pending_op != PENDING_NONE) {
- if (dump_bytes(ba, ba->drr, sizeof (dmu_replay_record_t)) != 0)
+ if (dsp->dsa_pending_op != PENDING_NONE) {
+ if (dump_bytes(dsp, dsp->dsa_drr,
+ sizeof (dmu_replay_record_t)) != 0)
return (EINTR);
- ba->pending_op = PENDING_NONE;
+ dsp->dsa_pending_op = PENDING_NONE;
}
/* write an OBJECT record */
- bzero(ba->drr, sizeof (dmu_replay_record_t));
- ba->drr->drr_type = DRR_OBJECT;
+ bzero(dsp->dsa_drr, sizeof (dmu_replay_record_t));
+ dsp->dsa_drr->drr_type = DRR_OBJECT;
drro->drr_object = object;
drro->drr_type = dnp->dn_type;
drro->drr_bonustype = dnp->dn_bonustype;
@@ -288,19 +278,19 @@ dump_dnode(struct backuparg *ba, uint64_t object, dnode_phys_t *dnp)
drro->drr_bonuslen = dnp->dn_bonuslen;
drro->drr_checksumtype = dnp->dn_checksum;
drro->drr_compress = dnp->dn_compress;
- drro->drr_toguid = ba->toguid;
+ drro->drr_toguid = dsp->dsa_toguid;
- if (dump_bytes(ba, ba->drr, sizeof (dmu_replay_record_t)) != 0)
+ if (dump_bytes(dsp, dsp->dsa_drr, sizeof (dmu_replay_record_t)) != 0)
return (EINTR);
- if (dump_bytes(ba, DN_BONUS(dnp), P2ROUNDUP(dnp->dn_bonuslen, 8)) != 0)
+ if (dump_bytes(dsp, DN_BONUS(dnp), P2ROUNDUP(dnp->dn_bonuslen, 8)) != 0)
return (EINTR);
/* free anything past the end of the file */
- if (dump_free(ba, object, (dnp->dn_maxblkid + 1) *
+ if (dump_free(dsp, object, (dnp->dn_maxblkid + 1) *
(dnp->dn_datablkszsec << SPA_MINBLOCKSHIFT), -1ULL))
return (EINTR);
- if (ba->err)
+ if (dsp->dsa_err)
return (EINTR);
return (0);
}
@@ -314,7 +304,7 @@ static int
backup_cb(spa_t *spa, zilog_t *zilog, const blkptr_t *bp, arc_buf_t *pbuf,
const zbookmark_t *zb, const dnode_phys_t *dnp, void *arg)
{
- struct backuparg *ba = arg;
+ dmu_sendarg_t *dsp = arg;
dmu_object_type_t type = bp ? BP_GET_TYPE(bp) : DMU_OT_NONE;
int err = 0;
@@ -327,10 +317,10 @@ backup_cb(spa_t *spa, zilog_t *zilog, const blkptr_t *bp, arc_buf_t *pbuf,
} else if (bp == NULL && zb->zb_object == DMU_META_DNODE_OBJECT) {
uint64_t span = BP_SPAN(dnp, zb->zb_level);
uint64_t dnobj = (zb->zb_blkid * span) >> DNODE_SHIFT;
- err = dump_freeobjects(ba, dnobj, span >> DNODE_SHIFT);
+ err = dump_freeobjects(dsp, dnobj, span >> DNODE_SHIFT);
} else if (bp == NULL) {
uint64_t span = BP_SPAN(dnp, zb->zb_level);
- err = dump_free(ba, zb->zb_object, zb->zb_blkid * span, span);
+ err = dump_free(dsp, zb->zb_object, zb->zb_blkid * span, span);
} else if (zb->zb_level > 0 || type == DMU_OT_OBJSET) {
return (0);
} else if (type == DMU_OT_DNODE) {
@@ -349,7 +339,7 @@ backup_cb(spa_t *spa, zilog_t *zilog, const blkptr_t *bp, arc_buf_t *pbuf,
for (i = 0; i < blksz >> DNODE_SHIFT; i++) {
uint64_t dnobj = (zb->zb_blkid <<
(DNODE_BLOCK_SHIFT - DNODE_SHIFT)) + i;
- err = dump_dnode(ba, dnobj, blk+i);
+ err = dump_dnode(dsp, dnobj, blk+i);
if (err)
break;
}
@@ -364,7 +354,7 @@ backup_cb(spa_t *spa, zilog_t *zilog, const blkptr_t *bp, arc_buf_t *pbuf,
ZIO_FLAG_CANFAIL, &aflags, zb) != 0)
return (EIO);
- err = dump_spill(ba, zb->zb_object, blksz, abuf->b_data);
+ err = dump_spill(dsp, zb->zb_object, blksz, abuf->b_data);
(void) arc_buf_remove_ref(abuf, &abuf);
} else { /* it's a level-0 block of a regular object */
uint32_t aflags = ARC_WAIT;
@@ -388,7 +378,7 @@ backup_cb(spa_t *spa, zilog_t *zilog, const blkptr_t *bp, arc_buf_t *pbuf,
}
}
- err = dump_data(ba, type, zb->zb_object, zb->zb_blkid * blksz,
+ err = dump_data(dsp, type, zb->zb_object, zb->zb_blkid * blksz,
blksz, bp, abuf->b_data);
(void) arc_buf_remove_ref(abuf, &abuf);
}
@@ -397,14 +387,53 @@ backup_cb(spa_t *spa, zilog_t *zilog, const blkptr_t *bp, arc_buf_t *pbuf,
return (err);
}
+/*
+ * Return TRUE if 'earlier' is an earlier snapshot in 'later's timeline.
+ * For example, they could both be snapshots of the same filesystem, and
+ * 'earlier' is before 'later'. Or 'earlier' could be the origin of
+ * 'later's filesystem. Or 'earlier' could be an older snapshot in the origin's
+ * filesystem. Or 'earlier' could be the origin's origin.
+ */
+static boolean_t
+is_before(dsl_dataset_t *later, dsl_dataset_t *earlier)
+{
+ dsl_pool_t *dp = later->ds_dir->dd_pool;
+ int error;
+ boolean_t ret;
+ dsl_dataset_t *origin;
+
+ if (earlier->ds_phys->ds_creation_txg >=
+ later->ds_phys->ds_creation_txg)
+ return (B_FALSE);
+
+ if (later->ds_dir == earlier->ds_dir)
+ return (B_TRUE);
+ if (!dsl_dir_is_clone(later->ds_dir))
+ return (B_FALSE);
+
+ rw_enter(&dp->dp_config_rwlock, RW_READER);
+ if (later->ds_dir->dd_phys->dd_origin_obj == earlier->ds_object) {
+ rw_exit(&dp->dp_config_rwlock);
+ return (B_TRUE);
+ }
+ error = dsl_dataset_hold_obj(dp,
+ later->ds_dir->dd_phys->dd_origin_obj, FTAG, &origin);
+ rw_exit(&dp->dp_config_rwlock);
+ if (error != 0)
+ return (B_FALSE);
+ ret = is_before(origin, earlier);
+ dsl_dataset_rele(origin, FTAG);
+ return (ret);
+}
+
int
-dmu_sendbackup(objset_t *tosnap, objset_t *fromsnap, boolean_t fromorigin,
- vnode_t *vp, offset_t *off)
+dmu_send(objset_t *tosnap, objset_t *fromsnap, int outfd, vnode_t *vp,
+ offset_t *off)
{
dsl_dataset_t *ds = tosnap->os_dsl_dataset;
dsl_dataset_t *fromds = fromsnap ? fromsnap->os_dsl_dataset : NULL;
dmu_replay_record_t *drr;
- struct backuparg ba;
+ dmu_sendarg_t *dsp;
int err;
uint64_t fromtxg = 0;
@@ -412,30 +441,13 @@ dmu_sendbackup(objset_t *tosnap, objset_t *fromsnap, boolean_t fromorigin,
if (ds->ds_phys->ds_next_snap_obj == 0)
return (EINVAL);
- /* fromsnap must be an earlier snapshot from the same fs as tosnap */
- if (fromds && (ds->ds_dir != fromds->ds_dir ||
- fromds->ds_phys->ds_creation_txg >= ds->ds_phys->ds_creation_txg))
+ /*
+ * fromsnap must be an earlier snapshot from the same fs as tosnap,
+ * or the origin's fs.
+ */
+ if (fromds != NULL && !is_before(ds, fromds))
return (EXDEV);
- if (fromorigin) {
- dsl_pool_t *dp = ds->ds_dir->dd_pool;
-
- if (fromsnap)
- return (EINVAL);
-
- if (dsl_dir_is_clone(ds->ds_dir)) {
- rw_enter(&dp->dp_config_rwlock, RW_READER);
- err = dsl_dataset_hold_obj(dp,
- ds->ds_dir->dd_phys->dd_origin_obj, FTAG, &fromds);
- rw_exit(&dp->dp_config_rwlock);
- if (err)
- return (err);
- } else {
- fromorigin = B_FALSE;
- }
- }
-
-
drr = kmem_zalloc(sizeof (dmu_replay_record_t), KM_SLEEP);
drr->drr_type = DRR_BEGIN;
drr->drr_u.drr_begin.drr_magic = DMU_BACKUP_MAGIC;
@@ -445,8 +457,10 @@ dmu_sendbackup(objset_t *tosnap, objset_t *fromsnap, boolean_t fromorigin,
#ifdef _KERNEL
if (dmu_objset_type(tosnap) == DMU_OST_ZFS) {
uint64_t version;
- if (zfs_get_zplprop(tosnap, ZFS_PROP_VERSION, &version) != 0)
+ if (zfs_get_zplprop(tosnap, ZFS_PROP_VERSION, &version) != 0) {
+ kmem_free(drr, sizeof (dmu_replay_record_t));
return (EINVAL);
+ }
if (version == ZPL_VERSION_SA) {
DMU_SET_FEATUREFLAGS(
drr->drr_u.drr_begin.drr_versioninfo,
@@ -458,7 +472,7 @@ dmu_sendbackup(objset_t *tosnap, objset_t *fromsnap, boolean_t fromorigin,
drr->drr_u.drr_begin.drr_creation_time =
ds->ds_phys->ds_creation_time;
drr->drr_u.drr_begin.drr_type = tosnap->os_phys->os_type;
- if (fromorigin)
+ if (fromds != NULL && ds->ds_dir != fromds->ds_dir)
drr->drr_u.drr_begin.drr_flags |= DRR_FLAG_CLONE;
drr->drr_u.drr_begin.drr_toguid = ds->ds_phys->ds_guid;
if (ds->ds_phys->ds_flags & DS_FLAG_CI_DATASET)
@@ -470,54 +484,64 @@ dmu_sendbackup(objset_t *tosnap, objset_t *fromsnap, boolean_t fromorigin,
if (fromds)
fromtxg = fromds->ds_phys->ds_creation_txg;
- if (fromorigin)
- dsl_dataset_rele(fromds, FTAG);
-
- ba.drr = drr;
- ba.vp = vp;
- ba.os = tosnap;
- ba.off = off;
- ba.toguid = ds->ds_phys->ds_guid;
- ZIO_SET_CHECKSUM(&ba.zc, 0, 0, 0, 0);
- ba.pending_op = PENDING_NONE;
-
- if (dump_bytes(&ba, drr, sizeof (dmu_replay_record_t)) != 0) {
- kmem_free(drr, sizeof (dmu_replay_record_t));
- return (ba.err);
+
+ dsp = kmem_zalloc(sizeof (dmu_sendarg_t), KM_SLEEP);
+
+ dsp->dsa_drr = drr;
+ dsp->dsa_vp = vp;
+ dsp->dsa_outfd = outfd;
+ dsp->dsa_proc = curproc;
+ dsp->dsa_os = tosnap;
+ dsp->dsa_off = off;
+ dsp->dsa_toguid = ds->ds_phys->ds_guid;
+ ZIO_SET_CHECKSUM(&dsp->dsa_zc, 0, 0, 0, 0);
+ dsp->dsa_pending_op = PENDING_NONE;
+
+ mutex_enter(&ds->ds_sendstream_lock);
+ list_insert_head(&ds->ds_sendstreams, dsp);
+ mutex_exit(&ds->ds_sendstream_lock);
+
+ if (dump_bytes(dsp, drr, sizeof (dmu_replay_record_t)) != 0) {
+ err = dsp->dsa_err;
+ goto out;
}
err = traverse_dataset(ds, fromtxg, TRAVERSE_PRE | TRAVERSE_PREFETCH,
- backup_cb, &ba);
+ backup_cb, dsp);
- if (ba.pending_op != PENDING_NONE)
- if (dump_bytes(&ba, drr, sizeof (dmu_replay_record_t)) != 0)
+ if (dsp->dsa_pending_op != PENDING_NONE)
+ if (dump_bytes(dsp, drr, sizeof (dmu_replay_record_t)) != 0)
err = EINTR;
if (err) {
- if (err == EINTR && ba.err)
- err = ba.err;
- kmem_free(drr, sizeof (dmu_replay_record_t));
- return (err);
+ if (err == EINTR && dsp->dsa_err)
+ err = dsp->dsa_err;
+ goto out;
}
bzero(drr, sizeof (dmu_replay_record_t));
drr->drr_type = DRR_END;
- drr->drr_u.drr_end.drr_checksum = ba.zc;
- drr->drr_u.drr_end.drr_toguid = ba.toguid;
+ drr->drr_u.drr_end.drr_checksum = dsp->dsa_zc;
+ drr->drr_u.drr_end.drr_toguid = dsp->dsa_toguid;
- if (dump_bytes(&ba, drr, sizeof (dmu_replay_record_t)) != 0) {
- kmem_free(drr, sizeof (dmu_replay_record_t));
- return (ba.err);
+ if (dump_bytes(dsp, drr, sizeof (dmu_replay_record_t)) != 0) {
+ err = dsp->dsa_err;
+ goto out;
}
+out:
+ mutex_enter(&ds->ds_sendstream_lock);
+ list_remove(&ds->ds_sendstreams, dsp);
+ mutex_exit(&ds->ds_sendstream_lock);
+
kmem_free(drr, sizeof (dmu_replay_record_t));
+ kmem_free(dsp, sizeof (dmu_sendarg_t));
- return (0);
+ return (err);
}
int
-dmu_send_estimate(objset_t *tosnap, objset_t *fromsnap, boolean_t fromorigin,
- uint64_t *sizep)
+dmu_send_estimate(objset_t *tosnap, objset_t *fromsnap, uint64_t *sizep)
{
dsl_dataset_t *ds = tosnap->os_dsl_dataset;
dsl_dataset_t *fromds = fromsnap ? fromsnap->os_dsl_dataset : NULL;
@@ -529,27 +553,13 @@ dmu_send_estimate(objset_t *tosnap, objset_t *fromsnap, boolean_t fromorigin,
if (ds->ds_phys->ds_next_snap_obj == 0)
return (EINVAL);
- /* fromsnap must be an earlier snapshot from the same fs as tosnap */
- if (fromds && (ds->ds_dir != fromds->ds_dir ||
- fromds->ds_phys->ds_creation_txg >= ds->ds_phys->ds_creation_txg))
+ /*
+ * fromsnap must be an earlier snapshot from the same fs as tosnap,
+ * or the origin's fs.
+ */
+ if (fromds != NULL && !is_before(ds, fromds))
return (EXDEV);
- if (fromorigin) {
- if (fromsnap)
- return (EINVAL);
-
- if (dsl_dir_is_clone(ds->ds_dir)) {
- rw_enter(&dp->dp_config_rwlock, RW_READER);
- err = dsl_dataset_hold_obj(dp,
- ds->ds_dir->dd_phys->dd_origin_obj, FTAG, &fromds);
- rw_exit(&dp->dp_config_rwlock);
- if (err)
- return (err);
- } else {
- fromorigin = B_FALSE;
- }
- }
-
/* Get uncompressed size estimate of changed data. */
if (fromds == NULL) {
size = ds->ds_phys->ds_uncompressed_bytes;
@@ -557,8 +567,6 @@ dmu_send_estimate(objset_t *tosnap, objset_t *fromsnap, boolean_t fromorigin,
uint64_t used, comp;
err = dsl_dataset_space_written(fromds, ds,
&used, &comp, &size);
- if (fromorigin)
- dsl_dataset_rele(fromds, FTAG);
if (err)
return (err);
}
@@ -657,8 +665,7 @@ recv_new_sync(void *arg1, void *arg2, dmu_tx_t *tx)
rbsa->ds, &rbsa->ds->ds_phys->ds_bp, rbsa->type, tx);
}
- spa_history_log_internal(LOG_DS_REPLAY_FULL_SYNC,
- dd->dd_pool->dp_spa, tx, "dataset = %lld", dsobj);
+ spa_history_log_internal_ds(rbsa->ds, "receive new", tx, "");
}
/* ARGSUSED */
@@ -759,8 +766,7 @@ recv_existing_sync(void *arg1, void *arg2, dmu_tx_t *tx)
rbsa->ds = cds;
- spa_history_log_internal(LOG_DS_REPLAY_INC_SYNC,
- dp->dp_spa, tx, "dataset = %lld", dsobj);
+ spa_history_log_internal_ds(cds, "receive over existing", tx, "");
}
static boolean_t
@@ -1070,8 +1076,8 @@ restore_object(struct restorearg *ra, objset_t *os, struct drr_object *drro)
void *data = NULL;
if (drro->drr_type == DMU_OT_NONE ||
- drro->drr_type >= DMU_OT_NUMTYPES ||
- drro->drr_bonustype >= DMU_OT_NUMTYPES ||
+ !DMU_OT_IS_VALID(drro->drr_type) ||
+ !DMU_OT_IS_VALID(drro->drr_bonustype) ||
drro->drr_checksumtype >= ZIO_CHECKSUM_FUNCTIONS ||
drro->drr_compress >= ZIO_COMPRESS_FUNCTIONS ||
P2PHASE(drro->drr_blksz, SPA_MINBLOCKSIZE) ||
@@ -1136,7 +1142,9 @@ restore_object(struct restorearg *ra, objset_t *os, struct drr_object *drro)
ASSERT3U(db->db_size, >=, drro->drr_bonuslen);
bcopy(data, db->db_data, drro->drr_bonuslen);
if (ra->byteswap) {
- dmu_ot[drro->drr_bonustype].ot_byteswap(db->db_data,
+ dmu_object_byteswap_t byteswap =
+ DMU_OT_BYTESWAP(drro->drr_bonustype);
+ dmu_ot_byteswap[byteswap].ob_func(db->db_data,
drro->drr_bonuslen);
}
dmu_buf_rele(db, FTAG);
@@ -1179,7 +1187,7 @@ restore_write(struct restorearg *ra, objset_t *os,
int err;
if (drrw->drr_offset + drrw->drr_length < drrw->drr_offset ||
- drrw->drr_type >= DMU_OT_NUMTYPES)
+ !DMU_OT_IS_VALID(drrw->drr_type))
return (EINVAL);
data = restore_read(ra, drrw->drr_length);
@@ -1198,8 +1206,11 @@ restore_write(struct restorearg *ra, objset_t *os,
dmu_tx_abort(tx);
return (err);
}
- if (ra->byteswap)
- dmu_ot[drrw->drr_type].ot_byteswap(data, drrw->drr_length);
+ if (ra->byteswap) {
+ dmu_object_byteswap_t byteswap =
+ DMU_OT_BYTESWAP(drrw->drr_type);
+ dmu_ot_byteswap[byteswap].ob_func(data, drrw->drr_length);
+ }
dmu_write(os, drrw->drr_object,
drrw->drr_offset, drrw->drr_length, data, tx);
dmu_tx_commit(tx);
@@ -1563,6 +1574,7 @@ recv_end_sync(void *arg1, void *arg2, dmu_tx_t *tx)
dmu_buf_will_dirty(ds->ds_dbuf, tx);
ds->ds_phys->ds_flags &= ~DS_FLAG_INCONSISTENT;
+ spa_history_log_internal_ds(ds, "finished receiving", tx, "");
}
static int
diff --git a/usr/src/uts/common/fs/zfs/dmu_traverse.c b/usr/src/uts/common/fs/zfs/dmu_traverse.c
index 023f90e12e..bfe9e65064 100644
--- a/usr/src/uts/common/fs/zfs/dmu_traverse.c
+++ b/usr/src/uts/common/fs/zfs/dmu_traverse.c
@@ -20,6 +20,7 @@
*/
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012 by Delphix. All rights reserved.
*/
#include <sys/zfs_context.h>
@@ -53,6 +54,7 @@ typedef struct traverse_data {
uint64_t td_objset;
blkptr_t *td_rootbp;
uint64_t td_min_txg;
+ zbookmark_t *td_resume;
int td_flags;
prefetch_data_t *td_pfd;
blkptr_cb_t *td_func;
@@ -128,6 +130,54 @@ traverse_zil(traverse_data_t *td, zil_header_t *zh)
zil_free(zilog);
}
+typedef enum resume_skip {
+ RESUME_SKIP_ALL,
+ RESUME_SKIP_NONE,
+ RESUME_SKIP_CHILDREN
+} resume_skip_t;
+
+/*
+ * Returns RESUME_SKIP_ALL if td indicates that we are resuming a traversal and
+ * the block indicated by zb does not need to be visited at all. Returns
+ * RESUME_SKIP_CHILDREN if we are resuming a post traversal and we reach the
+ * resume point. This indicates that this block should be visited but not its
+ * children (since they must have been visited in a previous traversal).
+ * Otherwise returns RESUME_SKIP_NONE.
+ */
+static resume_skip_t
+resume_skip_check(traverse_data_t *td, const dnode_phys_t *dnp,
+ const zbookmark_t *zb)
+{
+ if (td->td_resume != NULL && !ZB_IS_ZERO(td->td_resume)) {
+ /*
+ * If we already visited this bp & everything below,
+ * don't bother doing it again.
+ */
+ if (zbookmark_is_before(dnp, zb, td->td_resume))
+ return (RESUME_SKIP_ALL);
+
+ /*
+ * If we found the block we're trying to resume from, zero
+ * the bookmark out to indicate that we have resumed.
+ */
+ ASSERT3U(zb->zb_object, <=, td->td_resume->zb_object);
+ if (bcmp(zb, td->td_resume, sizeof (*zb)) == 0) {
+ bzero(td->td_resume, sizeof (*zb));
+ if (td->td_flags & TRAVERSE_POST)
+ return (RESUME_SKIP_CHILDREN);
+ }
+ }
+ return (RESUME_SKIP_NONE);
+}
+
+static void
+traverse_pause(traverse_data_t *td, const zbookmark_t *zb)
+{
+ ASSERT(td->td_resume != NULL);
+ ASSERT3U(zb->zb_level, ==, 0);
+ bcopy(zb, td->td_resume, sizeof (*td->td_resume));
+}
+
static int
traverse_visitbp(traverse_data_t *td, const dnode_phys_t *dnp,
arc_buf_t *pbuf, blkptr_t *bp, const zbookmark_t *zb)
@@ -137,8 +187,20 @@ traverse_visitbp(traverse_data_t *td, const dnode_phys_t *dnp,
arc_buf_t *buf = NULL;
prefetch_data_t *pd = td->td_pfd;
boolean_t hard = td->td_flags & TRAVERSE_HARD;
+ boolean_t pause = B_FALSE;
+
+ switch (resume_skip_check(td, dnp, zb)) {
+ case RESUME_SKIP_ALL:
+ return (0);
+ case RESUME_SKIP_CHILDREN:
+ goto post;
+ case RESUME_SKIP_NONE:
+ break;
+ default:
+ ASSERT(0);
+ }
- if (bp->blk_birth == 0) {
+ if (BP_IS_HOLE(bp)) {
err = td->td_func(td->td_spa, NULL, NULL, pbuf, zb, dnp,
td->td_arg);
return (err);
@@ -164,8 +226,10 @@ traverse_visitbp(traverse_data_t *td, const dnode_phys_t *dnp,
td->td_arg);
if (err == TRAVERSE_VISIT_NO_CHILDREN)
return (0);
- if (err)
- return (err);
+ if (err == ERESTART)
+ pause = B_TRUE; /* handle pausing at a common point */
+ if (err != 0)
+ goto post;
}
if (BP_GET_LEVEL(bp) > 0) {
@@ -253,9 +317,18 @@ traverse_visitbp(traverse_data_t *td, const dnode_phys_t *dnp,
if (buf)
(void) arc_buf_remove_ref(buf, &buf);
+post:
if (err == 0 && lasterr == 0 && (td->td_flags & TRAVERSE_POST)) {
err = td->td_func(td->td_spa, NULL, bp, pbuf, zb, dnp,
td->td_arg);
+ if (err == ERESTART)
+ pause = B_TRUE;
+ }
+
+ if (pause && td->td_resume != NULL) {
+ ASSERT3U(err, ==, ERESTART);
+ ASSERT(!hard);
+ traverse_pause(td, zb);
}
return (err != 0 ? err : lasterr);
@@ -353,18 +426,23 @@ traverse_prefetch_thread(void *arg)
* in syncing context).
*/
static int
-traverse_impl(spa_t *spa, dsl_dataset_t *ds, blkptr_t *rootbp,
- uint64_t txg_start, int flags, blkptr_cb_t func, void *arg)
+traverse_impl(spa_t *spa, dsl_dataset_t *ds, uint64_t objset, blkptr_t *rootbp,
+ uint64_t txg_start, zbookmark_t *resume, int flags,
+ blkptr_cb_t func, void *arg)
{
traverse_data_t td;
prefetch_data_t pd = { 0 };
zbookmark_t czb;
int err;
+ ASSERT(ds == NULL || objset == ds->ds_object);
+ ASSERT(!(flags & TRAVERSE_PRE) || !(flags & TRAVERSE_POST));
+
td.td_spa = spa;
- td.td_objset = ds ? ds->ds_object : 0;
+ td.td_objset = objset;
td.td_rootbp = rootbp;
td.td_min_txg = txg_start;
+ td.td_resume = resume;
td.td_func = func;
td.td_arg = arg;
td.td_pfd = &pd;
@@ -416,8 +494,17 @@ int
traverse_dataset(dsl_dataset_t *ds, uint64_t txg_start, int flags,
blkptr_cb_t func, void *arg)
{
- return (traverse_impl(ds->ds_dir->dd_pool->dp_spa, ds,
- &ds->ds_phys->ds_bp, txg_start, flags, func, arg));
+ return (traverse_impl(ds->ds_dir->dd_pool->dp_spa, ds, ds->ds_object,
+ &ds->ds_phys->ds_bp, txg_start, NULL, flags, func, arg));
+}
+
+int
+traverse_dataset_destroyed(spa_t *spa, blkptr_t *blkptr,
+ uint64_t txg_start, zbookmark_t *resume, int flags,
+ blkptr_cb_t func, void *arg)
+{
+ return (traverse_impl(spa, NULL, ZB_DESTROYED_OBJSET,
+ blkptr, txg_start, resume, flags, func, arg));
}
/*
@@ -434,8 +521,8 @@ traverse_pool(spa_t *spa, uint64_t txg_start, int flags,
boolean_t hard = (flags & TRAVERSE_HARD);
/* visit the MOS */
- err = traverse_impl(spa, NULL, spa_get_rootblkptr(spa),
- txg_start, flags, func, arg);
+ err = traverse_impl(spa, NULL, 0, spa_get_rootblkptr(spa),
+ txg_start, NULL, flags, func, arg);
if (err)
return (err);
diff --git a/usr/src/uts/common/fs/zfs/dmu_tx.c b/usr/src/uts/common/fs/zfs/dmu_tx.c
index 2301942907..d943e1c417 100644
--- a/usr/src/uts/common/fs/zfs/dmu_tx.c
+++ b/usr/src/uts/common/fs/zfs/dmu_tx.c
@@ -20,9 +20,8 @@
*/
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
- */
-/*
* Copyright 2011 Nexenta Systems, Inc. All rights reserved.
+ * Copyright (c) 2012 by Delphix. All rights reserved.
*/
#include <sys/dmu.h>
@@ -49,7 +48,7 @@ dmu_tx_create_dd(dsl_dir_t *dd)
{
dmu_tx_t *tx = kmem_zalloc(sizeof (dmu_tx_t), KM_SLEEP);
tx->tx_dir = dd;
- if (dd)
+ if (dd != NULL)
tx->tx_pool = dd->dd_pool;
list_create(&tx->tx_holds, sizeof (dmu_tx_hold_t),
offsetof(dmu_tx_hold_t, txh_node));
@@ -678,7 +677,7 @@ dmu_tx_hold_zap(dmu_tx_t *tx, uint64_t object, int add, const char *name)
return;
}
- ASSERT3P(dmu_ot[dn->dn_type].ot_byteswap, ==, zap_byteswap);
+ ASSERT3P(DMU_OT_BYTESWAP(dn->dn_type), ==, DMU_BSWAP_ZAP);
if (dn->dn_maxblkid == 0 && !add) {
blkptr_t *bp;
diff --git a/usr/src/uts/common/fs/zfs/dnode.c b/usr/src/uts/common/fs/zfs/dnode.c
index 850dd5816b..05ccf9fc62 100644
--- a/usr/src/uts/common/fs/zfs/dnode.c
+++ b/usr/src/uts/common/fs/zfs/dnode.c
@@ -20,6 +20,7 @@
*/
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012 by Delphix. All rights reserved.
*/
#include <sys/zfs_context.h>
@@ -193,7 +194,7 @@ dnode_verify(dnode_t *dn)
ASSERT(dn->dn_objset);
ASSERT(dn->dn_handle->dnh_dnode == dn);
- ASSERT(dn->dn_phys->dn_type < DMU_OT_NUMTYPES);
+ ASSERT(DMU_OT_IS_VALID(dn->dn_phys->dn_type));
if (!(zfs_flags & ZFS_DEBUG_DNODE_VERIFY))
return;
@@ -212,7 +213,7 @@ dnode_verify(dnode_t *dn)
ASSERT3U(1<<dn->dn_datablkshift, ==, dn->dn_datablksz);
}
ASSERT3U(dn->dn_nlevels, <=, 30);
- ASSERT3U(dn->dn_type, <=, DMU_OT_NUMTYPES);
+ ASSERT(DMU_OT_IS_VALID(dn->dn_type));
ASSERT3U(dn->dn_nblkptr, >=, 1);
ASSERT3U(dn->dn_nblkptr, <=, DN_MAX_NBLKPTR);
ASSERT3U(dn->dn_bonuslen, <=, DN_MAX_BONUSLEN);
@@ -278,8 +279,10 @@ dnode_byteswap(dnode_phys_t *dnp)
*/
int off = (dnp->dn_nblkptr-1) * sizeof (blkptr_t);
size_t len = DN_MAX_BONUSLEN - off;
- ASSERT3U(dnp->dn_bonustype, <, DMU_OT_NUMTYPES);
- dmu_ot[dnp->dn_bonustype].ot_byteswap(dnp->dn_bonus + off, len);
+ ASSERT(DMU_OT_IS_VALID(dnp->dn_bonustype));
+ dmu_object_byteswap_t byteswap =
+ DMU_OT_BYTESWAP(dnp->dn_bonustype);
+ dmu_ot_byteswap[byteswap].ob_func(dnp->dn_bonus + off, len);
}
/* Swap SPILL block if we have one */
@@ -407,7 +410,7 @@ dnode_create(objset_t *os, dnode_phys_t *dnp, dmu_buf_impl_t *db,
dmu_zfetch_init(&dn->dn_zfetch, dn);
- ASSERT(dn->dn_phys->dn_type < DMU_OT_NUMTYPES);
+ ASSERT(DMU_OT_IS_VALID(dn->dn_phys->dn_type));
mutex_enter(&os->os_lock);
list_insert_head(&os->os_dnodes, dn);
@@ -496,11 +499,11 @@ dnode_allocate(dnode_t *dn, dmu_object_type_t ot, int blocksize, int ibs,
ASSERT(bcmp(dn->dn_phys, &dnode_phys_zero, sizeof (dnode_phys_t)) == 0);
ASSERT(dn->dn_phys->dn_type == DMU_OT_NONE);
ASSERT(ot != DMU_OT_NONE);
- ASSERT3U(ot, <, DMU_OT_NUMTYPES);
+ ASSERT(DMU_OT_IS_VALID(ot));
ASSERT((bonustype == DMU_OT_NONE && bonuslen == 0) ||
(bonustype == DMU_OT_SA && bonuslen == 0) ||
(bonustype != DMU_OT_NONE && bonuslen != 0));
- ASSERT3U(bonustype, <, DMU_OT_NUMTYPES);
+ ASSERT(DMU_OT_IS_VALID(bonustype));
ASSERT3U(bonuslen, <=, DN_MAX_BONUSLEN);
ASSERT(dn->dn_type == DMU_OT_NONE);
ASSERT3U(dn->dn_maxblkid, ==, 0);
@@ -568,7 +571,7 @@ dnode_reallocate(dnode_t *dn, dmu_object_type_t ot, int blocksize,
ASSERT((bonustype == DMU_OT_NONE && bonuslen == 0) ||
(bonustype != DMU_OT_NONE && bonuslen != 0) ||
(bonustype == DMU_OT_SA && bonuslen == 0));
- ASSERT3U(bonustype, <, DMU_OT_NUMTYPES);
+ ASSERT(DMU_OT_IS_VALID(bonustype));
ASSERT3U(bonuslen, <=, DN_MAX_BONUSLEN);
/* clean up any unreferenced dbufs */
diff --git a/usr/src/uts/common/fs/zfs/dnode_sync.c b/usr/src/uts/common/fs/zfs/dnode_sync.c
index 2ee990a3b3..8d817919b3 100644
--- a/usr/src/uts/common/fs/zfs/dnode_sync.c
+++ b/usr/src/uts/common/fs/zfs/dnode_sync.c
@@ -18,8 +18,10 @@
*
* CDDL HEADER END
*/
+
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012 by Delphix. All rights reserved.
*/
#include <sys/zfs_context.h>
@@ -594,7 +596,7 @@ dnode_sync(dnode_t *dn, dmu_tx_t *tx)
}
if (dn->dn_next_bonustype[txgoff]) {
- ASSERT(dn->dn_next_bonustype[txgoff] < DMU_OT_NUMTYPES);
+ ASSERT(DMU_OT_IS_VALID(dn->dn_next_bonustype[txgoff]));
dnp->dn_bonustype = dn->dn_next_bonustype[txgoff];
dn->dn_next_bonustype[txgoff] = 0;
}
diff --git a/usr/src/uts/common/fs/zfs/dsl_dataset.c b/usr/src/uts/common/fs/zfs/dsl_dataset.c
index aeeefd178e..555797e77e 100644
--- a/usr/src/uts/common/fs/zfs/dsl_dataset.c
+++ b/usr/src/uts/common/fs/zfs/dsl_dataset.c
@@ -20,7 +20,7 @@
*/
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2011 by Delphix. All rights reserved.
+ * Copyright (c) 2012 by Delphix. All rights reserved.
* Copyright (c) 2012, Joyent, Inc. All rights reserved.
*/
@@ -30,10 +30,12 @@
#include <sys/dsl_prop.h>
#include <sys/dsl_synctask.h>
#include <sys/dmu_traverse.h>
+#include <sys/dmu_impl.h>
#include <sys/dmu_tx.h>
#include <sys/arc.h>
#include <sys/zio.h>
#include <sys/zap.h>
+#include <sys/zfeature.h>
#include <sys/unique.h>
#include <sys/zfs_context.h>
#include <sys/zfs_ioctl.h>
@@ -99,7 +101,7 @@ dsl_dataset_block_born(dsl_dataset_t *ds, const blkptr_t *bp, dmu_tx_t *tx)
if (BP_IS_HOLE(bp))
return;
ASSERT(BP_GET_TYPE(bp) != DMU_OT_NONE);
- ASSERT3U(BP_GET_TYPE(bp), <, DMU_OT_NUMTYPES);
+ ASSERT(DMU_OT_IS_VALID(BP_GET_TYPE(bp)));
if (ds == NULL) {
/*
* Account for the meta-objset space in its placeholder
@@ -116,7 +118,7 @@ dsl_dataset_block_born(dsl_dataset_t *ds, const blkptr_t *bp, dmu_tx_t *tx)
mutex_enter(&ds->ds_dir->dd_lock);
mutex_enter(&ds->ds_lock);
delta = parent_delta(ds, used);
- ds->ds_phys->ds_used_bytes += used;
+ ds->ds_phys->ds_referenced_bytes += used;
ds->ds_phys->ds_compressed_bytes += compressed;
ds->ds_phys->ds_uncompressed_bytes += uncompressed;
ds->ds_phys->ds_unique_bytes += used;
@@ -210,8 +212,8 @@ dsl_dataset_block_kill(dsl_dataset_t *ds, const blkptr_t *bp, dmu_tx_t *tx,
}
}
mutex_enter(&ds->ds_lock);
- ASSERT3U(ds->ds_phys->ds_used_bytes, >=, used);
- ds->ds_phys->ds_used_bytes -= used;
+ ASSERT3U(ds->ds_phys->ds_referenced_bytes, >=, used);
+ ds->ds_phys->ds_referenced_bytes -= used;
ASSERT3U(ds->ds_phys->ds_compressed_bytes, >=, compressed);
ds->ds_phys->ds_compressed_bytes -= compressed;
ASSERT3U(ds->ds_phys->ds_uncompressed_bytes, >=, uncompressed);
@@ -395,6 +397,8 @@ dsl_dataset_get_ref(dsl_pool_t *dp, uint64_t dsobj, void *tag,
mutex_init(&ds->ds_lock, NULL, MUTEX_DEFAULT, NULL);
mutex_init(&ds->ds_recvlock, NULL, MUTEX_DEFAULT, NULL);
mutex_init(&ds->ds_opening_lock, NULL, MUTEX_DEFAULT, NULL);
+ mutex_init(&ds->ds_sendstream_lock, NULL, MUTEX_DEFAULT, NULL);
+
rw_init(&ds->ds_rwlock, 0, 0, 0);
cv_init(&ds->ds_exclusive_cv, NULL, CV_DEFAULT, NULL);
@@ -402,6 +406,9 @@ dsl_dataset_get_ref(dsl_pool_t *dp, uint64_t dsobj, void *tag,
dsl_deadlist_open(&ds->ds_deadlist,
mos, ds->ds_phys->ds_deadlist_obj);
+ list_create(&ds->ds_sendstreams, sizeof (dmu_sendarg_t),
+ offsetof(dmu_sendarg_t, dsa_link));
+
if (err == 0) {
err = dsl_dir_open_obj(dp,
ds->ds_phys->ds_dir_obj, NULL, ds, &ds->ds_dir);
@@ -812,8 +819,8 @@ dsl_dataset_create_sync_dd(dsl_dir_t *dd, dsl_dataset_t *origin,
dsphys->ds_prev_snap_obj = origin->ds_object;
dsphys->ds_prev_snap_txg =
origin->ds_phys->ds_creation_txg;
- dsphys->ds_used_bytes =
- origin->ds_phys->ds_used_bytes;
+ dsphys->ds_referenced_bytes =
+ origin->ds_phys->ds_referenced_bytes;
dsphys->ds_compressed_bytes =
origin->ds_phys->ds_compressed_bytes;
dsphys->ds_uncompressed_bytes =
@@ -907,7 +914,8 @@ dsl_dataset_create_sync(dsl_dir_t *pdd, const char *lastname,
* The snapshots must all be in the same pool.
*/
int
-dmu_snapshots_destroy_nvl(nvlist_t *snaps, boolean_t defer, char *failed)
+dmu_snapshots_destroy_nvl(nvlist_t *snaps, boolean_t defer,
+ nvlist_t *errlist)
{
int err;
dsl_sync_task_t *dst;
@@ -927,7 +935,6 @@ dmu_snapshots_destroy_nvl(nvlist_t *snaps, boolean_t defer, char *failed)
for (pair = nvlist_next_nvpair(snaps, NULL); pair != NULL;
pair = nvlist_next_nvpair(snaps, pair)) {
dsl_dataset_t *ds;
- int err;
err = dsl_dataset_own(nvpair_name(pair), B_TRUE, dstg, &ds);
if (err == 0) {
@@ -943,7 +950,7 @@ dmu_snapshots_destroy_nvl(nvlist_t *snaps, boolean_t defer, char *failed)
} else if (err == ENOENT) {
err = 0;
} else {
- (void) strcpy(failed, nvpair_name(pair));
+ fnvlist_add_int32(errlist, nvpair_name(pair), err);
break;
}
}
@@ -957,10 +964,12 @@ dmu_snapshots_destroy_nvl(nvlist_t *snaps, boolean_t defer, char *failed)
dsl_dataset_t *ds = dsda->ds;
/*
- * Return the file system name that triggered the error
+ * Return the snapshots that triggered the error.
*/
- if (dst->dst_err) {
- dsl_dataset_name(ds, failed);
+ if (dst->dst_err != 0) {
+ char name[ZFS_MAXNAMELEN];
+ dsl_dataset_name(ds, name);
+ fnvlist_add_int32(errlist, name, dst->dst_err);
}
ASSERT3P(dsda->rm_origin, ==, NULL);
dsl_dataset_disown(ds, dstg);
@@ -1039,7 +1048,6 @@ dsl_dataset_destroy(dsl_dataset_t *ds, void *tag, boolean_t defer)
dsl_dir_t *dd;
uint64_t obj;
struct dsl_ds_destroyarg dsda = { 0 };
- dsl_dataset_t dummy_ds = { 0 };
dsda.ds = ds;
@@ -1059,8 +1067,6 @@ dsl_dataset_destroy(dsl_dataset_t *ds, void *tag, boolean_t defer)
}
dd = ds->ds_dir;
- dummy_ds.ds_dir = dd;
- dummy_ds.ds_object = ds->ds_object;
/*
* Check for errors and mark this ds as inconsistent, in
@@ -1076,19 +1082,23 @@ dsl_dataset_destroy(dsl_dataset_t *ds, void *tag, boolean_t defer)
goto out;
/*
- * remove the objects in open context, so that we won't
- * have too much to do in syncing context.
+ * If async destruction is not enabled try to remove all objects
+ * while in the open context so that there is less work to do in
+ * the syncing context.
*/
- for (obj = 0; err == 0; err = dmu_object_next(os, &obj, FALSE,
- ds->ds_phys->ds_prev_snap_txg)) {
- /*
- * Ignore errors, if there is not enough disk space
- * we will deal with it in dsl_dataset_destroy_sync().
- */
- (void) dmu_free_object(os, obj);
+ if (!spa_feature_is_enabled(dsl_dataset_get_spa(ds),
+ &spa_feature_table[SPA_FEATURE_ASYNC_DESTROY])) {
+ for (obj = 0; err == 0; err = dmu_object_next(os, &obj, FALSE,
+ ds->ds_phys->ds_prev_snap_txg)) {
+ /*
+ * Ignore errors, if there is not enough disk space
+ * we will deal with it in dsl_dataset_destroy_sync().
+ */
+ (void) dmu_free_object(os, obj);
+ }
+ if (err != ESRCH)
+ goto out;
}
- if (err != ESRCH)
- goto out;
/*
* Only the ZIL knows how to free log blocks.
@@ -1143,7 +1153,7 @@ dsl_dataset_destroy(dsl_dataset_t *ds, void *tag, boolean_t defer)
dsl_sync_task_create(dstg, dsl_dataset_destroy_check,
dsl_dataset_destroy_sync, &dsda, tag, 0);
dsl_sync_task_create(dstg, dsl_dir_destroy_check,
- dsl_dir_destroy_sync, &dummy_ds, FTAG, 0);
+ dsl_dir_destroy_sync, dd, FTAG, 0);
err = dsl_sync_task_group_wait(dstg);
dsl_sync_task_group_destroy(dstg);
@@ -1234,7 +1244,7 @@ dsl_dataset_recalc_head_uniq(dsl_dataset_t *ds)
ASSERT(!dsl_dataset_is_snapshot(ds));
if (ds->ds_phys->ds_prev_snap_obj != 0)
- mrs_used = ds->ds_prev->ds_phys->ds_used_bytes;
+ mrs_used = ds->ds_prev->ds_phys->ds_referenced_bytes;
else
mrs_used = 0;
@@ -1242,7 +1252,7 @@ dsl_dataset_recalc_head_uniq(dsl_dataset_t *ds)
ASSERT3U(dlused, <=, mrs_used);
ds->ds_phys->ds_unique_bytes =
- ds->ds_phys->ds_used_bytes - (mrs_used - dlused);
+ ds->ds_phys->ds_referenced_bytes - (mrs_used - dlused);
if (spa_version(ds->ds_dir->dd_pool->dp_spa) >=
SPA_VERSION_UNIQUE_ACCURATE)
@@ -1318,14 +1328,12 @@ static void
dsl_dataset_destroy_begin_sync(void *arg1, void *arg2, dmu_tx_t *tx)
{
dsl_dataset_t *ds = arg1;
- dsl_pool_t *dp = ds->ds_dir->dd_pool;
/* Mark it as inconsistent on-disk, in case we crash */
dmu_buf_will_dirty(ds->ds_dbuf, tx);
ds->ds_phys->ds_flags |= DS_FLAG_INCONSISTENT;
- spa_history_log_internal(LOG_DS_DESTROY_BEGIN, dp->dp_spa, tx,
- "dataset = %llu", ds->ds_object);
+ spa_history_log_internal_ds(ds, "destroy begin", tx, "");
}
static int
@@ -1600,6 +1608,30 @@ process_old_deadlist(dsl_dataset_t *ds, dsl_dataset_t *ds_prev,
ds_next->ds_phys->ds_deadlist_obj);
}
+static int
+old_synchronous_dataset_destroy(dsl_dataset_t *ds, dmu_tx_t *tx)
+{
+ int err;
+ struct killarg ka;
+
+ /*
+ * Free everything that we point to (that's born after
+ * the previous snapshot, if we are a clone)
+ *
+ * NB: this should be very quick, because we already
+ * freed all the objects in open context.
+ */
+ ka.ds = ds;
+ ka.tx = tx;
+ err = traverse_dataset(ds,
+ ds->ds_phys->ds_prev_snap_txg, TRAVERSE_POST,
+ kill_blkptr, &ka);
+ ASSERT3U(err, ==, 0);
+ ASSERT(!DS_UNIQUE_IS_ACCURATE(ds) || ds->ds_phys->ds_unique_bytes == 0);
+
+ return (err);
+}
+
void
dsl_dataset_destroy_sync(void *arg1, void *tag, dmu_tx_t *tx)
{
@@ -1626,9 +1658,13 @@ dsl_dataset_destroy_sync(void *arg1, void *tag, dmu_tx_t *tx)
ASSERT(spa_version(dp->dp_spa) >= SPA_VERSION_USERREFS);
dmu_buf_will_dirty(ds->ds_dbuf, tx);
ds->ds_phys->ds_flags |= DS_FLAG_DEFER_DESTROY;
+ spa_history_log_internal_ds(ds, "defer_destroy", tx, "");
return;
}
+ /* We need to log before removing it from the namespace. */
+ spa_history_log_internal_ds(ds, "destroy", tx, "");
+
/* signal any waiters that this dataset is going away */
mutex_enter(&ds->ds_lock);
ds->ds_owner = dsl_reaper;
@@ -1746,7 +1782,6 @@ dsl_dataset_destroy_sync(void *arg1, void *tag, dmu_tx_t *tx)
tx);
dsl_dir_diduse_space(tx->tx_pool->dp_free_dir,
DD_USED_HEAD, used, comp, uncomp, tx);
- dsl_dir_dirty(tx->tx_pool->dp_free_dir, tx);
/* Merge our deadlist into next's and free it. */
dsl_deadlist_merge(&ds_next->ds_deadlist,
@@ -1822,32 +1857,54 @@ dsl_dataset_destroy_sync(void *arg1, void *tag, dmu_tx_t *tx)
}
dsl_dataset_rele(ds_next, FTAG);
} else {
+ zfeature_info_t *async_destroy =
+ &spa_feature_table[SPA_FEATURE_ASYNC_DESTROY];
+
/*
* There's no next snapshot, so this is a head dataset.
* Destroy the deadlist. Unless it's a clone, the
* deadlist should be empty. (If it's a clone, it's
* safe to ignore the deadlist contents.)
*/
- struct killarg ka;
-
dsl_deadlist_close(&ds->ds_deadlist);
dsl_deadlist_free(mos, ds->ds_phys->ds_deadlist_obj, tx);
ds->ds_phys->ds_deadlist_obj = 0;
- /*
- * Free everything that we point to (that's born after
- * the previous snapshot, if we are a clone)
- *
- * NB: this should be very quick, because we already
- * freed all the objects in open context.
- */
- ka.ds = ds;
- ka.tx = tx;
- err = traverse_dataset(ds, ds->ds_phys->ds_prev_snap_txg,
- TRAVERSE_POST, kill_blkptr, &ka);
- ASSERT3U(err, ==, 0);
- ASSERT(!DS_UNIQUE_IS_ACCURATE(ds) ||
- ds->ds_phys->ds_unique_bytes == 0);
+ if (!spa_feature_is_enabled(dp->dp_spa, async_destroy)) {
+ err = old_synchronous_dataset_destroy(ds, tx);
+ } else {
+ /*
+ * Move the bptree into the pool's list of trees to
+ * clean up and update space accounting information.
+ */
+ uint64_t used, comp, uncomp;
+
+ ASSERT(err == 0 || err == EBUSY);
+ if (!spa_feature_is_active(dp->dp_spa, async_destroy)) {
+ spa_feature_incr(dp->dp_spa, async_destroy, tx);
+ dp->dp_bptree_obj = bptree_alloc(
+ dp->dp_meta_objset, tx);
+ VERIFY(zap_add(dp->dp_meta_objset,
+ DMU_POOL_DIRECTORY_OBJECT,
+ DMU_POOL_BPTREE_OBJ, sizeof (uint64_t), 1,
+ &dp->dp_bptree_obj, tx) == 0);
+ }
+
+ used = ds->ds_dir->dd_phys->dd_used_bytes;
+ comp = ds->ds_dir->dd_phys->dd_compressed_bytes;
+ uncomp = ds->ds_dir->dd_phys->dd_uncompressed_bytes;
+
+ ASSERT(!DS_UNIQUE_IS_ACCURATE(ds) ||
+ ds->ds_phys->ds_unique_bytes == used);
+
+ bptree_add(dp->dp_meta_objset, dp->dp_bptree_obj,
+ &ds->ds_phys->ds_bp, ds->ds_phys->ds_prev_snap_txg,
+ used, comp, uncomp, tx);
+ dsl_dir_diduse_space(ds->ds_dir, DD_USED_HEAD,
+ -used, -comp, -uncomp, tx);
+ dsl_dir_diduse_space(dp->dp_free_dir, DD_USED_HEAD,
+ used, comp, uncomp, tx);
+ }
if (ds->ds_prev != NULL) {
if (spa_version(dp->dp_spa) >= SPA_VERSION_DIR_CLONES) {
@@ -1902,8 +1959,6 @@ dsl_dataset_destroy_sync(void *arg1, void *tag, dmu_tx_t *tx)
dsl_dataset_rele(ds_prev, FTAG);
spa_prop_clear_bootfs(dp->dp_spa, ds->ds_object, tx);
- spa_history_log_internal(LOG_DS_DESTROY, dp->dp_spa, tx,
- "dataset = %llu", ds->ds_object);
if (ds->ds_phys->ds_next_clones_obj != 0) {
uint64_t count;
@@ -1951,7 +2006,7 @@ dsl_dataset_snapshot_reserve_space(dsl_dataset_t *ds, dmu_tx_t *tx)
return (ENOSPC);
/*
- * Propogate any reserved space for this snapshot to other
+ * Propagate any reserved space for this snapshot to other
* snapshot checks in this sync group.
*/
if (asize > 0)
@@ -1961,10 +2016,9 @@ dsl_dataset_snapshot_reserve_space(dsl_dataset_t *ds, dmu_tx_t *tx)
}
int
-dsl_dataset_snapshot_check(void *arg1, void *arg2, dmu_tx_t *tx)
+dsl_dataset_snapshot_check(dsl_dataset_t *ds, const char *snapname,
+ dmu_tx_t *tx)
{
- dsl_dataset_t *ds = arg1;
- const char *snapname = arg2;
int err;
uint64_t value;
@@ -1976,7 +2030,7 @@ dsl_dataset_snapshot_check(void *arg1, void *arg2, dmu_tx_t *tx)
return (EAGAIN);
/*
- * Check for conflicting name snapshot name.
+ * Check for conflicting snapshot name.
*/
err = dsl_dataset_snap_lookup(ds, snapname, &value);
if (err == 0)
@@ -2000,10 +2054,9 @@ dsl_dataset_snapshot_check(void *arg1, void *arg2, dmu_tx_t *tx)
}
void
-dsl_dataset_snapshot_sync(void *arg1, void *arg2, dmu_tx_t *tx)
+dsl_dataset_snapshot_sync(dsl_dataset_t *ds, const char *snapname,
+ dmu_tx_t *tx)
{
- dsl_dataset_t *ds = arg1;
- const char *snapname = arg2;
dsl_pool_t *dp = ds->ds_dir->dd_pool;
dmu_buf_t *dbuf;
dsl_dataset_phys_t *dsphys;
@@ -2038,7 +2091,7 @@ dsl_dataset_snapshot_sync(void *arg1, void *arg2, dmu_tx_t *tx)
dsphys->ds_creation_time = gethrestime_sec();
dsphys->ds_creation_txg = crtxg;
dsphys->ds_deadlist_obj = ds->ds_phys->ds_deadlist_obj;
- dsphys->ds_used_bytes = ds->ds_phys->ds_used_bytes;
+ dsphys->ds_referenced_bytes = ds->ds_phys->ds_referenced_bytes;
dsphys->ds_compressed_bytes = ds->ds_phys->ds_compressed_bytes;
dsphys->ds_uncompressed_bytes = ds->ds_phys->ds_uncompressed_bytes;
dsphys->ds_flags = ds->ds_phys->ds_flags;
@@ -2109,8 +2162,7 @@ dsl_dataset_snapshot_sync(void *arg1, void *arg2, dmu_tx_t *tx)
dsl_dir_snap_cmtime_update(ds->ds_dir);
- spa_history_log_internal(LOG_DS_SNAPSHOT, dp->dp_spa, tx,
- "dataset = %llu", dsobj);
+ spa_history_log_internal_ds(ds->ds_prev, "snapshot", tx, "");
}
void
@@ -2162,10 +2214,22 @@ get_clones_stat(dsl_dataset_t *ds, nvlist_t *nv)
zap_cursor_advance(&zc)) {
dsl_dataset_t *clone;
char buf[ZFS_MAXNAMELEN];
+ /*
+ * Even though we hold the dp_config_rwlock, the dataset
+ * may fail to open, returning ENOENT. If there is a
+ * thread concurrently attempting to destroy this
+ * dataset, it will have the ds_rwlock held for
+ * RW_WRITER. Our call to dsl_dataset_hold_obj() ->
+ * dsl_dataset_hold_ref() will fail its
+ * rw_tryenter(&ds->ds_rwlock, RW_READER), drop the
+ * dp_config_rwlock, and wait for the destroy progress
+ * and signal ds_exclusive_cv. If the destroy was
+ * successful, we will see that
+ * DSL_DATASET_IS_DESTROYED(), and return ENOENT.
+ */
if (dsl_dataset_hold_obj(ds->ds_dir->dd_pool,
- za.za_first_integer, FTAG, &clone) != 0) {
- goto fail;
- }
+ za.za_first_integer, FTAG, &clone) != 0)
+ continue;
dsl_dir_name(clone->ds_dir, buf);
VERIFY(nvlist_add_boolean(val, buf) == 0);
dsl_dataset_rele(clone, FTAG);
@@ -2185,7 +2249,20 @@ dsl_dataset_stats(dsl_dataset_t *ds, nvlist_t *nv)
{
uint64_t refd, avail, uobjs, aobjs, ratio;
- dsl_dir_stats(ds->ds_dir, nv);
+ ratio = ds->ds_phys->ds_compressed_bytes == 0 ? 100 :
+ (ds->ds_phys->ds_uncompressed_bytes * 100 /
+ ds->ds_phys->ds_compressed_bytes);
+
+ dsl_prop_nvlist_add_uint64(nv, ZFS_PROP_REFRATIO, ratio);
+
+ if (dsl_dataset_is_snapshot(ds)) {
+ dsl_prop_nvlist_add_uint64(nv, ZFS_PROP_COMPRESSRATIO, ratio);
+ dsl_prop_nvlist_add_uint64(nv, ZFS_PROP_USED,
+ ds->ds_phys->ds_unique_bytes);
+ get_clones_stat(ds, nv);
+ } else {
+ dsl_dir_stats(ds->ds_dir, nv);
+ }
dsl_dataset_space(ds, &refd, &avail, &uobjs, &aobjs);
dsl_prop_nvlist_add_uint64(nv, ZFS_PROP_AVAILABLE, avail);
@@ -2230,22 +2307,6 @@ dsl_dataset_stats(dsl_dataset_t *ds, nvlist_t *nv)
}
}
- ratio = ds->ds_phys->ds_compressed_bytes == 0 ? 100 :
- (ds->ds_phys->ds_uncompressed_bytes * 100 /
- ds->ds_phys->ds_compressed_bytes);
- dsl_prop_nvlist_add_uint64(nv, ZFS_PROP_REFRATIO, ratio);
-
- if (ds->ds_phys->ds_next_snap_obj) {
- /*
- * This is a snapshot; override the dd's space used with
- * our unique space and compression ratio.
- */
- dsl_prop_nvlist_add_uint64(nv, ZFS_PROP_USED,
- ds->ds_phys->ds_unique_bytes);
- dsl_prop_nvlist_add_uint64(nv, ZFS_PROP_COMPRESSRATIO, ratio);
-
- get_clones_stat(ds, nv);
- }
}
void
@@ -2254,27 +2315,25 @@ dsl_dataset_fast_stat(dsl_dataset_t *ds, dmu_objset_stats_t *stat)
stat->dds_creation_txg = ds->ds_phys->ds_creation_txg;
stat->dds_inconsistent = ds->ds_phys->ds_flags & DS_FLAG_INCONSISTENT;
stat->dds_guid = ds->ds_phys->ds_guid;
- if (ds->ds_phys->ds_next_snap_obj) {
+ stat->dds_origin[0] = '\0';
+ if (dsl_dataset_is_snapshot(ds)) {
stat->dds_is_snapshot = B_TRUE;
stat->dds_num_clones = ds->ds_phys->ds_num_children - 1;
} else {
stat->dds_is_snapshot = B_FALSE;
stat->dds_num_clones = 0;
- }
- /* clone origin is really a dsl_dir thing... */
- rw_enter(&ds->ds_dir->dd_pool->dp_config_rwlock, RW_READER);
- if (dsl_dir_is_clone(ds->ds_dir)) {
- dsl_dataset_t *ods;
+ rw_enter(&ds->ds_dir->dd_pool->dp_config_rwlock, RW_READER);
+ if (dsl_dir_is_clone(ds->ds_dir)) {
+ dsl_dataset_t *ods;
- VERIFY(0 == dsl_dataset_get_ref(ds->ds_dir->dd_pool,
- ds->ds_dir->dd_phys->dd_origin_obj, FTAG, &ods));
- dsl_dataset_name(ods, stat->dds_origin);
- dsl_dataset_drop_ref(ods, FTAG);
- } else {
- stat->dds_origin[0] = '\0';
+ VERIFY(0 == dsl_dataset_get_ref(ds->ds_dir->dd_pool,
+ ds->ds_dir->dd_phys->dd_origin_obj, FTAG, &ods));
+ dsl_dataset_name(ods, stat->dds_origin);
+ dsl_dataset_drop_ref(ods, FTAG);
+ }
+ rw_exit(&ds->ds_dir->dd_pool->dp_config_rwlock);
}
- rw_exit(&ds->ds_dir->dd_pool->dp_config_rwlock);
}
uint64_t
@@ -2288,7 +2347,7 @@ dsl_dataset_space(dsl_dataset_t *ds,
uint64_t *refdbytesp, uint64_t *availbytesp,
uint64_t *usedobjsp, uint64_t *availobjsp)
{
- *refdbytesp = ds->ds_phys->ds_used_bytes;
+ *refdbytesp = ds->ds_phys->ds_referenced_bytes;
*availbytesp = dsl_dir_space_available(ds->ds_dir, NULL, 0, TRUE);
if (ds->ds_reserved > ds->ds_phys->ds_unique_bytes)
*availbytesp += ds->ds_reserved - ds->ds_phys->ds_unique_bytes;
@@ -2391,8 +2450,8 @@ dsl_dataset_snapshot_rename_sync(void *arg1, void *arg2, dmu_tx_t *tx)
ds->ds_snapname, 8, 1, &ds->ds_object, tx);
ASSERT3U(err, ==, 0);
- spa_history_log_internal(LOG_DS_RENAME, dd->dd_pool->dp_spa, tx,
- "dataset = %llu", ds->ds_object);
+ spa_history_log_internal_ds(ds, "rename", tx,
+ "-> @%s", newsnapname);
dsl_dataset_rele(hds, FTAG);
}
@@ -2625,7 +2684,7 @@ dsl_dataset_promote_check(void *arg1, void *arg2, dmu_tx_t *tx)
* Note however, if we stop before we reach the ORIGIN we get:
* uN + kN + kN-1 + ... + kM - uM-1
*/
- pa->used = origin_ds->ds_phys->ds_used_bytes;
+ pa->used = origin_ds->ds_phys->ds_referenced_bytes;
pa->comp = origin_ds->ds_phys->ds_compressed_bytes;
pa->uncomp = origin_ds->ds_phys->ds_uncompressed_bytes;
for (snap = list_head(&pa->shared_snaps); snap;
@@ -2659,7 +2718,7 @@ dsl_dataset_promote_check(void *arg1, void *arg2, dmu_tx_t *tx)
* so we need to subtract out the clone origin's used space.
*/
if (pa->origin_origin) {
- pa->used -= pa->origin_origin->ds_phys->ds_used_bytes;
+ pa->used -= pa->origin_origin->ds_phys->ds_referenced_bytes;
pa->comp -= pa->origin_origin->ds_phys->ds_compressed_bytes;
pa->uncomp -= pa->origin_origin->ds_phys->ds_uncompressed_bytes;
}
@@ -2872,8 +2931,7 @@ dsl_dataset_promote_sync(void *arg1, void *arg2, dmu_tx_t *tx)
origin_ds->ds_phys->ds_unique_bytes = pa->unique;
/* log history record */
- spa_history_log_internal(LOG_DS_PROMOTE, dd->dd_pool->dp_spa, tx,
- "dataset = %llu", hds->ds_object);
+ spa_history_log_internal_ds(hds, "promote", tx, "");
dsl_dir_close(odd, FTAG);
}
@@ -3175,8 +3233,8 @@ dsl_dataset_clone_swap_sync(void *arg1, void *arg2, dmu_tx_t *tx)
dsl_deadlist_space(&csa->ohds->ds_deadlist,
&odl_used, &odl_comp, &odl_uncomp);
- dused = csa->cds->ds_phys->ds_used_bytes + cdl_used -
- (csa->ohds->ds_phys->ds_used_bytes + odl_used);
+ dused = csa->cds->ds_phys->ds_referenced_bytes + cdl_used -
+ (csa->ohds->ds_phys->ds_referenced_bytes + odl_used);
dcomp = csa->cds->ds_phys->ds_compressed_bytes + cdl_comp -
(csa->ohds->ds_phys->ds_compressed_bytes + odl_comp);
duncomp = csa->cds->ds_phys->ds_uncompressed_bytes +
@@ -3205,8 +3263,8 @@ dsl_dataset_clone_swap_sync(void *arg1, void *arg2, dmu_tx_t *tx)
}
/* swap ds_*_bytes */
- SWITCH64(csa->ohds->ds_phys->ds_used_bytes,
- csa->cds->ds_phys->ds_used_bytes);
+ SWITCH64(csa->ohds->ds_phys->ds_referenced_bytes,
+ csa->cds->ds_phys->ds_referenced_bytes);
SWITCH64(csa->ohds->ds_phys->ds_compressed_bytes,
csa->cds->ds_phys->ds_compressed_bytes);
SWITCH64(csa->ohds->ds_phys->ds_uncompressed_bytes,
@@ -3231,6 +3289,9 @@ dsl_dataset_clone_swap_sync(void *arg1, void *arg2, dmu_tx_t *tx)
csa->ohds->ds_phys->ds_deadlist_obj);
dsl_scan_ds_clone_swapped(csa->ohds, csa->cds, tx);
+
+ spa_history_log_internal_ds(csa->cds, "clone swap", tx,
+ "parent=%s", csa->ohds->ds_dir->dd_myname);
}
/*
@@ -3335,8 +3396,9 @@ dsl_dataset_check_quota(dsl_dataset_t *ds, boolean_t check_quota,
* on-disk is over quota and there are no pending changes (which
* may free up space for us).
*/
- if (ds->ds_phys->ds_used_bytes + inflight >= ds->ds_quota) {
- if (inflight > 0 || ds->ds_phys->ds_used_bytes < ds->ds_quota)
+ if (ds->ds_phys->ds_referenced_bytes + inflight >= ds->ds_quota) {
+ if (inflight > 0 ||
+ ds->ds_phys->ds_referenced_bytes < ds->ds_quota)
error = ERESTART;
else
error = EDQUOT;
@@ -3363,7 +3425,7 @@ dsl_dataset_set_quota_check(void *arg1, void *arg2, dmu_tx_t *tx)
if (psa->psa_effective_value == 0)
return (0);
- if (psa->psa_effective_value < ds->ds_phys->ds_used_bytes ||
+ if (psa->psa_effective_value < ds->ds_phys->ds_referenced_bytes ||
psa->psa_effective_value < ds->ds_reserved)
return (ENOSPC);
@@ -3386,9 +3448,8 @@ dsl_dataset_set_quota_sync(void *arg1, void *arg2, dmu_tx_t *tx)
dmu_buf_will_dirty(ds->ds_dbuf, tx);
ds->ds_quota = effective_value;
- spa_history_log_internal(LOG_DS_REFQUOTA,
- ds->ds_dir->dd_pool->dp_spa, tx, "%lld dataset = %llu ",
- (longlong_t)ds->ds_quota, ds->ds_object);
+ spa_history_log_internal_ds(ds, "set refquota", tx,
+ "refquota=%lld", (longlong_t)ds->ds_quota);
}
}
@@ -3493,9 +3554,8 @@ dsl_dataset_set_reservation_sync(void *arg1, void *arg2, dmu_tx_t *tx)
dsl_dir_diduse_space(ds->ds_dir, DD_USED_REFRSRV, delta, 0, 0, tx);
mutex_exit(&ds->ds_dir->dd_lock);
- spa_history_log_internal(LOG_DS_REFRESERV,
- ds->ds_dir->dd_pool->dp_spa, tx, "%lld dataset = %llu",
- (longlong_t)effective_value, ds->ds_object);
+ spa_history_log_internal_ds(ds, "set refreservation", tx,
+ "refreservation=%lld", (longlong_t)effective_value);
}
int
@@ -3561,7 +3621,7 @@ dsl_dataset_user_hold_check(void *arg1, void *arg2, dmu_tx_t *tx)
{
dsl_dataset_t *ds = arg1;
struct dsl_ds_holdarg *ha = arg2;
- char *htag = ha->htag;
+ const char *htag = ha->htag;
objset_t *mos = ds->ds_dir->dd_pool->dp_meta_objset;
int error = 0;
@@ -3595,7 +3655,7 @@ dsl_dataset_user_hold_sync(void *arg1, void *arg2, dmu_tx_t *tx)
{
dsl_dataset_t *ds = arg1;
struct dsl_ds_holdarg *ha = arg2;
- char *htag = ha->htag;
+ const char *htag = ha->htag;
dsl_pool_t *dp = ds->ds_dir->dd_pool;
objset_t *mos = dp->dp_meta_objset;
uint64_t now = gethrestime_sec();
@@ -3623,9 +3683,9 @@ dsl_dataset_user_hold_sync(void *arg1, void *arg2, dmu_tx_t *tx)
htag, &now, tx));
}
- spa_history_log_internal(LOG_DS_USER_HOLD,
- dp->dp_spa, tx, "<%s> temp = %d dataset = %llu", htag,
- (int)ha->temphold, ds->ds_object);
+ spa_history_log_internal_ds(ds, "hold", tx,
+ "tag = %s temp = %d holds now = %llu",
+ htag, (int)ha->temphold, ds->ds_userrefs);
}
static int
@@ -3832,7 +3892,6 @@ dsl_dataset_user_release_sync(void *arg1, void *tag, dmu_tx_t *tx)
dsl_pool_t *dp = ds->ds_dir->dd_pool;
objset_t *mos = dp->dp_meta_objset;
uint64_t zapobj;
- uint64_t dsobj = ds->ds_object;
uint64_t refs;
int error;
@@ -3855,9 +3914,8 @@ dsl_dataset_user_release_sync(void *arg1, void *tag, dmu_tx_t *tx)
dsl_dataset_destroy_sync(&dsda, tag, tx);
}
- spa_history_log_internal(LOG_DS_USER_RELEASE,
- dp->dp_spa, tx, "<%s> %lld dataset = %llu",
- ra->htag, (longlong_t)refs, dsobj);
+ spa_history_log_internal_ds(ds, "release", tx,
+ "tag = %s refs now = %lld", ra->htag, (longlong_t)refs);
}
static int
@@ -4117,8 +4175,8 @@ dsl_dataset_space_written(dsl_dataset_t *oldsnap, dsl_dataset_t *new,
dsl_pool_t *dp = new->ds_dir->dd_pool;
*usedp = 0;
- *usedp += new->ds_phys->ds_used_bytes;
- *usedp -= oldsnap->ds_phys->ds_used_bytes;
+ *usedp += new->ds_phys->ds_referenced_bytes;
+ *usedp -= oldsnap->ds_phys->ds_referenced_bytes;
*compp = 0;
*compp += new->ds_phys->ds_compressed_bytes;
diff --git a/usr/src/uts/common/fs/zfs/dsl_deleg.c b/usr/src/uts/common/fs/zfs/dsl_deleg.c
index 94026e1c13..ba620bd6fb 100644
--- a/usr/src/uts/common/fs/zfs/dsl_deleg.c
+++ b/usr/src/uts/common/fs/zfs/dsl_deleg.c
@@ -20,7 +20,7 @@
*/
/*
* Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2011 by Delphix. All rights reserved.
+ * Copyright (c) 2012 by Delphix. All rights reserved.
*/
/*
@@ -171,10 +171,8 @@ dsl_deleg_set_sync(void *arg1, void *arg2, dmu_tx_t *tx)
VERIFY(nvpair_value_nvlist(whopair, &perms) == 0);
if (zap_lookup(mos, zapobj, whokey, 8, 1, &jumpobj) != 0) {
- jumpobj = zap_create(mos, DMU_OT_DSL_PERMS,
- DMU_OT_NONE, 0, tx);
- VERIFY(zap_update(mos, zapobj,
- whokey, 8, 1, &jumpobj, tx) == 0);
+ jumpobj = zap_create_link(mos, DMU_OT_DSL_PERMS,
+ zapobj, whokey, tx);
}
while (permpair = nvlist_next_nvpair(perms, permpair)) {
@@ -183,10 +181,8 @@ dsl_deleg_set_sync(void *arg1, void *arg2, dmu_tx_t *tx)
VERIFY(zap_update(mos, jumpobj,
perm, 8, 1, &n, tx) == 0);
- spa_history_log_internal(LOG_DS_PERM_UPDATE,
- dd->dd_pool->dp_spa, tx,
- "%s %s dataset = %llu", whokey, perm,
- dd->dd_phys->dd_head_dataset_obj);
+ spa_history_log_internal_dd(dd, "permission update", tx,
+ "%s %s", whokey, perm);
}
}
}
@@ -215,10 +211,8 @@ dsl_deleg_unset_sync(void *arg1, void *arg2, dmu_tx_t *tx)
(void) zap_remove(mos, zapobj, whokey, tx);
VERIFY(0 == zap_destroy(mos, jumpobj, tx));
}
- spa_history_log_internal(LOG_DS_PERM_WHO_REMOVE,
- dd->dd_pool->dp_spa, tx,
- "%s dataset = %llu", whokey,
- dd->dd_phys->dd_head_dataset_obj);
+ spa_history_log_internal_dd(dd, "permission who remove",
+ tx, "%s", whokey);
continue;
}
@@ -236,10 +230,8 @@ dsl_deleg_unset_sync(void *arg1, void *arg2, dmu_tx_t *tx)
VERIFY(0 == zap_destroy(mos,
jumpobj, tx));
}
- spa_history_log_internal(LOG_DS_PERM_REMOVE,
- dd->dd_pool->dp_spa, tx,
- "%s %s dataset = %llu", whokey, perm,
- dd->dd_phys->dd_head_dataset_obj);
+ spa_history_log_internal_dd(dd, "permission remove", tx,
+ "%s %s", whokey, perm);
}
}
}
@@ -526,12 +518,10 @@ dsl_load_user_sets(objset_t *mos, uint64_t zapobj, avl_tree_t *avl,
}
/*
- * Check if user has requested permission. If descendent is set, must have
- * descendent perms.
+ * Check if user has requested permission.
*/
int
-dsl_deleg_access_impl(dsl_dataset_t *ds, boolean_t descendent, const char *perm,
- cred_t *cr)
+dsl_deleg_access_impl(dsl_dataset_t *ds, const char *perm, cred_t *cr)
{
dsl_dir_t *dd;
dsl_pool_t *dp;
@@ -552,7 +542,7 @@ dsl_deleg_access_impl(dsl_dataset_t *ds, boolean_t descendent, const char *perm,
SPA_VERSION_DELEGATED_PERMS)
return (EPERM);
- if (dsl_dataset_is_snapshot(ds) || descendent) {
+ if (dsl_dataset_is_snapshot(ds)) {
/*
* Snapshots are treated as descendents only,
* local permissions do not apply.
@@ -645,7 +635,7 @@ dsl_deleg_access(const char *dsname, const char *perm, cred_t *cr)
if (error)
return (error);
- error = dsl_deleg_access_impl(ds, B_FALSE, perm, cr);
+ error = dsl_deleg_access_impl(ds, perm, cr);
dsl_dataset_rele(ds, FTAG);
return (error);
diff --git a/usr/src/uts/common/fs/zfs/dsl_dir.c b/usr/src/uts/common/fs/zfs/dsl_dir.c
index b6af7598e2..35fe0e5efa 100644
--- a/usr/src/uts/common/fs/zfs/dsl_dir.c
+++ b/usr/src/uts/common/fs/zfs/dsl_dir.c
@@ -20,6 +20,7 @@
*/
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012 by Delphix. All rights reserved.
*/
#include <sys/dmu.h>
@@ -40,8 +41,8 @@
#include "zfs_namecheck.h"
static uint64_t dsl_dir_space_towrite(dsl_dir_t *dd);
-static void dsl_dir_set_reservation_sync(void *arg1, void *arg2, dmu_tx_t *tx);
-
+static void dsl_dir_set_reservation_sync_impl(dsl_dir_t *dd,
+ uint64_t value, dmu_tx_t *tx);
/* ARGSUSED */
static void
@@ -448,8 +449,7 @@ dsl_dir_create_sync(dsl_pool_t *dp, dsl_dir_t *pds, const char *name,
int
dsl_dir_destroy_check(void *arg1, void *arg2, dmu_tx_t *tx)
{
- dsl_dataset_t *ds = arg1;
- dsl_dir_t *dd = ds->ds_dir;
+ dsl_dir_t *dd = arg1;
dsl_pool_t *dp = dd->dd_pool;
objset_t *mos = dp->dp_meta_objset;
int err;
@@ -478,24 +478,19 @@ dsl_dir_destroy_check(void *arg1, void *arg2, dmu_tx_t *tx)
void
dsl_dir_destroy_sync(void *arg1, void *tag, dmu_tx_t *tx)
{
- dsl_dataset_t *ds = arg1;
- dsl_dir_t *dd = ds->ds_dir;
+ dsl_dir_t *dd = arg1;
objset_t *mos = dd->dd_pool->dp_meta_objset;
- dsl_prop_setarg_t psa;
- uint64_t value = 0;
uint64_t obj;
dd_used_t t;
ASSERT(RW_WRITE_HELD(&dd->dd_pool->dp_config_rwlock));
ASSERT(dd->dd_phys->dd_head_dataset_obj == 0);
- /* Remove our reservation. */
- dsl_prop_setarg_init_uint64(&psa, "reservation",
- (ZPROP_SRC_NONE | ZPROP_SRC_LOCAL | ZPROP_SRC_RECEIVED),
- &value);
- psa.psa_effective_value = 0; /* predict default value */
-
- dsl_dir_set_reservation_sync(ds, &psa, tx);
+ /*
+ * Remove our reservation. The impl() routine avoids setting the
+ * actual property, which would require the (already destroyed) ds.
+ */
+ dsl_dir_set_reservation_sync_impl(dd, 0, tx);
ASSERT3U(dd->dd_phys->dd_used_bytes, ==, 0);
ASSERT3U(dd->dd_phys->dd_reserved, ==, 0);
@@ -1062,9 +1057,8 @@ dsl_dir_set_quota_sync(void *arg1, void *arg2, dmu_tx_t *tx)
dd->dd_phys->dd_quota = effective_value;
mutex_exit(&dd->dd_lock);
- spa_history_log_internal(LOG_DS_QUOTA, dd->dd_pool->dp_spa,
- tx, "%lld dataset = %llu ",
- (longlong_t)effective_value, dd->dd_phys->dd_head_dataset_obj);
+ spa_history_log_internal_dd(dd, "set quota", tx,
+ "quota=%lld", (longlong_t)effective_value);
}
int
@@ -1151,25 +1145,17 @@ dsl_dir_set_reservation_check(void *arg1, void *arg2, dmu_tx_t *tx)
}
static void
-dsl_dir_set_reservation_sync(void *arg1, void *arg2, dmu_tx_t *tx)
+dsl_dir_set_reservation_sync_impl(dsl_dir_t *dd, uint64_t value, dmu_tx_t *tx)
{
- dsl_dataset_t *ds = arg1;
- dsl_dir_t *dd = ds->ds_dir;
- dsl_prop_setarg_t *psa = arg2;
- uint64_t effective_value = psa->psa_effective_value;
uint64_t used;
int64_t delta;
- dsl_prop_set_sync(ds, psa, tx);
- DSL_PROP_CHECK_PREDICTION(dd, psa);
-
dmu_buf_will_dirty(dd->dd_dbuf, tx);
mutex_enter(&dd->dd_lock);
used = dd->dd_phys->dd_used_bytes;
- delta = MAX(used, effective_value) -
- MAX(used, dd->dd_phys->dd_reserved);
- dd->dd_phys->dd_reserved = effective_value;
+ delta = MAX(used, value) - MAX(used, dd->dd_phys->dd_reserved);
+ dd->dd_phys->dd_reserved = value;
if (dd->dd_parent != NULL) {
/* Roll up this additional usage into our ancestors */
@@ -1177,10 +1163,24 @@ dsl_dir_set_reservation_sync(void *arg1, void *arg2, dmu_tx_t *tx)
delta, 0, 0, tx);
}
mutex_exit(&dd->dd_lock);
+}
+
+
+static void
+dsl_dir_set_reservation_sync(void *arg1, void *arg2, dmu_tx_t *tx)
+{
+ dsl_dataset_t *ds = arg1;
+ dsl_dir_t *dd = ds->ds_dir;
+ dsl_prop_setarg_t *psa = arg2;
+ uint64_t value = psa->psa_effective_value;
+
+ dsl_prop_set_sync(ds, psa, tx);
+ DSL_PROP_CHECK_PREDICTION(dd, psa);
- spa_history_log_internal(LOG_DS_RESERVATION, dd->dd_pool->dp_spa,
- tx, "%lld dataset = %llu",
- (longlong_t)effective_value, dd->dd_phys->dd_head_dataset_obj);
+ dsl_dir_set_reservation_sync_impl(dd, value, tx);
+
+ spa_history_log_internal_dd(dd, "set reservation", tx,
+ "reservation=%lld", (longlong_t)value);
}
int
@@ -1301,9 +1301,15 @@ dsl_dir_rename_sync(void *arg1, void *arg2, dmu_tx_t *tx)
dsl_pool_t *dp = dd->dd_pool;
objset_t *mos = dp->dp_meta_objset;
int err;
+ char namebuf[MAXNAMELEN];
ASSERT(dmu_buf_refcount(dd->dd_dbuf) <= 2);
+ /* Log this before we change the name. */
+ dsl_dir_name(ra->newparent, namebuf);
+ spa_history_log_internal_dd(dd, "rename", tx,
+ "-> %s/%s", namebuf, ra->mynewname);
+
if (ra->newparent != dd->dd_parent) {
dsl_dir_diduse_space(dd->dd_parent, DD_USED_CHILD,
-dd->dd_phys->dd_used_bytes,
@@ -1343,8 +1349,6 @@ dsl_dir_rename_sync(void *arg1, void *arg2, dmu_tx_t *tx)
dd->dd_myname, 8, 1, &dd->dd_object, tx);
ASSERT3U(err, ==, 0);
- spa_history_log_internal(LOG_DS_RENAME, dd->dd_pool->dp_spa,
- tx, "dataset = %llu", dd->dd_phys->dd_head_dataset_obj);
}
int
diff --git a/usr/src/uts/common/fs/zfs/dsl_pool.c b/usr/src/uts/common/fs/zfs/dsl_pool.c
index 316b37cebd..31c42767b1 100644
--- a/usr/src/uts/common/fs/zfs/dsl_pool.c
+++ b/usr/src/uts/common/fs/zfs/dsl_pool.c
@@ -20,7 +20,7 @@
*/
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2011 by Delphix. All rights reserved.
+ * Copyright (c) 2012 by Delphix. All rights reserved.
*/
#include <sys/dsl_pool.h>
@@ -41,6 +41,8 @@
#include <sys/spa_impl.h>
#include <sys/dsl_deadlist.h>
#include <sys/zfs_zone.h>
+#include <sys/bptree.h>
+#include <sys/zfeature.h>
int zfs_no_write_throttle = 0;
int zfs_write_limit_shift = 3; /* 1/8th of physical memory */
@@ -101,20 +103,32 @@ dsl_pool_open_impl(spa_t *spa, uint64_t txg)
}
int
-dsl_pool_open(spa_t *spa, uint64_t txg, dsl_pool_t **dpp)
+dsl_pool_init(spa_t *spa, uint64_t txg, dsl_pool_t **dpp)
{
int err;
dsl_pool_t *dp = dsl_pool_open_impl(spa, txg);
+
+ err = dmu_objset_open_impl(spa, NULL, &dp->dp_meta_rootbp,
+ &dp->dp_meta_objset);
+ if (err != 0)
+ dsl_pool_close(dp);
+ else
+ *dpp = dp;
+
+ return (err);
+}
+
+int
+dsl_pool_open(dsl_pool_t *dp)
+{
+ int err;
dsl_dir_t *dd;
dsl_dataset_t *ds;
uint64_t obj;
- rw_enter(&dp->dp_config_rwlock, RW_WRITER);
- err = dmu_objset_open_impl(spa, NULL, &dp->dp_meta_rootbp,
- &dp->dp_meta_objset);
- if (err)
- goto out;
+ ASSERT(!dmu_objset_is_dirty_anywhere(dp->dp_meta_objset));
+ rw_enter(&dp->dp_config_rwlock, RW_WRITER);
err = zap_lookup(dp->dp_meta_objset, DMU_POOL_DIRECTORY_OBJECT,
DMU_POOL_ROOT_DATASET, sizeof (uint64_t), 1,
&dp->dp_root_dir_obj);
@@ -130,7 +144,7 @@ dsl_pool_open(spa_t *spa, uint64_t txg, dsl_pool_t **dpp)
if (err)
goto out;
- if (spa_version(spa) >= SPA_VERSION_ORIGIN) {
+ if (spa_version(dp->dp_spa) >= SPA_VERSION_ORIGIN) {
err = dsl_pool_open_special_dir(dp, ORIGIN_DIR_NAME, &dd);
if (err)
goto out;
@@ -147,7 +161,7 @@ dsl_pool_open(spa_t *spa, uint64_t txg, dsl_pool_t **dpp)
goto out;
}
- if (spa_version(spa) >= SPA_VERSION_DEADLISTS) {
+ if (spa_version(dp->dp_spa) >= SPA_VERSION_DEADLISTS) {
err = dsl_pool_open_special_dir(dp, FREE_DIR_NAME,
&dp->dp_free_dir);
if (err)
@@ -161,6 +175,15 @@ dsl_pool_open(spa_t *spa, uint64_t txg, dsl_pool_t **dpp)
dp->dp_meta_objset, obj));
}
+ if (spa_feature_is_active(dp->dp_spa,
+ &spa_feature_table[SPA_FEATURE_ASYNC_DESTROY])) {
+ err = zap_lookup(dp->dp_meta_objset, DMU_POOL_DIRECTORY_OBJECT,
+ DMU_POOL_BPTREE_OBJ, sizeof (uint64_t), 1,
+ &dp->dp_bptree_obj);
+ if (err != 0)
+ goto out;
+ }
+
err = zap_lookup(dp->dp_meta_objset, DMU_POOL_DIRECTORY_OBJECT,
DMU_POOL_TMP_USERREFS, sizeof (uint64_t), 1,
&dp->dp_tmp_userrefs_obj);
@@ -169,15 +192,10 @@ dsl_pool_open(spa_t *spa, uint64_t txg, dsl_pool_t **dpp)
if (err)
goto out;
- err = dsl_scan_init(dp, txg);
+ err = dsl_scan_init(dp, dp->dp_tx.tx_open_txg);
out:
rw_exit(&dp->dp_config_rwlock);
- if (err)
- dsl_pool_close(dp);
- else
- *dpp = dp;
-
return (err);
}
@@ -471,7 +489,7 @@ int
dsl_pool_sync_context(dsl_pool_t *dp)
{
return (curthread == dp->dp_tx.tx_sync_thread ||
- spa_get_dsl(dp->dp_spa) == NULL);
+ spa_is_initializing(dp->dp_spa));
}
uint64_t
@@ -789,11 +807,8 @@ dsl_pool_user_hold_create_obj(dsl_pool_t *dp, dmu_tx_t *tx)
ASSERT(dp->dp_tmp_userrefs_obj == 0);
ASSERT(dmu_tx_is_syncing(tx));
- dp->dp_tmp_userrefs_obj = zap_create(mos, DMU_OT_USERREFS,
- DMU_OT_NONE, 0, tx);
-
- VERIFY(zap_add(mos, DMU_POOL_DIRECTORY_OBJECT, DMU_POOL_TMP_USERREFS,
- sizeof (uint64_t), 1, &dp->dp_tmp_userrefs_obj, tx) == 0);
+ dp->dp_tmp_userrefs_obj = zap_create_link(mos, DMU_OT_USERREFS,
+ DMU_POOL_DIRECTORY_OBJECT, DMU_POOL_TMP_USERREFS, tx);
}
static int
diff --git a/usr/src/uts/common/fs/zfs/dsl_prop.c b/usr/src/uts/common/fs/zfs/dsl_prop.c
index aa66b32e79..5bbe14ff69 100644
--- a/usr/src/uts/common/fs/zfs/dsl_prop.c
+++ b/usr/src/uts/common/fs/zfs/dsl_prop.c
@@ -20,6 +20,7 @@
*/
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012 by Delphix. All rights reserved.
*/
#include <sys/zfs_context.h>
@@ -702,11 +703,9 @@ dsl_prop_set_sync(void *arg1, void *arg2, dmu_tx_t *tx)
}
}
- spa_history_log_internal((source == ZPROP_SRC_NONE ||
- source == ZPROP_SRC_INHERITED) ? LOG_DS_INHERIT :
- LOG_DS_PROPSET, ds->ds_dir->dd_pool->dp_spa, tx,
- "%s=%s dataset = %llu", propname,
- (valstr == NULL ? "" : valstr), ds->ds_object);
+ spa_history_log_internal_ds(ds, (source == ZPROP_SRC_NONE ||
+ source == ZPROP_SRC_INHERITED) ? "inherit" : "set", tx,
+ "%s=%s", propname, (valstr == NULL ? "" : valstr));
if (tbuf != NULL)
kmem_free(tbuf, ZAP_MAXVALUELEN);
@@ -755,24 +754,6 @@ dsl_props_set_sync(void *arg1, void *arg2, dmu_tx_t *tx)
}
}
-void
-dsl_dir_prop_set_uint64_sync(dsl_dir_t *dd, const char *name, uint64_t val,
- dmu_tx_t *tx)
-{
- objset_t *mos = dd->dd_pool->dp_meta_objset;
- uint64_t zapobj = dd->dd_phys->dd_props_zapobj;
-
- ASSERT(dmu_tx_is_syncing(tx));
-
- VERIFY(0 == zap_update(mos, zapobj, name, sizeof (val), 1, &val, tx));
-
- dsl_prop_changed_notify(dd->dd_pool, dd->dd_object, name, val, TRUE);
-
- spa_history_log_internal(LOG_DS_PROPSET, dd->dd_pool->dp_spa, tx,
- "%s=%llu dataset = %llu", name, (u_longlong_t)val,
- dd->dd_phys->dd_head_dataset_obj);
-}
-
int
dsl_prop_set(const char *dsname, const char *propname, zprop_source_t source,
int intsz, int numints, const void *buf)
diff --git a/usr/src/uts/common/fs/zfs/dsl_scan.c b/usr/src/uts/common/fs/zfs/dsl_scan.c
index 56d4108367..8f08f04a06 100644
--- a/usr/src/uts/common/fs/zfs/dsl_scan.c
+++ b/usr/src/uts/common/fs/zfs/dsl_scan.c
@@ -20,6 +20,7 @@
*/
/*
* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012 by Delphix. All rights reserved.
*/
#include <sys/dsl_scan.h>
@@ -44,6 +45,7 @@
#include <sys/ddt.h>
#include <sys/sa.h>
#include <sys/sa_impl.h>
+#include <sys/zfeature.h>
#ifdef _KERNEL
#include <sys/zfs_vfsops.h>
#endif
@@ -226,7 +228,7 @@ dsl_scan_setup_sync(void *arg1, void *arg2, dmu_tx_t *tx)
dsl_scan_sync_state(scn, tx);
- spa_history_log_internal(LOG_POOL_SCAN, spa, tx,
+ spa_history_log_internal(spa, "scan setup", tx,
"func=%u mintxg=%llu maxtxg=%llu",
*funcp, scn->scn_phys.scn_min_txg, scn->scn_phys.scn_max_txg);
}
@@ -275,7 +277,7 @@ dsl_scan_done(dsl_scan_t *scn, boolean_t complete, dmu_tx_t *tx)
else
scn->scn_phys.scn_state = DSS_CANCELED;
- spa_history_log_internal(LOG_POOL_SCAN_DONE, spa, tx,
+ spa_history_log_internal(spa, "scan done", tx,
"complete=%u", complete);
if (DSL_SCAN_IS_SCRUB_RESILVER(scn)) {
@@ -382,55 +384,6 @@ dsl_read_nolock(zio_t *pio, spa_t *spa, const blkptr_t *bpp,
priority, zio_flags, arc_flags, zb));
}
-static boolean_t
-bookmark_is_zero(const zbookmark_t *zb)
-{
- return (zb->zb_objset == 0 && zb->zb_object == 0 &&
- zb->zb_level == 0 && zb->zb_blkid == 0);
-}
-
-/* dnp is the dnode for zb1->zb_object */
-static boolean_t
-bookmark_is_before(const dnode_phys_t *dnp, const zbookmark_t *zb1,
- const zbookmark_t *zb2)
-{
- uint64_t zb1nextL0, zb2thisobj;
-
- ASSERT(zb1->zb_objset == zb2->zb_objset);
- ASSERT(zb2->zb_level == 0);
-
- /*
- * A bookmark in the deadlist is considered to be after
- * everything else.
- */
- if (zb2->zb_object == DMU_DEADLIST_OBJECT)
- return (B_TRUE);
-
- /* The objset_phys_t isn't before anything. */
- if (dnp == NULL)
- return (B_FALSE);
-
- zb1nextL0 = (zb1->zb_blkid + 1) <<
- ((zb1->zb_level) * (dnp->dn_indblkshift - SPA_BLKPTRSHIFT));
-
- zb2thisobj = zb2->zb_object ? zb2->zb_object :
- zb2->zb_blkid << (DNODE_BLOCK_SHIFT - DNODE_SHIFT);
-
- if (zb1->zb_object == DMU_META_DNODE_OBJECT) {
- uint64_t nextobj = zb1nextL0 *
- (dnp->dn_datablkszsec << SPA_MINBLOCKSHIFT) >> DNODE_SHIFT;
- return (nextobj <= zb2thisobj);
- }
-
- if (zb1->zb_object < zb2thisobj)
- return (B_TRUE);
- if (zb1->zb_object > zb2thisobj)
- return (B_FALSE);
- if (zb2->zb_object == DMU_META_DNODE_OBJECT)
- return (B_FALSE);
- return (zb1nextL0 <= zb2->zb_blkid);
-}
-
static uint64_t
dsl_scan_ds_maxtxg(dsl_dataset_t *ds)
{
@@ -462,7 +415,7 @@ dsl_scan_check_pause(dsl_scan_t *scn, const zbookmark_t *zb)
if (scn->scn_pausing)
return (B_TRUE); /* we're already pausing */
- if (!bookmark_is_zero(&scn->scn_phys.scn_bookmark))
+ if (!ZB_IS_ZERO(&scn->scn_phys.scn_bookmark))
return (B_FALSE); /* we're resuming */
/* We only know how to resume from level-0 blocks. */
@@ -617,13 +570,13 @@ dsl_scan_check_resume(dsl_scan_t *scn, const dnode_phys_t *dnp,
/*
* We never skip over user/group accounting objects (obj<0)
*/
- if (!bookmark_is_zero(&scn->scn_phys.scn_bookmark) &&
+ if (!ZB_IS_ZERO(&scn->scn_phys.scn_bookmark) &&
(int64_t)zb->zb_object >= 0) {
/*
* If we already visited this bp & everything below (in
* a prior txg sync), don't bother doing it again.
*/
- if (bookmark_is_before(dnp, zb, &scn->scn_phys.scn_bookmark))
+ if (zbookmark_is_before(dnp, zb, &scn->scn_phys.scn_bookmark))
return (B_TRUE);
/*
@@ -816,22 +769,6 @@ dsl_scan_visitbp(blkptr_t *bp, const zbookmark_t *zb,
if (bp->blk_birth <= scn->scn_phys.scn_cur_min_txg)
return;
- if (BP_GET_TYPE(bp) != DMU_OT_USERGROUP_USED) {
- /*
- * For non-user-accounting blocks, we need to read the
- * new bp (from a deleted snapshot, found in
- * check_existing_xlation). If we used the old bp,
- * pointers inside this block from before we resumed
- * would be untranslated.
- *
- * For user-accounting blocks, we need to read the old
- * bp, because we will apply the entire space delta to
- * it (original untranslated -> translations from
- * deleted snap -> now).
- */
- bp_toread = *bp;
- }
-
if (dsl_scan_recurse(scn, ds, ostype, dnp, &bp_toread, zb, tx,
&buf) != 0)
return;
@@ -1396,19 +1333,28 @@ dsl_scan_visit(dsl_scan_t *scn, dmu_tx_t *tx)
zap_cursor_fini(&zc);
}
-static int
-dsl_scan_free_cb(void *arg, const blkptr_t *bp, dmu_tx_t *tx)
+static boolean_t
+dsl_scan_free_should_pause(dsl_scan_t *scn)
{
- dsl_scan_t *scn = arg;
uint64_t elapsed_nanosecs;
elapsed_nanosecs = gethrtime() - scn->scn_sync_start_time;
-
- if (elapsed_nanosecs / NANOSEC > zfs_txg_timeout ||
+ return (elapsed_nanosecs / NANOSEC > zfs_txg_timeout ||
(elapsed_nanosecs / MICROSEC > zfs_free_min_time_ms &&
txg_sync_waiting(scn->scn_dp)) ||
- spa_shutting_down(scn->scn_dp->dp_spa))
- return (ERESTART);
+ spa_shutting_down(scn->scn_dp->dp_spa));
+}
+
+static int
+dsl_scan_free_block_cb(void *arg, const blkptr_t *bp, dmu_tx_t *tx)
+{
+ dsl_scan_t *scn = arg;
+
+ if (!scn->scn_is_bptree ||
+ (BP_GET_LEVEL(bp) == 0 && BP_GET_TYPE(bp) != DMU_OT_OBJSET)) {
+ if (dsl_scan_free_should_pause(scn))
+ return (ERESTART);
+ }
zio_nowait(zio_free_sync(scn->scn_zio_root, scn->scn_dp->dp_spa,
dmu_tx_get_txg(tx), bp, 0));
@@ -1433,6 +1379,10 @@ dsl_scan_active(dsl_scan_t *scn)
if (scn->scn_phys.scn_state == DSS_SCANNING)
return (B_TRUE);
+ if (spa_feature_is_active(spa,
+ &spa_feature_table[SPA_FEATURE_ASYNC_DESTROY])) {
+ return (B_TRUE);
+ }
if (spa_version(scn->scn_dp->dp_spa) >= SPA_VERSION_DEADLISTS) {
(void) bpobj_space(&scn->scn_dp->dp_free_bpobj,
&used, &comp, &uncomp);
@@ -1479,14 +1429,40 @@ dsl_scan_sync(dsl_pool_t *dp, dmu_tx_t *tx)
* traversing it.
*/
if (spa_version(dp->dp_spa) >= SPA_VERSION_DEADLISTS) {
+ scn->scn_is_bptree = B_FALSE;
scn->scn_zio_root = zio_root(dp->dp_spa, NULL,
NULL, ZIO_FLAG_MUSTSUCCEED);
err = bpobj_iterate(&dp->dp_free_bpobj,
- dsl_scan_free_cb, scn, tx);
+ dsl_scan_free_block_cb, scn, tx);
VERIFY3U(0, ==, zio_wait(scn->scn_zio_root));
+
+ if (err == 0 && spa_feature_is_active(spa,
+ &spa_feature_table[SPA_FEATURE_ASYNC_DESTROY])) {
+ scn->scn_is_bptree = B_TRUE;
+ scn->scn_zio_root = zio_root(dp->dp_spa, NULL,
+ NULL, ZIO_FLAG_MUSTSUCCEED);
+ err = bptree_iterate(dp->dp_meta_objset,
+ dp->dp_bptree_obj, B_TRUE, dsl_scan_free_block_cb,
+ scn, tx);
+ VERIFY3U(0, ==, zio_wait(scn->scn_zio_root));
+ if (err != 0)
+ return;
+
+ /* disable async destroy feature */
+ spa_feature_decr(spa,
+ &spa_feature_table[SPA_FEATURE_ASYNC_DESTROY], tx);
+ ASSERT(!spa_feature_is_active(spa,
+ &spa_feature_table[SPA_FEATURE_ASYNC_DESTROY]));
+ VERIFY3U(0, ==, zap_remove(dp->dp_meta_objset,
+ DMU_POOL_DIRECTORY_OBJECT,
+ DMU_POOL_BPTREE_OBJ, tx));
+ VERIFY3U(0, ==, bptree_free(dp->dp_meta_objset,
+ dp->dp_bptree_obj, tx));
+ dp->dp_bptree_obj = 0;
+ }
if (scn->scn_visited_this_txg) {
zfs_dbgmsg("freed %llu blocks in %llums from "
- "free_bpobj txg %llu",
+ "free_bpobj/bptree txg %llu",
(longlong_t)scn->scn_visited_this_txg,
(longlong_t)
(gethrtime() - scn->scn_sync_start_time) / MICROSEC,
@@ -1601,6 +1577,8 @@ count_block(zfs_all_blkstats_t *zab, const blkptr_t *bp)
for (i = 0; i < 4; i++) {
int l = (i < 2) ? BP_GET_LEVEL(bp) : DN_MAX_LEVELS;
int t = (i & 1) ? BP_GET_TYPE(bp) : DMU_OT_TOTAL;
+ if (t & DMU_OT_NEWTYPE)
+ t = DMU_OT_OTHER;
zfs_blkstat_t *zb = &zab->zab_type[l][t];
int equal;
diff --git a/usr/src/uts/common/fs/zfs/dsl_synctask.c b/usr/src/uts/common/fs/zfs/dsl_synctask.c
index b0818ce274..312423e943 100644
--- a/usr/src/uts/common/fs/zfs/dsl_synctask.c
+++ b/usr/src/uts/common/fs/zfs/dsl_synctask.c
@@ -20,6 +20,7 @@
*/
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012 by Delphix. All rights reserved.
*/
#include <sys/dmu.h>
@@ -85,17 +86,17 @@ top:
/* Do a preliminary error check. */
dstg->dstg_err = 0;
+#ifdef ZFS_DEBUG
+ /*
+ * Only check half the time, otherwise, the sync-context
+ * check will almost never fail.
+ */
+ if (spa_get_random(2) == 0)
+ goto skip;
+#endif
rw_enter(&dstg->dstg_pool->dp_config_rwlock, RW_READER);
for (dst = list_head(&dstg->dstg_tasks); dst;
dst = list_next(&dstg->dstg_tasks, dst)) {
-#ifdef ZFS_DEBUG
- /*
- * Only check half the time, otherwise, the sync-context
- * check will almost never fail.
- */
- if (spa_get_random(2) == 0)
- continue;
-#endif
dst->dst_err =
dst->dst_checkfunc(dst->dst_arg1, dst->dst_arg2, tx);
if (dst->dst_err)
@@ -107,6 +108,7 @@ top:
dmu_tx_commit(tx);
return (dstg->dstg_err);
}
+skip:
/*
* We don't generally have many sync tasks, so pay the price of
diff --git a/usr/src/uts/common/fs/zfs/rrwlock.c b/usr/src/uts/common/fs/zfs/rrwlock.c
index 4cef53f951..7f9290bd44 100644
--- a/usr/src/uts/common/fs/zfs/rrwlock.c
+++ b/usr/src/uts/common/fs/zfs/rrwlock.c
@@ -22,6 +22,9 @@
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
+/*
+ * Copyright (c) 2012 by Delphix. All rights reserved.
+ */
#include <sys/refcount.h>
#include <sys/rrwlock.h>
@@ -262,3 +265,13 @@ rrw_held(rrwlock_t *rrl, krw_t rw)
return (held);
}
+
+void
+rrw_tsd_destroy(void *arg)
+{
+ rrw_node_t *rn = arg;
+ if (rn != NULL) {
+ panic("thread %p terminating with rrw lock %p held",
+ (void *)curthread, (void *)rn->rn_rrl);
+ }
+}
diff --git a/usr/src/uts/common/fs/zfs/sa.c b/usr/src/uts/common/fs/zfs/sa.c
index 57b3565cba..06607d784e 100644
--- a/usr/src/uts/common/fs/zfs/sa.c
+++ b/usr/src/uts/common/fs/zfs/sa.c
@@ -18,9 +18,11 @@
*
* CDDL HEADER END
*/
+
/*
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
* Portions Copyright 2011 iXsystems, Inc
+ * Copyright (c) 2012 by Delphix. All rights reserved.
*/
#include <sys/zfs_context.h>
@@ -427,10 +429,9 @@ sa_add_layout_entry(objset_t *os, sa_attr_type_t *attrs, int attr_count,
char attr_name[8];
if (sa->sa_layout_attr_obj == 0) {
- sa->sa_layout_attr_obj = zap_create(os,
- DMU_OT_SA_ATTR_LAYOUTS, DMU_OT_NONE, 0, tx);
- VERIFY(zap_add(os, sa->sa_master_obj, SA_LAYOUTS, 8, 1,
- &sa->sa_layout_attr_obj, tx) == 0);
+ sa->sa_layout_attr_obj = zap_create_link(os,
+ DMU_OT_SA_ATTR_LAYOUTS,
+ sa->sa_master_obj, SA_LAYOUTS, tx);
}
(void) snprintf(attr_name, sizeof (attr_name),
@@ -1552,10 +1553,9 @@ sa_attr_register_sync(sa_handle_t *hdl, dmu_tx_t *tx)
}
if (sa->sa_reg_attr_obj == NULL) {
- sa->sa_reg_attr_obj = zap_create(hdl->sa_os,
- DMU_OT_SA_ATTR_REGISTRATION, DMU_OT_NONE, 0, tx);
- VERIFY(zap_add(hdl->sa_os, sa->sa_master_obj,
- SA_REGISTRY, 8, 1, &sa->sa_reg_attr_obj, tx) == 0);
+ sa->sa_reg_attr_obj = zap_create_link(hdl->sa_os,
+ DMU_OT_SA_ATTR_REGISTRATION,
+ sa->sa_master_obj, SA_REGISTRY, tx);
}
for (i = 0; i != sa->sa_num_attrs; i++) {
if (sa->sa_attr_table[i].sa_registered)
diff --git a/usr/src/uts/common/fs/zfs/spa.c b/usr/src/uts/common/fs/zfs/spa.c
index a4c61fc947..9c4af11134 100644
--- a/usr/src/uts/common/fs/zfs/spa.c
+++ b/usr/src/uts/common/fs/zfs/spa.c
@@ -62,6 +62,7 @@
#include <sys/spa_boot.h>
#include <sys/zfs_ioctl.h>
#include <sys/dsl_scan.h>
+#include <sys/zfeature.h>
#ifdef _KERNEL
#include <sys/bootprops.h>
@@ -113,6 +114,7 @@ const zio_taskq_info_t zio_taskqs[ZIO_TYPES][ZIO_TASKQ_TYPES] = {
{ ZTI_ONE, ZTI_NULL, ZTI_ONE, ZTI_NULL },
};
+static dsl_syncfunc_t spa_sync_version;
static dsl_syncfunc_t spa_sync_props;
static boolean_t spa_has_active_shared_spare(spa_t *spa);
static int spa_load_impl(spa_t *spa, uint64_t, nvlist_t *config,
@@ -168,6 +170,7 @@ static void
spa_prop_get_config(spa_t *spa, nvlist_t **nvp)
{
vdev_t *rvd = spa->spa_root_vdev;
+ dsl_pool_t *pool = spa->spa_dsl_pool;
uint64_t size;
uint64_t alloc;
uint64_t space;
@@ -214,6 +217,22 @@ spa_prop_get_config(spa_t *spa, nvlist_t **nvp)
spa_prop_add_list(*nvp, ZPOOL_PROP_VERSION, NULL, version, src);
}
+ if (pool != NULL) {
+ dsl_dir_t *freedir = pool->dp_free_dir;
+
+ /*
+ * The $FREE directory was introduced in SPA_VERSION_DEADLISTS,
+ * when opening pools before this version freedir will be NULL.
+ */
+ if (freedir != NULL) {
+ spa_prop_add_list(*nvp, ZPOOL_PROP_FREEING, NULL,
+ freedir->dd_phys->dd_used_bytes, src);
+ } else {
+ spa_prop_add_list(*nvp, ZPOOL_PROP_FREEING,
+ NULL, 0, src);
+ }
+ }
+
spa_prop_add_list(*nvp, ZPOOL_PROP_GUID, NULL, spa_guid(spa), src);
if (spa->spa_comment != NULL) {
@@ -353,25 +372,55 @@ spa_prop_validate(spa_t *spa, nvlist_t *props)
nvpair_t *elem;
int error = 0, reset_bootfs = 0;
uint64_t objnum;
+ boolean_t has_feature = B_FALSE;
elem = NULL;
while ((elem = nvlist_next_nvpair(props, elem)) != NULL) {
- zpool_prop_t prop;
- char *propname, *strval;
uint64_t intval;
- objset_t *os;
- char *slash, *check;
+ char *strval, *slash, *check, *fname;
+ const char *propname = nvpair_name(elem);
+ zpool_prop_t prop = zpool_name_to_prop(propname);
- propname = nvpair_name(elem);
+ switch (prop) {
+ case ZPROP_INVAL:
+ if (!zpool_prop_feature(propname)) {
+ error = EINVAL;
+ break;
+ }
- if ((prop = zpool_name_to_prop(propname)) == ZPROP_INVAL)
- return (EINVAL);
+ /*
+ * Sanitize the input.
+ */
+ if (nvpair_type(elem) != DATA_TYPE_UINT64) {
+ error = EINVAL;
+ break;
+ }
+
+ if (nvpair_value_uint64(elem, &intval) != 0) {
+ error = EINVAL;
+ break;
+ }
+
+ if (intval != 0) {
+ error = EINVAL;
+ break;
+ }
+
+ fname = strchr(propname, '@') + 1;
+ if (zfeature_lookup_name(fname, NULL) != 0) {
+ error = EINVAL;
+ break;
+ }
+
+ has_feature = B_TRUE;
+ break;
- switch (prop) {
case ZPOOL_PROP_VERSION:
error = nvpair_value_uint64(elem, &intval);
if (!error &&
- (intval < spa_version(spa) || intval > SPA_VERSION))
+ (intval < spa_version(spa) ||
+ intval > SPA_VERSION_BEFORE_FEATURES ||
+ has_feature))
error = EINVAL;
break;
@@ -408,6 +457,7 @@ spa_prop_validate(spa_t *spa, nvlist_t *props)
error = nvpair_value_string(elem, &strval);
if (!error) {
+ objset_t *os;
uint64_t compress;
if (strval == NULL || strval[0] == '\0') {
@@ -557,33 +607,58 @@ int
spa_prop_set(spa_t *spa, nvlist_t *nvp)
{
int error;
- nvpair_t *elem;
+ nvpair_t *elem = NULL;
boolean_t need_sync = B_FALSE;
- zpool_prop_t prop;
if ((error = spa_prop_validate(spa, nvp)) != 0)
return (error);
- elem = NULL;
while ((elem = nvlist_next_nvpair(nvp, elem)) != NULL) {
- if ((prop = zpool_name_to_prop(
- nvpair_name(elem))) == ZPROP_INVAL)
- return (EINVAL);
+ zpool_prop_t prop = zpool_name_to_prop(nvpair_name(elem));
if (prop == ZPOOL_PROP_CACHEFILE ||
prop == ZPOOL_PROP_ALTROOT ||
prop == ZPOOL_PROP_READONLY)
continue;
+ if (prop == ZPOOL_PROP_VERSION || prop == ZPROP_INVAL) {
+ uint64_t ver;
+
+ if (prop == ZPOOL_PROP_VERSION) {
+ VERIFY(nvpair_value_uint64(elem, &ver) == 0);
+ } else {
+ ASSERT(zpool_prop_feature(nvpair_name(elem)));
+ ver = SPA_VERSION_FEATURES;
+ need_sync = B_TRUE;
+ }
+
+ /* Save time if the version is already set. */
+ if (ver == spa_version(spa))
+ continue;
+
+ /*
+ * In addition to the pool directory object, we might
+ * create the pool properties object, the features for
+ * read object, the features for write object, or the
+ * feature descriptions object.
+ */
+ error = dsl_sync_task_do(spa_get_dsl(spa), NULL,
+ spa_sync_version, spa, &ver, 6);
+ if (error)
+ return (error);
+ continue;
+ }
+
need_sync = B_TRUE;
break;
}
- if (need_sync)
+ if (need_sync) {
return (dsl_sync_task_do(spa_get_dsl(spa), NULL, spa_sync_props,
- spa, nvp, 3));
- else
- return (0);
+ spa, nvp, 6));
+ }
+
+ return (0);
}
/*
@@ -1607,7 +1682,7 @@ spa_load_verify_done(zio_t *zio)
int error = zio->io_error;
if (error) {
- if ((BP_GET_LEVEL(bp) != 0 || dmu_ot[type].ot_metadata) &&
+ if ((BP_GET_LEVEL(bp) != 0 || DMU_OT_IS_METADATA(type)) &&
type != DMU_OT_INTENT_LOG)
atomic_add_64(&sle->sle_meta_count, 1);
else
@@ -1837,6 +1912,9 @@ spa_load(spa_t *spa, spa_load_state_t state, spa_import_type_t type,
KM_SLEEP) == 0);
}
+ nvlist_free(spa->spa_load_info);
+ spa->spa_load_info = fnvlist_alloc();
+
gethrestime(&spa->spa_loaded_ts);
error = spa_load_impl(spa, pool_guid, config, state, type,
mosconfig, &ereport);
@@ -1869,12 +1947,14 @@ spa_load_impl(spa_t *spa, uint64_t pool_guid, nvlist_t *config,
{
int error = 0;
nvlist_t *nvroot = NULL;
+ nvlist_t *label;
vdev_t *rvd;
uberblock_t *ub = &spa->spa_uberblock;
uint64_t children, config_cache_txg = spa->spa_config_txg;
int orig_mode = spa->spa_mode;
int parse;
uint64_t obj;
+ boolean_t missing_feat_write = B_FALSE;
/*
* If this is an untrusted config, access the pool in read-only mode.
@@ -1954,19 +2034,78 @@ spa_load_impl(spa_t *spa, uint64_t pool_guid, nvlist_t *config,
/*
* Find the best uberblock.
*/
- vdev_uberblock_load(NULL, rvd, ub);
+ vdev_uberblock_load(rvd, ub, &label);
/*
* If we weren't able to find a single valid uberblock, return failure.
*/
- if (ub->ub_txg == 0)
+ if (ub->ub_txg == 0) {
+ nvlist_free(label);
return (spa_vdev_err(rvd, VDEV_AUX_CORRUPT_DATA, ENXIO));
+ }
/*
- * If the pool is newer than the code, we can't open it.
+ * If the pool has an unsupported version we can't open it.
*/
- if (ub->ub_version > SPA_VERSION)
+ if (!SPA_VERSION_IS_SUPPORTED(ub->ub_version)) {
+ nvlist_free(label);
return (spa_vdev_err(rvd, VDEV_AUX_VERSION_NEWER, ENOTSUP));
+ }
+
+ if (ub->ub_version >= SPA_VERSION_FEATURES) {
+ nvlist_t *features;
+
+ /*
+ * If we weren't able to find what's necessary for reading the
+ * MOS in the label, return failure.
+ */
+ if (label == NULL || nvlist_lookup_nvlist(label,
+ ZPOOL_CONFIG_FEATURES_FOR_READ, &features) != 0) {
+ nvlist_free(label);
+ return (spa_vdev_err(rvd, VDEV_AUX_CORRUPT_DATA,
+ ENXIO));
+ }
+
+ /*
+ * Update our in-core representation with the definitive values
+ * from the label.
+ */
+ nvlist_free(spa->spa_label_features);
+ VERIFY(nvlist_dup(features, &spa->spa_label_features, 0) == 0);
+ }
+
+ nvlist_free(label);
+
+ /*
+ * Look through entries in the label nvlist's features_for_read. If
+ * there is a feature listed there which we don't understand then we
+ * cannot open a pool.
+ */
+ if (ub->ub_version >= SPA_VERSION_FEATURES) {
+ nvlist_t *unsup_feat;
+
+ VERIFY(nvlist_alloc(&unsup_feat, NV_UNIQUE_NAME, KM_SLEEP) ==
+ 0);
+
+ for (nvpair_t *nvp = nvlist_next_nvpair(spa->spa_label_features,
+ NULL); nvp != NULL;
+ nvp = nvlist_next_nvpair(spa->spa_label_features, nvp)) {
+ if (!zfeature_is_supported(nvpair_name(nvp))) {
+ VERIFY(nvlist_add_string(unsup_feat,
+ nvpair_name(nvp), "") == 0);
+ }
+ }
+
+ if (!nvlist_empty(unsup_feat)) {
+ VERIFY(nvlist_add_nvlist(spa->spa_load_info,
+ ZPOOL_CONFIG_UNSUP_FEAT, unsup_feat) == 0);
+ nvlist_free(unsup_feat);
+ return (spa_vdev_err(rvd, VDEV_AUX_UNSUP_FEAT,
+ ENOTSUP));
+ }
+
+ nvlist_free(unsup_feat);
+ }
/*
* If the vdev guid sum doesn't match the uberblock, we have an
@@ -2000,7 +2139,7 @@ spa_load_impl(spa_t *spa, uint64_t pool_guid, nvlist_t *config,
spa->spa_claim_max_txg = spa->spa_first_txg;
spa->spa_prev_software_version = ub->ub_software_version;
- error = dsl_pool_open(spa, spa->spa_first_txg, &spa->spa_dsl_pool);
+ error = dsl_pool_init(spa, spa->spa_first_txg, &spa->spa_dsl_pool);
if (error)
return (spa_vdev_err(rvd, VDEV_AUX_CORRUPT_DATA, EIO));
spa->spa_meta_objset = spa->spa_dsl_pool->dp_meta_objset;
@@ -2008,6 +2147,89 @@ spa_load_impl(spa_t *spa, uint64_t pool_guid, nvlist_t *config,
if (spa_dir_prop(spa, DMU_POOL_CONFIG, &spa->spa_config_object) != 0)
return (spa_vdev_err(rvd, VDEV_AUX_CORRUPT_DATA, EIO));
+ if (spa_version(spa) >= SPA_VERSION_FEATURES) {
+ boolean_t missing_feat_read = B_FALSE;
+ nvlist_t *unsup_feat, *enabled_feat;
+
+ if (spa_dir_prop(spa, DMU_POOL_FEATURES_FOR_READ,
+ &spa->spa_feat_for_read_obj) != 0) {
+ return (spa_vdev_err(rvd, VDEV_AUX_CORRUPT_DATA, EIO));
+ }
+
+ if (spa_dir_prop(spa, DMU_POOL_FEATURES_FOR_WRITE,
+ &spa->spa_feat_for_write_obj) != 0) {
+ return (spa_vdev_err(rvd, VDEV_AUX_CORRUPT_DATA, EIO));
+ }
+
+ if (spa_dir_prop(spa, DMU_POOL_FEATURE_DESCRIPTIONS,
+ &spa->spa_feat_desc_obj) != 0) {
+ return (spa_vdev_err(rvd, VDEV_AUX_CORRUPT_DATA, EIO));
+ }
+
+ enabled_feat = fnvlist_alloc();
+ unsup_feat = fnvlist_alloc();
+
+ if (!feature_is_supported(spa->spa_meta_objset,
+ spa->spa_feat_for_read_obj, spa->spa_feat_desc_obj,
+ unsup_feat, enabled_feat))
+ missing_feat_read = B_TRUE;
+
+ if (spa_writeable(spa) || state == SPA_LOAD_TRYIMPORT) {
+ if (!feature_is_supported(spa->spa_meta_objset,
+ spa->spa_feat_for_write_obj, spa->spa_feat_desc_obj,
+ unsup_feat, enabled_feat)) {
+ missing_feat_write = B_TRUE;
+ }
+ }
+
+ fnvlist_add_nvlist(spa->spa_load_info,
+ ZPOOL_CONFIG_ENABLED_FEAT, enabled_feat);
+
+ if (!nvlist_empty(unsup_feat)) {
+ fnvlist_add_nvlist(spa->spa_load_info,
+ ZPOOL_CONFIG_UNSUP_FEAT, unsup_feat);
+ }
+
+ fnvlist_free(enabled_feat);
+ fnvlist_free(unsup_feat);
+
+ if (!missing_feat_read) {
+ fnvlist_add_boolean(spa->spa_load_info,
+ ZPOOL_CONFIG_CAN_RDONLY);
+ }
+
+ /*
+ * If the state is SPA_LOAD_TRYIMPORT, our objective is
+ * twofold: to determine whether the pool is available for
+ * import in read-write mode and (if it is not) whether the
+ * pool is available for import in read-only mode. If the pool
+ * is available for import in read-write mode, it is displayed
+ * as available in userland; if it is not available for import
+ * in read-only mode, it is displayed as unavailable in
+ * userland. If the pool is available for import in read-only
+ * mode but not read-write mode, it is displayed as unavailable
+ * in userland with a special note that the pool is actually
+ * available for open in read-only mode.
+ *
+ * As a result, if the state is SPA_LOAD_TRYIMPORT and we are
+ * missing a feature for write, we must first determine whether
+ * the pool can be opened read-only before returning to
+ * userland in order to know whether to display the
+ * abovementioned note.
+ */
+ if (missing_feat_read || (missing_feat_write &&
+ spa_writeable(spa))) {
+ return (spa_vdev_err(rvd, VDEV_AUX_UNSUP_FEAT,
+ ENOTSUP));
+ }
+ }
+
+ spa->spa_is_initializing = B_TRUE;
+ error = dsl_pool_open(spa->spa_dsl_pool);
+ spa->spa_is_initializing = B_FALSE;
+ if (error != 0)
+ return (spa_vdev_err(rvd, VDEV_AUX_CORRUPT_DATA, EIO));
+
if (!mosconfig) {
uint64_t hostid;
nvlist_t *policy = NULL, *nvconfig;
@@ -2225,7 +2447,7 @@ spa_load_impl(spa_t *spa, uint64_t pool_guid, nvlist_t *config,
nvlist_free(nvconfig);
/*
- * Now that we've validate the config, check the state of the
+ * Now that we've validated the config, check the state of the
* root vdev. If it can't be opened, it indicates one or
* more toplevel vdevs are faulted.
*/
@@ -2238,6 +2460,17 @@ spa_load_impl(spa_t *spa, uint64_t pool_guid, nvlist_t *config,
}
}
+ if (missing_feat_write) {
+ ASSERT(state == SPA_LOAD_TRYIMPORT);
+
+ /*
+ * At this point, we know that we can open the pool in
+ * read-only mode but not read-write mode. We now have enough
+ * information and can return to userland.
+ */
+ return (spa_vdev_err(rvd, VDEV_AUX_UNSUP_FEAT, ENOTSUP));
+ }
+
/*
* We've successfully opened the pool, verify that we're ready
* to start pushing transactions.
@@ -2317,6 +2550,12 @@ spa_load_impl(spa_t *spa, uint64_t pool_guid, nvlist_t *config,
spa_async_request(spa, SPA_ASYNC_RESILVER);
/*
+ * Log the fact that we booted up (so that we can detect if
+ * we rebooted in the middle of an operation).
+ */
+ spa_history_log_version(spa, "open");
+
+ /*
* Delete any inconsistent datasets.
*/
(void) dmu_objset_find(spa_name(spa),
@@ -2347,10 +2586,18 @@ spa_load_retry(spa_t *spa, spa_load_state_t state, int mosconfig)
return (spa_load(spa, state, SPA_IMPORT_EXISTING, mosconfig));
}
+/*
+ * If spa_load() fails this function will try loading prior txg's. If
+ * 'state' is SPA_LOAD_RECOVER and one of these loads succeeds the pool
+ * will be rewound to that txg. If 'state' is not SPA_LOAD_RECOVER this
+ * function will not rewind the pool and will return the same error as
+ * spa_load().
+ */
static int
spa_load_best(spa_t *spa, spa_load_state_t state, int mosconfig,
uint64_t max_request, int rewind_flags)
{
+ nvlist_t *loadinfo = NULL;
nvlist_t *config = NULL;
int load_error, rewind_error;
uint64_t safe_rewind_txg;
@@ -2379,9 +2626,18 @@ spa_load_best(spa_t *spa, spa_load_state_t state, int mosconfig,
return (load_error);
}
- /* Price of rolling back is discarding txgs, including log */
- if (state == SPA_LOAD_RECOVER)
+ if (state == SPA_LOAD_RECOVER) {
+ /* Price of rolling back is discarding txgs, including log */
spa_set_log_state(spa, SPA_LOG_CLEAR);
+ } else {
+ /*
+ * If we aren't rolling back save the load info from our first
+ * import attempt so that we can restore it after attempting
+ * to rewind.
+ */
+ loadinfo = spa->spa_load_info;
+ spa->spa_load_info = fnvlist_alloc();
+ }
spa->spa_load_max_txg = spa->spa_last_ubsync_txg;
safe_rewind_txg = spa->spa_last_ubsync_txg - TXG_DEFER_SIZE;
@@ -2405,7 +2661,20 @@ spa_load_best(spa_t *spa, spa_load_state_t state, int mosconfig,
if (config && (rewind_error || state != SPA_LOAD_RECOVER))
spa_config_set(spa, config);
- return (state == SPA_LOAD_RECOVER ? rewind_error : load_error);
+ if (state == SPA_LOAD_RECOVER) {
+ ASSERT3P(loadinfo, ==, NULL);
+ return (rewind_error);
+ } else {
+ /* Store the rewind info as part of the initial load info */
+ fnvlist_add_nvlist(loadinfo, ZPOOL_CONFIG_REWIND_INFO,
+ spa->spa_load_info);
+
+ /* Restore the initial load info */
+ fnvlist_free(spa->spa_load_info);
+ spa->spa_load_info = loadinfo;
+
+ return (load_error);
+ }
}
/*
@@ -2675,8 +2944,50 @@ spa_add_l2cache(spa_t *spa, nvlist_t *config)
}
}
+static void
+spa_add_feature_stats(spa_t *spa, nvlist_t *config)
+{
+ nvlist_t *features;
+ zap_cursor_t zc;
+ zap_attribute_t za;
+
+ ASSERT(spa_config_held(spa, SCL_CONFIG, RW_READER));
+ VERIFY(nvlist_alloc(&features, NV_UNIQUE_NAME, KM_SLEEP) == 0);
+
+ if (spa->spa_feat_for_read_obj != 0) {
+ for (zap_cursor_init(&zc, spa->spa_meta_objset,
+ spa->spa_feat_for_read_obj);
+ zap_cursor_retrieve(&zc, &za) == 0;
+ zap_cursor_advance(&zc)) {
+ ASSERT(za.za_integer_length == sizeof (uint64_t) &&
+ za.za_num_integers == 1);
+ VERIFY3U(0, ==, nvlist_add_uint64(features, za.za_name,
+ za.za_first_integer));
+ }
+ zap_cursor_fini(&zc);
+ }
+
+ if (spa->spa_feat_for_write_obj != 0) {
+ for (zap_cursor_init(&zc, spa->spa_meta_objset,
+ spa->spa_feat_for_write_obj);
+ zap_cursor_retrieve(&zc, &za) == 0;
+ zap_cursor_advance(&zc)) {
+ ASSERT(za.za_integer_length == sizeof (uint64_t) &&
+ za.za_num_integers == 1);
+ VERIFY3U(0, ==, nvlist_add_uint64(features, za.za_name,
+ za.za_first_integer));
+ }
+ zap_cursor_fini(&zc);
+ }
+
+ VERIFY(nvlist_add_nvlist(config, ZPOOL_CONFIG_FEATURE_STATS,
+ features) == 0);
+ nvlist_free(features);
+}
+
int
-spa_get_stats(const char *name, nvlist_t **config, char *altroot, size_t buflen)
+spa_get_stats(const char *name, nvlist_t **config,
+ char *altroot, size_t buflen)
{
int error;
spa_t *spa;
@@ -2711,6 +3022,7 @@ spa_get_stats(const char *name, nvlist_t **config, char *altroot, size_t buflen)
spa_add_spares(spa, *config);
spa_add_l2cache(spa, *config);
+ spa_add_feature_stats(spa, *config);
}
}
@@ -2919,7 +3231,7 @@ spa_l2cache_drop(spa_t *spa)
*/
int
spa_create(const char *pool, nvlist_t *nvroot, nvlist_t *props,
- const char *history_str, nvlist_t *zplprops)
+ nvlist_t *zplprops)
{
spa_t *spa;
char *altroot = NULL;
@@ -2931,6 +3243,7 @@ spa_create(const char *pool, nvlist_t *nvroot, nvlist_t *props,
nvlist_t **spares, **l2cache;
uint_t nspares, nl2cache;
uint64_t version, obj;
+ boolean_t has_features;
/*
* If this pool already exists, return failure.
@@ -2956,10 +3269,18 @@ spa_create(const char *pool, nvlist_t *nvroot, nvlist_t *props,
return (error);
}
- if (nvlist_lookup_uint64(props, zpool_prop_to_name(ZPOOL_PROP_VERSION),
- &version) != 0)
+ has_features = B_FALSE;
+ for (nvpair_t *elem = nvlist_next_nvpair(props, NULL);
+ elem != NULL; elem = nvlist_next_nvpair(props, elem)) {
+ if (zpool_prop_feature(nvpair_name(elem)))
+ has_features = B_TRUE;
+ }
+
+ if (has_features || nvlist_lookup_uint64(props,
+ zpool_prop_to_name(ZPOOL_PROP_VERSION), &version) != 0) {
version = SPA_VERSION;
- ASSERT(version <= SPA_VERSION);
+ }
+ ASSERT(SPA_VERSION_IS_SUPPORTED(version));
spa->spa_first_txg = txg;
spa->spa_uberblock.ub_txg = txg - 1;
@@ -3035,8 +3356,10 @@ spa_create(const char *pool, nvlist_t *nvroot, nvlist_t *props,
spa->spa_l2cache.sav_sync = B_TRUE;
}
+ spa->spa_is_initializing = B_TRUE;
spa->spa_dsl_pool = dp = dsl_pool_create(spa, zplprops, txg);
spa->spa_meta_objset = dp->dp_meta_objset;
+ spa->spa_is_initializing = B_FALSE;
/*
* Create DDTs (dedup tables).
@@ -3060,6 +3383,9 @@ spa_create(const char *pool, nvlist_t *nvroot, nvlist_t *props,
cmn_err(CE_PANIC, "failed to add pool config");
}
+ if (spa_version(spa) >= SPA_VERSION_FEATURES)
+ spa_feature_create_zap_objects(spa, tx);
+
if (zap_add(spa->spa_meta_objset,
DMU_POOL_DIRECTORY_OBJECT, DMU_POOL_CREATION_VERSION,
sizeof (uint64_t), 1, &version, tx) != 0) {
@@ -3124,9 +3450,7 @@ spa_create(const char *pool, nvlist_t *nvroot, nvlist_t *props,
spa_config_sync(spa, B_FALSE, B_TRUE);
- if (version >= SPA_VERSION_ZPOOL_HISTORY && history_str != NULL)
- (void) spa_history_log(spa, history_str, LOG_CMD_POOL_CREATE);
- spa_history_log_version(spa, LOG_POOL_CREATE);
+ spa_history_log_version(spa, "create");
spa->spa_minref = refcount_count(&spa->spa_refcount);
@@ -3250,7 +3574,7 @@ spa_import_rootpool(char *devpath, char *devid)
}
#endif
if (config == NULL) {
- cmn_err(CE_NOTE, "Can not read the pool label from '%s'",
+ cmn_err(CE_NOTE, "Cannot read the pool label from '%s'",
devpath);
return (EIO);
}
@@ -3326,7 +3650,6 @@ spa_import_rootpool(char *devpath, char *devid)
}
error = 0;
- spa_history_log_version(spa, LOG_POOL_IMPORT);
out:
spa_config_enter(spa, SCL_ALL, FTAG, RW_WRITER);
vdev_free(rvd);
@@ -3388,7 +3711,7 @@ spa_import(const char *pool, nvlist_t *config, nvlist_t *props, uint64_t flags)
spa_config_sync(spa, B_FALSE, B_TRUE);
mutex_exit(&spa_namespace_lock);
- spa_history_log_version(spa, LOG_POOL_IMPORT);
+ spa_history_log_version(spa, "import");
return (0);
}
@@ -3519,7 +3842,7 @@ spa_import(const char *pool, nvlist_t *config, nvlist_t *props, uint64_t flags)
spa_async_request(spa, SPA_ASYNC_AUTOEXPAND);
mutex_exit(&spa_namespace_lock);
- spa_history_log_version(spa, LOG_POOL_IMPORT);
+ spa_history_log_version(spa, "import");
return (0);
}
@@ -3564,6 +3887,8 @@ spa_tryimport(nvlist_t *tryconfig)
state) == 0);
VERIFY(nvlist_add_uint64(config, ZPOOL_CONFIG_TIMESTAMP,
spa->spa_uberblock.ub_timestamp) == 0);
+ VERIFY(nvlist_add_nvlist(config, ZPOOL_CONFIG_LOAD_INFO,
+ spa->spa_load_info) == 0);
/*
* If the bootfs property exists on this pool then we
@@ -4055,7 +4380,7 @@ spa_vdev_attach(spa_t *spa, uint64_t guid, nvlist_t *nvroot, int replacing)
*/
(void) spa_vdev_exit(spa, newrootvd, dtl_max_txg, 0);
- spa_history_log_internal(LOG_POOL_VDEV_ATTACH, spa, NULL,
+ spa_history_log_internal(spa, "vdev attach", NULL,
"%s vdev=%s %s vdev=%s",
replacing && newvd_isspare ? "spare in" :
replacing ? "replace" : "attach", newvdpath,
@@ -4272,7 +4597,7 @@ spa_vdev_detach(spa_t *spa, uint64_t guid, uint64_t pguid, int replace_done)
error = spa_vdev_exit(spa, vd, txg, 0);
- spa_history_log_internal(LOG_POOL_VDEV_DETACH, spa, NULL,
+ spa_history_log_internal(spa, "detach", NULL,
"vdev=%s", vdpath);
spa_strfree(vdpath);
@@ -4541,9 +4866,8 @@ spa_vdev_split_mirror(spa_t *spa, char *newname, nvlist_t *config,
if (vml[c] != NULL) {
vdev_split(vml[c]);
if (error == 0)
- spa_history_log_internal(LOG_POOL_VDEV_DETACH,
- spa, tx, "vdev=%s",
- vml[c]->vdev_path);
+ spa_history_log_internal(spa, "detach", tx,
+ "vdev=%s", vml[c]->vdev_path);
vdev_free(vml[c]);
}
}
@@ -4558,8 +4882,8 @@ spa_vdev_split_mirror(spa_t *spa, char *newname, nvlist_t *config,
zio_handle_panic_injection(spa, FTAG, 3);
/* split is complete; log a history record */
- spa_history_log_internal(LOG_POOL_SPLIT, newspa, NULL,
- "split new pool %s from pool %s", newname, spa_name(spa));
+ spa_history_log_internal(newspa, "split", NULL,
+ "from pool %s", spa_name(spa));
kmem_free(vml, children * sizeof (vdev_t *));
@@ -5145,8 +5469,7 @@ spa_async_thread(spa_t *spa)
* then log an internal history event.
*/
if (new_space != old_space) {
- spa_history_log_internal(LOG_POOL_VDEV_ONLINE,
- spa, NULL,
+ spa_history_log_internal(spa, "vdev online", NULL,
"pool '%s' size: %llu(+%llu)",
spa_name(spa), new_space, new_space - old_space);
}
@@ -5281,7 +5604,7 @@ spa_sync_nvlist(spa_t *spa, uint64_t obj, nvlist_t *nv, dmu_tx_t *tx)
* information. This avoids the dbuf_will_dirty() path and
* saves us a pre-read to get data we don't actually care about.
*/
- bufsize = P2ROUNDUP(nvsize, SPA_CONFIG_BLOCKSIZE);
+ bufsize = P2ROUNDUP((uint64_t)nvsize, SPA_CONFIG_BLOCKSIZE);
packed = kmem_alloc(bufsize, KM_SLEEP);
VERIFY(nvlist_pack(nv, &packed, &nvsize, NV_ENCODE_XDR,
@@ -5366,6 +5689,25 @@ spa_sync_config_object(spa_t *spa, dmu_tx_t *tx)
spa_sync_nvlist(spa, spa->spa_config_object, config, tx);
}
+static void
+spa_sync_version(void *arg1, void *arg2, dmu_tx_t *tx)
+{
+ spa_t *spa = arg1;
+ uint64_t version = *(uint64_t *)arg2;
+
+ /*
+ * Setting the version is special cased when first creating the pool.
+ */
+ ASSERT(tx->tx_txg != TXG_INITIAL);
+
+ ASSERT(version <= SPA_VERSION);
+ ASSERT(version >= spa_version(spa));
+
+ spa->spa_uberblock.ub_version = version;
+ vdev_config_dirty(spa->spa_root_vdev);
+ spa_history_log_internal(spa, "set", tx, "version=%lld", version);
+}
+
/*
* Set zpool properties.
*/
@@ -5375,32 +5717,40 @@ spa_sync_props(void *arg1, void *arg2, dmu_tx_t *tx)
spa_t *spa = arg1;
objset_t *mos = spa->spa_meta_objset;
nvlist_t *nvp = arg2;
- nvpair_t *elem;
- uint64_t intval;
- char *strval;
- zpool_prop_t prop;
- const char *propname;
- zprop_type_t proptype;
+ nvpair_t *elem = NULL;
mutex_enter(&spa->spa_props_lock);
- elem = NULL;
while ((elem = nvlist_next_nvpair(nvp, elem))) {
+ uint64_t intval;
+ char *strval, *fname;
+ zpool_prop_t prop;
+ const char *propname;
+ zprop_type_t proptype;
+ zfeature_info_t *feature;
+
switch (prop = zpool_name_to_prop(nvpair_name(elem))) {
+ case ZPROP_INVAL:
+ /*
+ * We checked this earlier in spa_prop_validate().
+ */
+ ASSERT(zpool_prop_feature(nvpair_name(elem)));
+
+ fname = strchr(nvpair_name(elem), '@') + 1;
+ VERIFY3U(0, ==, zfeature_lookup_name(fname, &feature));
+
+ spa_feature_enable(spa, feature, tx);
+ spa_history_log_internal(spa, "set", tx,
+ "%s=enabled", nvpair_name(elem));
+ break;
+
case ZPOOL_PROP_VERSION:
+ VERIFY(nvpair_value_uint64(elem, &intval) == 0);
/*
- * Only set version for non-zpool-creation cases
- * (set/import). spa_create() needs special care
- * for version setting.
+ * The version is synced seperatly before other
+ * properties and should be correct by now.
*/
- if (tx->tx_txg != TXG_INITIAL) {
- VERIFY(nvpair_value_uint64(elem,
- &intval) == 0);
- ASSERT(intval <= SPA_VERSION);
- ASSERT(intval >= spa_version(spa));
- spa->spa_uberblock.ub_version = intval;
- vdev_config_dirty(spa->spa_root_vdev);
- }
+ ASSERT3U(spa_version(spa), >=, intval);
break;
case ZPOOL_PROP_ALTROOT:
@@ -5431,20 +5781,18 @@ spa_sync_props(void *arg1, void *arg2, dmu_tx_t *tx)
*/
if (tx->tx_txg != TXG_INITIAL)
vdev_config_dirty(spa->spa_root_vdev);
+ spa_history_log_internal(spa, "set", tx,
+ "%s=%s", nvpair_name(elem), strval);
break;
default:
/*
* Set pool property values in the poolprops mos object.
*/
if (spa->spa_pool_props_object == 0) {
- VERIFY((spa->spa_pool_props_object =
- zap_create(mos, DMU_OT_POOL_PROPS,
- DMU_OT_NONE, 0, tx)) > 0);
-
- VERIFY(zap_update(mos,
+ spa->spa_pool_props_object =
+ zap_create_link(mos, DMU_OT_POOL_PROPS,
DMU_POOL_DIRECTORY_OBJECT, DMU_POOL_PROPS,
- 8, 1, &spa->spa_pool_props_object, tx)
- == 0);
+ tx);
}
/* normalize the property name */
@@ -5457,7 +5805,8 @@ spa_sync_props(void *arg1, void *arg2, dmu_tx_t *tx)
VERIFY(zap_update(mos,
spa->spa_pool_props_object, propname,
1, strlen(strval) + 1, strval, tx) == 0);
-
+ spa_history_log_internal(spa, "set", tx,
+ "%s=%s", nvpair_name(elem), strval);
} else if (nvpair_type(elem) == DATA_TYPE_UINT64) {
VERIFY(nvpair_value_uint64(elem, &intval) == 0);
@@ -5469,6 +5818,8 @@ spa_sync_props(void *arg1, void *arg2, dmu_tx_t *tx)
VERIFY(zap_update(mos,
spa->spa_pool_props_object, propname,
8, 1, &intval, tx) == 0);
+ spa_history_log_internal(spa, "set", tx,
+ "%s=%lld", nvpair_name(elem), intval);
} else {
ASSERT(0); /* not allowed */
}
@@ -5497,13 +5848,6 @@ spa_sync_props(void *arg1, void *arg2, dmu_tx_t *tx)
}
}
- /* log internal history if this is not a zpool create */
- if (spa_version(spa) >= SPA_VERSION_ZPOOL_HISTORY &&
- tx->tx_txg != TXG_INITIAL) {
- spa_history_log_internal(LOG_POOL_PROPSET,
- spa, tx, "%s %lld %s",
- nvpair_name(elem), intval, spa_name(spa));
- }
}
mutex_exit(&spa->spa_props_lock);
@@ -5543,6 +5887,11 @@ spa_sync_upgrades(spa_t *spa, dmu_tx_t *tx)
/* Keeping the freedir open increases spa_minref */
spa->spa_minref += 3;
}
+
+ if (spa->spa_ubsync.ub_version < SPA_VERSION_FEATURES &&
+ spa->spa_uberblock.ub_version >= SPA_VERSION_FEATURES) {
+ spa_feature_create_zap_objects(spa, tx);
+ }
}
/*
diff --git a/usr/src/uts/common/fs/zfs/spa_config.c b/usr/src/uts/common/fs/zfs/spa_config.c
index 8ca195d244..366545035d 100644
--- a/usr/src/uts/common/fs/zfs/spa_config.c
+++ b/usr/src/uts/common/fs/zfs/spa_config.c
@@ -22,7 +22,7 @@
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright 2011 Nexenta Systems, Inc. All rights reserved.
- * Copyright (c) 2011 by Delphix. All rights reserved.
+ * Copyright (c) 2012 by Delphix. All rights reserved.
*/
#include <sys/spa.h>
@@ -35,6 +35,7 @@
#include <sys/utsname.h>
#include <sys/systeminfo.h>
#include <sys/sunddi.h>
+#include <sys/zfeature.h>
#ifdef _KERNEL
#include <sys/kobj.h>
#include <sys/zone.h>
@@ -409,6 +410,12 @@ spa_config_generate(spa_t *spa, vdev_t *vd, uint64_t txg, int getstats)
VERIFY(nvlist_add_nvlist(config, ZPOOL_CONFIG_VDEV_TREE, nvroot) == 0);
nvlist_free(nvroot);
+ /*
+ * Store what's necessary for reading the MOS in the label.
+ */
+ VERIFY(nvlist_add_nvlist(config, ZPOOL_CONFIG_FEATURES_FOR_READ,
+ spa->spa_label_features) == 0);
+
if (getstats && spa_load_state(spa) == SPA_LOAD_NONE) {
ddt_histogram_t *ddh;
ddt_stat_t *dds;
diff --git a/usr/src/uts/common/fs/zfs/spa_history.c b/usr/src/uts/common/fs/zfs/spa_history.c
index 6df8411349..f2c32f548b 100644
--- a/usr/src/uts/common/fs/zfs/spa_history.c
+++ b/usr/src/uts/common/fs/zfs/spa_history.c
@@ -21,7 +21,7 @@
/*
* Copyright (c) 2006, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2011 by Delphix. All rights reserved.
+ * Copyright (c) 2012 by Delphix. All rights reserved.
*/
#include <sys/spa.h>
@@ -30,9 +30,12 @@
#include <sys/dsl_synctask.h>
#include <sys/dmu_tx.h>
#include <sys/dmu_objset.h>
+#include <sys/dsl_dataset.h>
+#include <sys/dsl_dir.h>
#include <sys/utsname.h>
#include <sys/cmn_err.h>
#include <sys/sunddi.h>
+#include <sys/cred.h>
#include "zfs_comutil.h"
#ifdef _KERNEL
#include <sys/zone.h>
@@ -176,12 +179,14 @@ spa_history_write(spa_t *spa, void *buf, uint64_t len, spa_history_phys_t *shpp,
}
static char *
-spa_history_zone()
+spa_history_zone(void)
{
#ifdef _KERNEL
+ if (INGLOBALZONE(curproc))
+ return (NULL);
return (curproc->p_zone->zone_name);
#else
- return ("global");
+ return (NULL);
#endif
}
@@ -193,14 +198,12 @@ static void
spa_history_log_sync(void *arg1, void *arg2, dmu_tx_t *tx)
{
spa_t *spa = arg1;
- history_arg_t *hap = arg2;
- const char *history_str = hap->ha_history_str;
+ nvlist_t *nvl = arg2;
objset_t *mos = spa->spa_meta_objset;
dmu_buf_t *dbp;
spa_history_phys_t *shpp;
size_t reclen;
uint64_t le_len;
- nvlist_t *nvrecord;
char *record_packed = NULL;
int ret;
@@ -230,46 +233,35 @@ spa_history_log_sync(void *arg1, void *arg2, dmu_tx_t *tx)
}
#endif
- VERIFY(nvlist_alloc(&nvrecord, NV_UNIQUE_NAME, KM_SLEEP) == 0);
- VERIFY(nvlist_add_uint64(nvrecord, ZPOOL_HIST_TIME,
- gethrestime_sec()) == 0);
- VERIFY(nvlist_add_uint64(nvrecord, ZPOOL_HIST_WHO, hap->ha_uid) == 0);
- if (hap->ha_zone != NULL)
- VERIFY(nvlist_add_string(nvrecord, ZPOOL_HIST_ZONE,
- hap->ha_zone) == 0);
+ fnvlist_add_uint64(nvl, ZPOOL_HIST_TIME, gethrestime_sec());
#ifdef _KERNEL
- VERIFY(nvlist_add_string(nvrecord, ZPOOL_HIST_HOST,
- utsname.nodename) == 0);
+ fnvlist_add_string(nvl, ZPOOL_HIST_HOST, utsname.nodename);
#endif
- if (hap->ha_log_type == LOG_CMD_POOL_CREATE ||
- hap->ha_log_type == LOG_CMD_NORMAL) {
- VERIFY(nvlist_add_string(nvrecord, ZPOOL_HIST_CMD,
- history_str) == 0);
-
- zfs_dbgmsg("command: %s", history_str);
- } else {
- VERIFY(nvlist_add_uint64(nvrecord, ZPOOL_HIST_INT_EVENT,
- hap->ha_event) == 0);
- VERIFY(nvlist_add_uint64(nvrecord, ZPOOL_HIST_TXG,
- tx->tx_txg) == 0);
- VERIFY(nvlist_add_string(nvrecord, ZPOOL_HIST_INT_STR,
- history_str) == 0);
-
- zfs_dbgmsg("internal %s pool:%s txg:%llu %s",
- zfs_history_event_names[hap->ha_event], spa_name(spa),
- (longlong_t)tx->tx_txg, history_str);
-
+ if (nvlist_exists(nvl, ZPOOL_HIST_CMD)) {
+ zfs_dbgmsg("command: %s",
+ fnvlist_lookup_string(nvl, ZPOOL_HIST_CMD));
+ } else if (nvlist_exists(nvl, ZPOOL_HIST_INT_NAME)) {
+ if (nvlist_exists(nvl, ZPOOL_HIST_DSNAME)) {
+ zfs_dbgmsg("txg %lld %s %s (id %llu) %s",
+ fnvlist_lookup_uint64(nvl, ZPOOL_HIST_TXG),
+ fnvlist_lookup_string(nvl, ZPOOL_HIST_INT_NAME),
+ fnvlist_lookup_string(nvl, ZPOOL_HIST_DSNAME),
+ fnvlist_lookup_uint64(nvl, ZPOOL_HIST_DSID),
+ fnvlist_lookup_string(nvl, ZPOOL_HIST_INT_STR));
+ } else {
+ zfs_dbgmsg("txg %lld %s %s",
+ fnvlist_lookup_uint64(nvl, ZPOOL_HIST_TXG),
+ fnvlist_lookup_string(nvl, ZPOOL_HIST_INT_NAME),
+ fnvlist_lookup_string(nvl, ZPOOL_HIST_INT_STR));
+ }
+ } else if (nvlist_exists(nvl, ZPOOL_HIST_IOCTL)) {
+ zfs_dbgmsg("ioctl %s",
+ fnvlist_lookup_string(nvl, ZPOOL_HIST_IOCTL));
}
- VERIFY(nvlist_size(nvrecord, &reclen, NV_ENCODE_XDR) == 0);
- record_packed = kmem_alloc(reclen, KM_SLEEP);
-
- VERIFY(nvlist_pack(nvrecord, &record_packed, &reclen,
- NV_ENCODE_XDR, KM_SLEEP) == 0);
+ record_packed = fnvlist_pack(nvl, &reclen);
mutex_enter(&spa->spa_history_lock);
- if (hap->ha_log_type == LOG_CMD_POOL_CREATE)
- VERIFY(shpp->sh_eof == shpp->sh_pool_create_len);
/* write out the packed length as little endian */
le_len = LE_64((uint64_t)reclen);
@@ -277,33 +269,42 @@ spa_history_log_sync(void *arg1, void *arg2, dmu_tx_t *tx)
if (!ret)
ret = spa_history_write(spa, record_packed, reclen, shpp, tx);
- if (!ret && hap->ha_log_type == LOG_CMD_POOL_CREATE) {
- shpp->sh_pool_create_len += sizeof (le_len) + reclen;
- shpp->sh_bof = shpp->sh_pool_create_len;
+ /* The first command is the create, which we keep forever */
+ if (ret == 0 && shpp->sh_pool_create_len == 0 &&
+ nvlist_exists(nvl, ZPOOL_HIST_CMD)) {
+ shpp->sh_pool_create_len = shpp->sh_bof = shpp->sh_eof;
}
mutex_exit(&spa->spa_history_lock);
- nvlist_free(nvrecord);
- kmem_free(record_packed, reclen);
+ fnvlist_pack_free(record_packed, reclen);
dmu_buf_rele(dbp, FTAG);
-
- strfree(hap->ha_history_str);
- if (hap->ha_zone != NULL)
- strfree(hap->ha_zone);
- kmem_free(hap, sizeof (history_arg_t));
+ fnvlist_free(nvl);
}
/*
* Write out a history event.
*/
int
-spa_history_log(spa_t *spa, const char *history_str, history_log_type_t what)
+spa_history_log(spa_t *spa, const char *msg)
+{
+ int err;
+ nvlist_t *nvl = fnvlist_alloc();
+
+ fnvlist_add_string(nvl, ZPOOL_HIST_CMD, msg);
+ err = spa_history_log_nvl(spa, nvl);
+ fnvlist_free(nvl);
+ return (err);
+}
+
+int
+spa_history_log_nvl(spa_t *spa, nvlist_t *nvl)
{
- history_arg_t *ha;
int err = 0;
dmu_tx_t *tx;
+ nvlist_t *nvarg;
- ASSERT(what != LOG_INTERNAL);
+ if (spa_version(spa) < SPA_VERSION_ZPOOL_HISTORY)
+ return (EINVAL);
tx = dmu_tx_create_dd(spa_get_dsl(spa)->dp_mos_dir);
err = dmu_tx_assign(tx, TXG_WAIT);
@@ -312,19 +313,21 @@ spa_history_log(spa_t *spa, const char *history_str, history_log_type_t what)
return (err);
}
- ha = kmem_alloc(sizeof (history_arg_t), KM_SLEEP);
- ha->ha_history_str = strdup(history_str);
- ha->ha_zone = strdup(spa_history_zone());
- ha->ha_log_type = what;
- ha->ha_uid = crgetuid(CRED());
+ nvarg = fnvlist_dup(nvl);
+ if (spa_history_zone() != NULL) {
+ fnvlist_add_string(nvarg, ZPOOL_HIST_ZONE,
+ spa_history_zone());
+ }
+ fnvlist_add_uint64(nvarg, ZPOOL_HIST_WHO, crgetruid(CRED()));
/* Kick this off asynchronously; errors are ignored. */
dsl_sync_task_do_nowait(spa_get_dsl(spa), NULL,
- spa_history_log_sync, spa, ha, 0, tx);
+ spa_history_log_sync, spa, nvarg, 0, tx);
dmu_tx_commit(tx);
- /* spa_history_log_sync will free ha and strings */
+ /* spa_history_log_sync will free nvl */
return (err);
+
}
/*
@@ -341,7 +344,7 @@ spa_history_get(spa_t *spa, uint64_t *offp, uint64_t *len, char *buf)
int err;
/*
- * If the command history doesn't exist (older pool),
+ * If the command history doesn't exist (older pool),
* that's ok, just return ENOENT.
*/
if (!spa->spa_history)
@@ -424,11 +427,14 @@ spa_history_get(spa_t *spa, uint64_t *offp, uint64_t *len, char *buf)
return (err);
}
+/*
+ * The nvlist will be consumed by this call.
+ */
static void
-log_internal(history_internal_events_t event, spa_t *spa,
+log_internal(nvlist_t *nvl, const char *operation, spa_t *spa,
dmu_tx_t *tx, const char *fmt, va_list adx)
{
- history_arg_t *ha;
+ char *msg;
/*
* If this is part of creating a pool, not everything is
@@ -437,28 +443,25 @@ log_internal(history_internal_events_t event, spa_t *spa,
if (tx->tx_txg == TXG_INITIAL)
return;
- ha = kmem_alloc(sizeof (history_arg_t), KM_SLEEP);
- ha->ha_history_str = kmem_alloc(vsnprintf(NULL, 0, fmt, adx) + 1,
- KM_SLEEP);
-
- (void) vsprintf(ha->ha_history_str, fmt, adx);
+ msg = kmem_alloc(vsnprintf(NULL, 0, fmt, adx) + 1, KM_SLEEP);
+ (void) vsprintf(msg, fmt, adx);
+ fnvlist_add_string(nvl, ZPOOL_HIST_INT_STR, msg);
+ strfree(msg);
- ha->ha_log_type = LOG_INTERNAL;
- ha->ha_event = event;
- ha->ha_zone = NULL;
- ha->ha_uid = 0;
+ fnvlist_add_string(nvl, ZPOOL_HIST_INT_NAME, operation);
+ fnvlist_add_uint64(nvl, ZPOOL_HIST_TXG, tx->tx_txg);
if (dmu_tx_is_syncing(tx)) {
- spa_history_log_sync(spa, ha, tx);
+ spa_history_log_sync(spa, nvl, tx);
} else {
dsl_sync_task_do_nowait(spa_get_dsl(spa), NULL,
- spa_history_log_sync, spa, ha, 0, tx);
+ spa_history_log_sync, spa, nvl, 0, tx);
}
- /* spa_history_log_sync() will free ha and strings */
+ /* spa_history_log_sync() will free nvl */
}
void
-spa_history_log_internal(history_internal_events_t event, spa_t *spa,
+spa_history_log_internal(spa_t *spa, const char *operation,
dmu_tx_t *tx, const char *fmt, ...)
{
dmu_tx_t *htx = tx;
@@ -474,7 +477,7 @@ spa_history_log_internal(history_internal_events_t event, spa_t *spa,
}
va_start(adx, fmt);
- log_internal(event, spa, htx, fmt, adx);
+ log_internal(fnvlist_alloc(), operation, spa, htx, fmt, adx);
va_end(adx);
/* if we didn't get a tx from the caller, commit the one we made */
@@ -483,21 +486,56 @@ spa_history_log_internal(history_internal_events_t event, spa_t *spa,
}
void
-spa_history_log_version(spa_t *spa, history_internal_events_t event)
+spa_history_log_internal_ds(dsl_dataset_t *ds, const char *operation,
+ dmu_tx_t *tx, const char *fmt, ...)
+{
+ va_list adx;
+ char namebuf[MAXNAMELEN];
+ nvlist_t *nvl = fnvlist_alloc();
+
+ ASSERT(tx != NULL);
+
+ dsl_dataset_name(ds, namebuf);
+ fnvlist_add_string(nvl, ZPOOL_HIST_DSNAME, namebuf);
+ fnvlist_add_uint64(nvl, ZPOOL_HIST_DSID, ds->ds_object);
+
+ va_start(adx, fmt);
+ log_internal(nvl, operation, dsl_dataset_get_spa(ds), tx, fmt, adx);
+ va_end(adx);
+}
+
+void
+spa_history_log_internal_dd(dsl_dir_t *dd, const char *operation,
+ dmu_tx_t *tx, const char *fmt, ...)
+{
+ va_list adx;
+ char namebuf[MAXNAMELEN];
+ nvlist_t *nvl = fnvlist_alloc();
+
+ ASSERT(tx != NULL);
+
+ dsl_dir_name(dd, namebuf);
+ fnvlist_add_string(nvl, ZPOOL_HIST_DSNAME, namebuf);
+ fnvlist_add_uint64(nvl, ZPOOL_HIST_DSID,
+ dd->dd_phys->dd_head_dataset_obj);
+
+ va_start(adx, fmt);
+ log_internal(nvl, operation, dd->dd_pool->dp_spa, tx, fmt, adx);
+ va_end(adx);
+}
+
+void
+spa_history_log_version(spa_t *spa, const char *operation)
{
#ifdef _KERNEL
uint64_t current_vers = spa_version(spa);
- if (current_vers >= SPA_VERSION_ZPOOL_HISTORY) {
- spa_history_log_internal(event, spa, NULL,
- "pool spa %llu; zfs spa %llu; zpl %d; uts %s %s %s %s",
- (u_longlong_t)current_vers, SPA_VERSION, ZPL_VERSION,
- utsname.nodename, utsname.release, utsname.version,
- utsname.machine);
- }
- cmn_err(CE_CONT, "!%s version %llu pool %s using %llu",
- event == LOG_POOL_IMPORT ? "imported" :
- event == LOG_POOL_CREATE ? "created" : "accessed",
+ spa_history_log_internal(spa, operation, NULL,
+ "pool version %llu; software version %llu/%d; uts %s %s %s %s",
+ (u_longlong_t)current_vers, SPA_VERSION, ZPL_VERSION,
+ utsname.nodename, utsname.release, utsname.version,
+ utsname.machine);
+ cmn_err(CE_CONT, "!%s version %llu pool %s using %llu", operation,
(u_longlong_t)current_vers, spa_name(spa), SPA_VERSION);
#endif
}
diff --git a/usr/src/uts/common/fs/zfs/spa_misc.c b/usr/src/uts/common/fs/zfs/spa_misc.c
index cc77f1bc18..9400194a93 100644
--- a/usr/src/uts/common/fs/zfs/spa_misc.c
+++ b/usr/src/uts/common/fs/zfs/spa_misc.c
@@ -20,7 +20,7 @@
*/
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2011 by Delphix. All rights reserved.
+ * Copyright (c) 2012 by Delphix. All rights reserved.
* Copyright 2011 Nexenta Systems, Inc. All rights reserved.
*/
@@ -48,6 +48,7 @@
#include <sys/arc.h>
#include <sys/ddt.h>
#include "zfs_prop.h"
+#include "zfeature_common.h"
/*
* SPA locking
@@ -216,7 +217,7 @@
* Like spa_vdev_enter/exit, these are convenience wrappers -- the actual
* locking is, always, based on spa_namespace_lock and spa_config_lock[].
*
- * spa_rename() is also implemented within this file since is requires
+ * spa_rename() is also implemented within this file since it requires
* manipulation of the namespace.
*/
@@ -483,8 +484,22 @@ spa_add(const char *name, nvlist_t *config, const char *altroot)
VERIFY(nvlist_alloc(&spa->spa_load_info, NV_UNIQUE_NAME,
KM_SLEEP) == 0);
- if (config != NULL)
+ if (config != NULL) {
+ nvlist_t *features;
+
+ if (nvlist_lookup_nvlist(config, ZPOOL_CONFIG_FEATURES_FOR_READ,
+ &features) == 0) {
+ VERIFY(nvlist_dup(features, &spa->spa_label_features,
+ 0) == 0);
+ }
+
VERIFY(nvlist_dup(config, &spa->spa_config, 0) == 0);
+ }
+
+ if (spa->spa_label_features == NULL) {
+ VERIFY(nvlist_alloc(&spa->spa_label_features, NV_UNIQUE_NAME,
+ KM_SLEEP) == 0);
+ }
return (spa);
}
@@ -521,6 +536,7 @@ spa_remove(spa_t *spa)
list_destroy(&spa->spa_config_list);
+ nvlist_free(spa->spa_label_features);
nvlist_free(spa->spa_load_info);
spa_config_set(spa, NULL);
@@ -1029,6 +1045,20 @@ spa_vdev_state_exit(spa_t *spa, vdev_t *vd, int error)
* ==========================================================================
*/
+void
+spa_activate_mos_feature(spa_t *spa, const char *feature)
+{
+ (void) nvlist_add_boolean(spa->spa_label_features, feature);
+ vdev_config_dirty(spa->spa_root_vdev);
+}
+
+void
+spa_deactivate_mos_feature(spa_t *spa, const char *feature)
+{
+ (void) nvlist_remove_all(spa->spa_label_features, feature);
+ vdev_config_dirty(spa->spa_root_vdev);
+}
+
/*
* Rename a spa_t.
*/
@@ -1179,12 +1209,22 @@ spa_generate_guid(spa_t *spa)
void
sprintf_blkptr(char *buf, const blkptr_t *bp)
{
- char *type = NULL;
+ char type[256];
char *checksum = NULL;
char *compress = NULL;
if (bp != NULL) {
- type = dmu_ot[BP_GET_TYPE(bp)].ot_name;
+ if (BP_GET_TYPE(bp) & DMU_OT_NEWTYPE) {
+ dmu_object_byteswap_t bswap =
+ DMU_OT_BYTESWAP(BP_GET_TYPE(bp));
+ (void) snprintf(type, sizeof (type), "bswap %s %s",
+ DMU_OT_IS_METADATA(BP_GET_TYPE(bp)) ?
+ "metadata" : "data",
+ dmu_ot_byteswap[bswap].ob_name);
+ } else {
+ (void) strlcpy(type, dmu_ot[BP_GET_TYPE(bp)].ot_name,
+ sizeof (type));
+ }
checksum = zio_checksum_table[BP_GET_CHECKSUM(bp)].ci_name;
compress = zio_compress_table[BP_GET_COMPRESS(bp)].ci_name;
}
@@ -1266,6 +1306,12 @@ spa_get_dsl(spa_t *spa)
return (spa->spa_dsl_pool);
}
+boolean_t
+spa_is_initializing(spa_t *spa)
+{
+ return (spa->spa_is_initializing);
+}
+
blkptr_t *
spa_get_rootblkptr(spa_t *spa)
{
@@ -1549,6 +1595,7 @@ spa_init(int mode)
vdev_cache_stat_init();
zfs_prop_init();
zpool_prop_init();
+ zpool_feature_init();
spa_config_load();
l2arc_start();
}
diff --git a/usr/src/uts/common/fs/zfs/sys/bptree.h b/usr/src/uts/common/fs/zfs/sys/bptree.h
new file mode 100644
index 0000000000..9715072118
--- /dev/null
+++ b/usr/src/uts/common/fs/zfs/sys/bptree.h
@@ -0,0 +1,64 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (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) 2012 by Delphix. All rights reserved.
+ */
+
+#ifndef _SYS_BPTREE_H
+#define _SYS_BPTREE_H
+
+#include <sys/spa.h>
+#include <sys/zio.h>
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+typedef struct bptree_phys {
+ uint64_t bt_begin;
+ uint64_t bt_end;
+ uint64_t bt_bytes;
+ uint64_t bt_comp;
+ uint64_t bt_uncomp;
+} bptree_phys_t;
+
+typedef struct bptree_entry_phys {
+ blkptr_t be_bp;
+ uint64_t be_birth_txg; /* only delete blocks born after this txg */
+ zbookmark_t be_zb; /* holds traversal resume point if needed */
+} bptree_entry_phys_t;
+
+typedef int bptree_itor_t(void *arg, const blkptr_t *bp, dmu_tx_t *tx);
+
+uint64_t bptree_alloc(objset_t *os, dmu_tx_t *tx);
+int bptree_free(objset_t *os, uint64_t obj, dmu_tx_t *tx);
+
+void bptree_add(objset_t *os, uint64_t obj, blkptr_t *bp, uint64_t birth_txg,
+ uint64_t bytes, uint64_t comp, uint64_t uncomp, dmu_tx_t *tx);
+
+int bptree_iterate(objset_t *os, uint64_t obj, boolean_t free,
+ bptree_itor_t func, void *arg, dmu_tx_t *tx);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _SYS_BPTREE_H */
diff --git a/usr/src/uts/common/fs/zfs/sys/dmu.h b/usr/src/uts/common/fs/zfs/sys/dmu.h
index 4476d21b56..d604835755 100644
--- a/usr/src/uts/common/fs/zfs/sys/dmu.h
+++ b/usr/src/uts/common/fs/zfs/sys/dmu.h
@@ -18,12 +18,12 @@
*
* CDDL HEADER END
*/
+
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2011 by Delphix. All rights reserved.
- */
-/*
+ * Copyright (c) 2012 by Delphix. All rights reserved.
* Copyright 2011 Nexenta Systems, Inc. All rights reserved.
+ * Copyright (c) 2012, Joyent, Inc. All rights reserved.
*/
/* Portions Copyright 2010 Robert Milkowski */
@@ -44,6 +44,7 @@
#include <sys/param.h>
#include <sys/cred.h>
#include <sys/time.h>
+#include <sys/fs/zfs.h>
#ifdef __cplusplus
extern "C" {
@@ -74,6 +75,53 @@ typedef struct objset objset_t;
typedef struct dmu_tx dmu_tx_t;
typedef struct dsl_dir dsl_dir_t;
+typedef enum dmu_object_byteswap {
+ DMU_BSWAP_UINT8,
+ DMU_BSWAP_UINT16,
+ DMU_BSWAP_UINT32,
+ DMU_BSWAP_UINT64,
+ DMU_BSWAP_ZAP,
+ DMU_BSWAP_DNODE,
+ DMU_BSWAP_OBJSET,
+ DMU_BSWAP_ZNODE,
+ DMU_BSWAP_OLDACL,
+ DMU_BSWAP_ACL,
+ /*
+ * Allocating a new byteswap type number makes the on-disk format
+ * incompatible with any other format that uses the same number.
+ *
+ * Data can usually be structured to work with one of the
+ * DMU_BSWAP_UINT* or DMU_BSWAP_ZAP types.
+ */
+ DMU_BSWAP_NUMFUNCS
+} dmu_object_byteswap_t;
+
+#define DMU_OT_NEWTYPE 0x80
+#define DMU_OT_METADATA 0x40
+#define DMU_OT_BYTESWAP_MASK 0x3f
+
+/*
+ * Defines a uint8_t object type. Object types specify if the data
+ * in the object is metadata (boolean) and how to byteswap the data
+ * (dmu_object_byteswap_t).
+ */
+#define DMU_OT(byteswap, metadata) \
+ (DMU_OT_NEWTYPE | \
+ ((metadata) ? DMU_OT_METADATA : 0) | \
+ ((byteswap) & DMU_OT_BYTESWAP_MASK))
+
+#define DMU_OT_IS_VALID(ot) (((ot) & DMU_OT_NEWTYPE) ? \
+ ((ot) & DMU_OT_BYTESWAP_MASK) < DMU_BSWAP_NUMFUNCS : \
+ (ot) < DMU_OT_NUMTYPES)
+
+#define DMU_OT_IS_METADATA(ot) (((ot) & DMU_OT_NEWTYPE) ? \
+ ((ot) & DMU_OT_METADATA) : \
+ dmu_ot[(ot)].ot_metadata)
+
+#define DMU_OT_BYTESWAP(ot) (((ot) & DMU_OT_NEWTYPE) ? \
+ ((ot) & DMU_OT_BYTESWAP_MASK) : \
+ dmu_ot[(ot)].ot_byteswap)
+
typedef enum dmu_object_type {
DMU_OT_NONE,
/* general: */
@@ -138,18 +186,36 @@ typedef enum dmu_object_type {
DMU_OT_DEADLIST_HDR, /* UINT64 */
DMU_OT_DSL_CLONES, /* ZAP */
DMU_OT_BPOBJ_SUBOBJ, /* UINT64 */
- DMU_OT_NUMTYPES
-} dmu_object_type_t;
+ /*
+ * Do not allocate new object types here. Doing so makes the on-disk
+ * format incompatible with any other format that uses the same object
+ * type number.
+ *
+ * When creating an object which does not have one of the above types
+ * use the DMU_OTN_* type with the correct byteswap and metadata
+ * values.
+ *
+ * The DMU_OTN_* types do not have entries in the dmu_ot table,
+ * use the DMU_OT_IS_METDATA() and DMU_OT_BYTESWAP() macros instead
+ * of indexing into dmu_ot directly (this works for both DMU_OT_* types
+ * and DMU_OTN_* types).
+ */
+ DMU_OT_NUMTYPES,
-typedef enum dmu_objset_type {
- DMU_OST_NONE,
- DMU_OST_META,
- DMU_OST_ZFS,
- DMU_OST_ZVOL,
- DMU_OST_OTHER, /* For testing only! */
- DMU_OST_ANY, /* Be careful! */
- DMU_OST_NUMTYPES
-} dmu_objset_type_t;
+ /*
+ * Names for valid types declared with DMU_OT().
+ */
+ DMU_OTN_UINT8_DATA = DMU_OT(DMU_BSWAP_UINT8, B_FALSE),
+ DMU_OTN_UINT8_METADATA = DMU_OT(DMU_BSWAP_UINT8, B_TRUE),
+ DMU_OTN_UINT16_DATA = DMU_OT(DMU_BSWAP_UINT16, B_FALSE),
+ DMU_OTN_UINT16_METADATA = DMU_OT(DMU_BSWAP_UINT16, B_TRUE),
+ DMU_OTN_UINT32_DATA = DMU_OT(DMU_BSWAP_UINT32, B_FALSE),
+ DMU_OTN_UINT32_METADATA = DMU_OT(DMU_BSWAP_UINT32, B_TRUE),
+ DMU_OTN_UINT64_DATA = DMU_OT(DMU_BSWAP_UINT64, B_FALSE),
+ DMU_OTN_UINT64_METADATA = DMU_OT(DMU_BSWAP_UINT64, B_TRUE),
+ DMU_OTN_ZAP_DATA = DMU_OT(DMU_BSWAP_ZAP, B_FALSE),
+ DMU_OTN_ZAP_METADATA = DMU_OT(DMU_BSWAP_ZAP, B_TRUE),
+} dmu_object_type_t;
void byteswap_uint64_array(void *buf, size_t size);
void byteswap_uint32_array(void *buf, size_t size);
@@ -195,9 +261,11 @@ int dmu_objset_create(const char *name, dmu_objset_type_t type, uint64_t flags,
int dmu_objset_clone(const char *name, struct dsl_dataset *clone_origin,
uint64_t flags);
int dmu_objset_destroy(const char *name, boolean_t defer);
-int dmu_snapshots_destroy_nvl(struct nvlist *snaps, boolean_t defer, char *);
-int dmu_objset_snapshot(char *fsname, char *snapname, char *tag,
- struct nvlist *props, boolean_t recursive, boolean_t temporary, int fd);
+int dmu_snapshots_destroy_nvl(struct nvlist *snaps, boolean_t defer,
+ struct nvlist *errlist);
+int dmu_objset_snapshot(struct nvlist *snaps, struct nvlist *, struct nvlist *);
+int dmu_objset_snapshot_one(const char *fsname, const char *snapname);
+int dmu_objset_snapshot_tmp(const char *, const char *, int);
int dmu_objset_rename(const char *name, const char *newname,
boolean_t recursive);
int dmu_objset_find(char *name, int func(const char *, void *), void *arg,
@@ -218,6 +286,9 @@ typedef void dmu_buf_evict_func_t(struct dmu_buf *db, void *user_ptr);
*/
#define DMU_POOL_DIRECTORY_OBJECT 1
#define DMU_POOL_CONFIG "config"
+#define DMU_POOL_FEATURES_FOR_WRITE "features_for_write"
+#define DMU_POOL_FEATURES_FOR_READ "features_for_read"
+#define DMU_POOL_FEATURE_DESCRIPTIONS "feature_descriptions"
#define DMU_POOL_ROOT_DATASET "root_dataset"
#define DMU_POOL_SYNC_BPOBJ "sync_bplist"
#define DMU_POOL_ERRLOG_SCRUB "errlog_scrub"
@@ -233,6 +304,7 @@ typedef void dmu_buf_evict_func_t(struct dmu_buf *db, void *user_ptr);
#define DMU_POOL_CREATION_VERSION "creation_version"
#define DMU_POOL_SCAN "scan"
#define DMU_POOL_FREE_BPOBJ "free_bpobj"
+#define DMU_POOL_BPTREE_OBJ "bptree_obj"
/*
* Allocate an object from this objset. The range of object numbers
@@ -493,7 +565,7 @@ void dmu_tx_callback_register(dmu_tx_t *tx, dmu_tx_callback_func_t *dcb_func,
/*
* Free up the data blocks for a defined range of a file. If size is
- * zero, the range from offset to end-of-file is freed.
+ * -1, the range from offset to end-of-file is freed.
*/
int dmu_free_range(objset_t *os, uint64_t object, uint64_t offset,
uint64_t size, dmu_tx_t *tx);
@@ -563,12 +635,18 @@ typedef struct dmu_object_info {
typedef void arc_byteswap_func_t(void *buf, size_t size);
typedef struct dmu_object_type_info {
- arc_byteswap_func_t *ot_byteswap;
+ dmu_object_byteswap_t ot_byteswap;
boolean_t ot_metadata;
char *ot_name;
} dmu_object_type_info_t;
+typedef struct dmu_object_byteswap_info {
+ arc_byteswap_func_t *ob_func;
+ char *ob_name;
+} dmu_object_byteswap_info_t;
+
extern const dmu_object_type_info_t dmu_ot[DMU_OT_NUMTYPES];
+extern const dmu_object_byteswap_info_t dmu_ot_byteswap[DMU_BSWAP_NUMFUNCS];
/*
* Get information on a DMU object.
@@ -704,10 +782,9 @@ typedef void (*dmu_traverse_cb_t)(objset_t *os, void *arg, struct blkptr *bp,
void dmu_traverse_objset(objset_t *os, uint64_t txg_start,
dmu_traverse_cb_t cb, void *arg);
-int dmu_sendbackup(objset_t *tosnap, objset_t *fromsnap, boolean_t fromorigin,
- struct vnode *vp, offset_t *off);
-int dmu_send_estimate(objset_t *tosnap, objset_t *fromsnap, boolean_t fromorign,
- uint64_t *sizep);
+int dmu_send(objset_t *tosnap, objset_t *fromsnap,
+ int outfd, struct vnode *vp, offset_t *off);
+int dmu_send_estimate(objset_t *tosnap, objset_t *fromsnap, uint64_t *sizep);
typedef struct dmu_recv_cookie {
/*
diff --git a/usr/src/uts/common/fs/zfs/sys/dmu_impl.h b/usr/src/uts/common/fs/zfs/sys/dmu_impl.h
index 22f9f5f8c8..defcdb29ca 100644
--- a/usr/src/uts/common/fs/zfs/sys/dmu_impl.h
+++ b/usr/src/uts/common/fs/zfs/sys/dmu_impl.h
@@ -21,6 +21,7 @@
/*
* Copyright 2010 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
+ * Copyright (c) 2012, Joyent, Inc. All rights reserved.
*/
#ifndef _SYS_DMU_IMPL_H
@@ -30,6 +31,7 @@
#include <sys/zio.h>
#include <sys/dnode.h>
#include <sys/zfs_context.h>
+#include <sys/zfs_ioctl.h>
#ifdef __cplusplus
extern "C" {
@@ -264,6 +266,32 @@ static xuio_stats_t xuio_stats = {
atomic_add_64(&xuio_stats.stat.value.ui64, (val))
#define XUIOSTAT_BUMP(stat) XUIOSTAT_INCR(stat, 1)
+/*
+ * The list of data whose inclusion in a send stream can be pending from
+ * one call to backup_cb to another. Multiple calls to dump_free() and
+ * dump_freeobjects() can be aggregated into a single DRR_FREE or
+ * DRR_FREEOBJECTS replay record.
+ */
+typedef enum {
+ PENDING_NONE,
+ PENDING_FREE,
+ PENDING_FREEOBJECTS
+} dmu_pendop_t;
+
+typedef struct dmu_sendarg {
+ list_node_t dsa_link;
+ dmu_replay_record_t *dsa_drr;
+ vnode_t *dsa_vp;
+ int dsa_outfd;
+ struct proc *dsa_proc;
+ offset_t *dsa_off;
+ objset_t *dsa_os;
+ zio_cksum_t dsa_zc;
+ uint64_t dsa_toguid;
+ int dsa_err;
+ dmu_pendop_t dsa_pending_op;
+} dmu_sendarg_t;
+
#ifdef __cplusplus
}
diff --git a/usr/src/uts/common/fs/zfs/sys/dmu_objset.h b/usr/src/uts/common/fs/zfs/sys/dmu_objset.h
index c6d202e2e8..9439993ace 100644
--- a/usr/src/uts/common/fs/zfs/sys/dmu_objset.h
+++ b/usr/src/uts/common/fs/zfs/sys/dmu_objset.h
@@ -20,6 +20,7 @@
*/
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012 by Delphix. All rights reserved.
*/
/* Portions Copyright 2010 Robert Milkowski */
@@ -137,24 +138,14 @@ void dmu_objset_rele(objset_t *os, void *tag);
void dmu_objset_disown(objset_t *os, void *tag);
int dmu_objset_from_ds(struct dsl_dataset *ds, objset_t **osp);
-int dmu_objset_create(const char *name, dmu_objset_type_t type, uint64_t flags,
- void (*func)(objset_t *os, void *arg, cred_t *cr, dmu_tx_t *tx), void *arg);
-int dmu_objset_clone(const char *name, struct dsl_dataset *clone_origin,
- uint64_t flags);
-int dmu_objset_destroy(const char *name, boolean_t defer);
-int dmu_objset_snapshot(char *fsname, char *snapname, char *tag,
- struct nvlist *props, boolean_t recursive, boolean_t temporary, int fd);
void dmu_objset_stats(objset_t *os, nvlist_t *nv);
void dmu_objset_fast_stat(objset_t *os, dmu_objset_stats_t *stat);
void dmu_objset_space(objset_t *os, uint64_t *refdbytesp, uint64_t *availbytesp,
uint64_t *usedobjsp, uint64_t *availobjsp);
uint64_t dmu_objset_fsid_guid(objset_t *os);
-int dmu_objset_find(char *name, int func(const char *, void *), void *arg,
- int flags);
int dmu_objset_find_spa(spa_t *spa, const char *name,
int func(spa_t *, uint64_t, const char *, void *), void *arg, int flags);
int dmu_objset_prefetch(const char *name, void *arg);
-void dmu_objset_byteswap(void *buf, size_t size);
int dmu_objset_evict_dbufs(objset_t *os);
timestruc_t dmu_objset_snap_cmtime(objset_t *os);
diff --git a/usr/src/uts/common/fs/zfs/sys/dmu_traverse.h b/usr/src/uts/common/fs/zfs/sys/dmu_traverse.h
index 5b326cd99c..3cbf42f56a 100644
--- a/usr/src/uts/common/fs/zfs/sys/dmu_traverse.h
+++ b/usr/src/uts/common/fs/zfs/sys/dmu_traverse.h
@@ -20,6 +20,7 @@
*/
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012 by Delphix. All rights reserved.
*/
#ifndef _SYS_DMU_TRAVERSE_H
@@ -54,6 +55,9 @@ typedef int (blkptr_cb_t)(spa_t *spa, zilog_t *zilog, const blkptr_t *bp,
int traverse_dataset(struct dsl_dataset *ds,
uint64_t txg_start, int flags, blkptr_cb_t func, void *arg);
+int traverse_dataset_destroyed(spa_t *spa, blkptr_t *blkptr,
+ uint64_t txg_start, zbookmark_t *resume, int flags,
+ blkptr_cb_t func, void *arg);
int traverse_pool(spa_t *spa,
uint64_t txg_start, int flags, blkptr_cb_t func, void *arg);
diff --git a/usr/src/uts/common/fs/zfs/sys/dsl_dataset.h b/usr/src/uts/common/fs/zfs/sys/dsl_dataset.h
index c4530a8f0a..6c43d97fd9 100644
--- a/usr/src/uts/common/fs/zfs/sys/dsl_dataset.h
+++ b/usr/src/uts/common/fs/zfs/sys/dsl_dataset.h
@@ -20,7 +20,8 @@
*/
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2011 by Delphix. All rights reserved.
+ * Copyright (c) 2012 by Delphix. All rights reserved.
+ * Copyright (c) 2012, Joyent, Inc. All rights reserved.
*/
#ifndef _SYS_DSL_DATASET_H
@@ -85,7 +86,12 @@ typedef struct dsl_dataset_phys {
uint64_t ds_creation_time; /* seconds since 1970 */
uint64_t ds_creation_txg;
uint64_t ds_deadlist_obj; /* DMU_OT_DEADLIST */
- uint64_t ds_used_bytes;
+ /*
+ * ds_referenced_bytes, ds_compressed_bytes, and ds_uncompressed_bytes
+ * include all blocks referenced by this dataset, including those
+ * shared with any other datasets.
+ */
+ uint64_t ds_referenced_bytes;
uint64_t ds_compressed_bytes;
uint64_t ds_uncompressed_bytes;
uint64_t ds_unique_bytes; /* only relevant to snapshots */
@@ -150,6 +156,9 @@ typedef struct dsl_dataset {
uint64_t ds_reserved; /* cached refreservation */
uint64_t ds_quota; /* cached refquota */
+ kmutex_t ds_sendstream_lock;
+ list_t ds_sendstreams;
+
/* Protected by ds_lock; keep at end of struct for better locality */
char ds_snapname[MAXNAMELEN];
} dsl_dataset_t;
@@ -171,7 +180,7 @@ struct dsl_ds_destroyarg {
struct dsl_ds_holdarg {
dsl_sync_task_group_t *dstg;
- char *htag;
+ const char *htag;
char *snapname;
boolean_t recursive;
boolean_t gotone;
@@ -206,12 +215,11 @@ uint64_t dsl_dataset_create_sync(dsl_dir_t *pds, const char *lastname,
uint64_t dsl_dataset_create_sync_dd(dsl_dir_t *dd, dsl_dataset_t *origin,
uint64_t flags, dmu_tx_t *tx);
int dsl_dataset_destroy(dsl_dataset_t *ds, void *tag, boolean_t defer);
-int dsl_snapshots_destroy(char *fsname, char *snapname, boolean_t defer);
dsl_checkfunc_t dsl_dataset_destroy_check;
dsl_syncfunc_t dsl_dataset_destroy_sync;
-dsl_checkfunc_t dsl_dataset_snapshot_check;
-dsl_syncfunc_t dsl_dataset_snapshot_sync;
dsl_syncfunc_t dsl_dataset_user_hold_sync;
+int dsl_dataset_snapshot_check(dsl_dataset_t *ds, const char *, dmu_tx_t *tx);
+void dsl_dataset_snapshot_sync(dsl_dataset_t *ds, const char *, dmu_tx_t *tx);
int dsl_dataset_rename(char *name, const char *newname, boolean_t recursive);
int dsl_dataset_promote(const char *name, char *conflsnap);
int dsl_dataset_clone_swap(dsl_dataset_t *clone, dsl_dataset_t *origin_head,
diff --git a/usr/src/uts/common/fs/zfs/sys/dsl_deleg.h b/usr/src/uts/common/fs/zfs/sys/dsl_deleg.h
index 9db6d07e87..5842639aaf 100644
--- a/usr/src/uts/common/fs/zfs/sys/dsl_deleg.h
+++ b/usr/src/uts/common/fs/zfs/sys/dsl_deleg.h
@@ -20,7 +20,7 @@
*/
/*
* Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2011 by Delphix. All rights reserved.
+ * Copyright (c) 2012 by Delphix. All rights reserved.
*/
#ifndef _SYS_DSL_DELEG_H
@@ -65,8 +65,7 @@ extern "C" {
int dsl_deleg_get(const char *ddname, nvlist_t **nvp);
int dsl_deleg_set(const char *ddname, nvlist_t *nvp, boolean_t unset);
int dsl_deleg_access(const char *ddname, const char *perm, cred_t *cr);
-int dsl_deleg_access_impl(struct dsl_dataset *ds, boolean_t descendent,
- const char *perm, cred_t *cr);
+int dsl_deleg_access_impl(struct dsl_dataset *ds, const char *perm, cred_t *cr);
void dsl_deleg_set_create_perms(dsl_dir_t *dd, dmu_tx_t *tx, cred_t *cr);
int dsl_deleg_can_allow(char *ddname, nvlist_t *nvp, cred_t *cr);
int dsl_deleg_can_unallow(char *ddname, nvlist_t *nvp, cred_t *cr);
diff --git a/usr/src/uts/common/fs/zfs/sys/dsl_pool.h b/usr/src/uts/common/fs/zfs/sys/dsl_pool.h
index 7d25bd7c02..9ff414888c 100644
--- a/usr/src/uts/common/fs/zfs/sys/dsl_pool.h
+++ b/usr/src/uts/common/fs/zfs/sys/dsl_pool.h
@@ -20,6 +20,7 @@
*/
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012 by Delphix. All rights reserved.
*/
#ifndef _SYS_DSL_POOL_H
@@ -34,6 +35,7 @@
#include <sys/ddt.h>
#include <sys/arc.h>
#include <sys/bpobj.h>
+#include <sys/bptree.h>
#ifdef __cplusplus
extern "C" {
@@ -48,7 +50,8 @@ struct dsl_scan;
/* These macros are for indexing into the zfs_all_blkstats_t. */
#define DMU_OT_DEFERRED DMU_OT_NONE
-#define DMU_OT_TOTAL DMU_OT_NUMTYPES
+#define DMU_OT_OTHER DMU_OT_NUMTYPES /* place holder for DMU_OT() types */
+#define DMU_OT_TOTAL (DMU_OT_NUMTYPES + 1)
typedef struct zfs_blkstat {
uint64_t zb_count;
@@ -85,6 +88,7 @@ typedef struct dsl_pool {
uint64_t dp_write_limit;
uint64_t dp_tmp_userrefs_obj;
bpobj_t dp_free_bpobj;
+ uint64_t dp_bptree_obj;
struct dsl_scan *dp_scan;
@@ -110,7 +114,8 @@ typedef struct dsl_pool {
zfs_all_blkstats_t *dp_blkstats;
} dsl_pool_t;
-int dsl_pool_open(spa_t *spa, uint64_t txg, dsl_pool_t **dpp);
+int dsl_pool_init(spa_t *spa, uint64_t txg, dsl_pool_t **dpp);
+int dsl_pool_open(dsl_pool_t *dp);
void dsl_pool_close(dsl_pool_t *dp);
dsl_pool_t *dsl_pool_create(spa_t *spa, nvlist_t *zplprops, uint64_t txg);
void dsl_pool_sync(dsl_pool_t *dp, uint64_t txg);
diff --git a/usr/src/uts/common/fs/zfs/sys/dsl_prop.h b/usr/src/uts/common/fs/zfs/sys/dsl_prop.h
index a636ad3509..b0d9a52cdf 100644
--- a/usr/src/uts/common/fs/zfs/sys/dsl_prop.h
+++ b/usr/src/uts/common/fs/zfs/sys/dsl_prop.h
@@ -20,6 +20,7 @@
*/
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012 by Delphix. All rights reserved.
*/
#ifndef _SYS_DSL_PROP_H
@@ -89,8 +90,6 @@ dsl_syncfunc_t dsl_props_set_sync;
int dsl_prop_set(const char *ddname, const char *propname,
zprop_source_t source, int intsz, int numints, const void *buf);
int dsl_props_set(const char *dsname, zprop_source_t source, nvlist_t *nvl);
-void dsl_dir_prop_set_uint64_sync(dsl_dir_t *dd, const char *name, uint64_t val,
- dmu_tx_t *tx);
void dsl_prop_setarg_init_uint64(dsl_prop_setarg_t *psa, const char *propname,
zprop_source_t source, uint64_t *value);
diff --git a/usr/src/uts/common/fs/zfs/sys/dsl_scan.h b/usr/src/uts/common/fs/zfs/sys/dsl_scan.h
index c79666e67d..5691f4d14d 100644
--- a/usr/src/uts/common/fs/zfs/sys/dsl_scan.h
+++ b/usr/src/uts/common/fs/zfs/sys/dsl_scan.h
@@ -20,6 +20,7 @@
*/
/*
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012 by Delphix. All rights reserved.
*/
#ifndef _SYS_DSL_SCAN_H
@@ -79,6 +80,9 @@ typedef struct dsl_scan {
uint64_t scn_sync_start_time;
zio_t *scn_zio_root;
+ /* for freeing blocks */
+ boolean_t scn_is_bptree;
+
/* for debugging / information */
uint64_t scn_visited_this_txg;
diff --git a/usr/src/uts/common/fs/zfs/sys/rrwlock.h b/usr/src/uts/common/fs/zfs/sys/rrwlock.h
index 19a43c97fc..239268bd58 100644
--- a/usr/src/uts/common/fs/zfs/sys/rrwlock.h
+++ b/usr/src/uts/common/fs/zfs/sys/rrwlock.h
@@ -22,12 +22,13 @@
* Copyright 2007 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
*/
+/*
+ * Copyright (c) 2012 by Delphix. All rights reserved.
+ */
#ifndef _SYS_RR_RW_LOCK_H
#define _SYS_RR_RW_LOCK_H
-#pragma ident "%Z%%M% %I% %E% SMI"
-
#ifdef __cplusplus
extern "C" {
#endif
@@ -69,6 +70,7 @@ void rrw_destroy(rrwlock_t *rrl);
void rrw_enter(rrwlock_t *rrl, krw_t rw, void *tag);
void rrw_exit(rrwlock_t *rrl, void *tag);
boolean_t rrw_held(rrwlock_t *rrl, krw_t rw);
+void rrw_tsd_destroy(void *arg);
#define RRW_READ_HELD(x) rrw_held(x, RW_READER)
#define RRW_WRITE_HELD(x) rrw_held(x, RW_WRITER)
diff --git a/usr/src/uts/common/fs/zfs/sys/spa.h b/usr/src/uts/common/fs/zfs/sys/spa.h
index a8e797c3aa..1043f4038a 100644
--- a/usr/src/uts/common/fs/zfs/sys/spa.h
+++ b/usr/src/uts/common/fs/zfs/sys/spa.h
@@ -20,7 +20,7 @@
*/
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2011 by Delphix. All rights reserved.
+ * Copyright (c) 2012 by Delphix. All rights reserved.
* Copyright 2011 Nexenta Systems, Inc. All rights reserved.
*/
@@ -52,6 +52,7 @@ typedef struct spa_aux_vdev spa_aux_vdev_t;
typedef struct ddt ddt_t;
typedef struct ddt_entry ddt_entry_t;
struct dsl_pool;
+struct dsl_dataset;
/*
* General-purpose 32-bit and 64-bit bitfield encodings.
@@ -94,7 +95,7 @@ struct dsl_pool;
/*
* Size of block to hold the configuration data (a packed nvlist)
*/
-#define SPA_CONFIG_BLOCKSIZE (1 << 14)
+#define SPA_CONFIG_BLOCKSIZE (1ULL << 14)
/*
* The DVA size encodings for LSIZE and PSIZE support blocks up to 32MB.
@@ -262,7 +263,7 @@ typedef struct blkptr {
DVA_GET_ASIZE(&(bp)->blk_dva[2]))
#define BP_GET_UCSIZE(bp) \
- ((BP_GET_LEVEL(bp) > 0 || dmu_ot[BP_GET_TYPE(bp)].ot_metadata) ? \
+ ((BP_GET_LEVEL(bp) > 0 || DMU_OT_IS_METADATA(BP_GET_TYPE(bp))) ? \
BP_GET_PSIZE(bp) : BP_GET_LSIZE(bp))
#define BP_GET_NDVAS(bp) \
@@ -403,8 +404,8 @@ typedef struct blkptr {
#include <sys/dmu.h>
#define BP_GET_BUFC_TYPE(bp) \
- (((BP_GET_LEVEL(bp) > 0) || (dmu_ot[BP_GET_TYPE(bp)].ot_metadata)) ? \
- ARC_BUFC_METADATA : ARC_BUFC_DATA);
+ (((BP_GET_LEVEL(bp) > 0) || (DMU_OT_IS_METADATA(BP_GET_TYPE(bp)))) ? \
+ ARC_BUFC_METADATA : ARC_BUFC_DATA)
typedef enum spa_import_type {
SPA_IMPORT_EXISTING,
@@ -415,10 +416,10 @@ typedef enum spa_import_type {
extern int spa_open(const char *pool, spa_t **, void *tag);
extern int spa_open_rewind(const char *pool, spa_t **, void *tag,
nvlist_t *policy, nvlist_t **config);
-extern int spa_get_stats(const char *pool, nvlist_t **config,
- char *altroot, size_t buflen);
+extern int spa_get_stats(const char *pool, nvlist_t **config, char *altroot,
+ size_t buflen);
extern int spa_create(const char *pool, nvlist_t *config, nvlist_t *props,
- const char *history_str, nvlist_t *zplprops);
+ nvlist_t *zplprops);
extern int spa_import_rootpool(char *devpath, char *devid);
extern int spa_import(const char *pool, nvlist_t *config, nvlist_t *props,
uint64_t flags);
@@ -573,6 +574,7 @@ extern void spa_claim_notify(zio_t *zio);
/* Accessor functions */
extern boolean_t spa_shutting_down(spa_t *spa);
extern struct dsl_pool *spa_get_dsl(spa_t *spa);
+extern boolean_t spa_is_initializing(spa_t *spa);
extern blkptr_t *spa_get_rootblkptr(spa_t *spa);
extern void spa_set_rootblkptr(spa_t *spa, const blkptr_t *bp);
extern void spa_altroot(spa_t *, char *, size_t);
@@ -604,6 +606,8 @@ extern uint64_t spa_delegation(spa_t *spa);
extern objset_t *spa_meta_objset(spa_t *spa);
/* Miscellaneous support routines */
+extern void spa_activate_mos_feature(spa_t *spa, const char *feature);
+extern void spa_deactivate_mos_feature(spa_t *spa, const char *feature);
extern int spa_rename(const char *oldname, const char *newname);
extern spa_t *spa_by_guid(uint64_t pool_guid, uint64_t device_guid);
extern boolean_t spa_guid_exists(uint64_t pool_guid, uint64_t device_guid);
@@ -629,31 +633,20 @@ extern boolean_t spa_writeable(spa_t *spa);
extern int spa_mode(spa_t *spa);
extern uint64_t strtonum(const char *str, char **nptr);
-/* history logging */
-typedef enum history_log_type {
- LOG_CMD_POOL_CREATE,
- LOG_CMD_NORMAL,
- LOG_INTERNAL
-} history_log_type_t;
-
-typedef struct history_arg {
- char *ha_history_str;
- history_log_type_t ha_log_type;
- history_internal_events_t ha_event;
- char *ha_zone;
- uid_t ha_uid;
-} history_arg_t;
-
extern char *spa_his_ievent_table[];
extern void spa_history_create_obj(spa_t *spa, dmu_tx_t *tx);
extern int spa_history_get(spa_t *spa, uint64_t *offset, uint64_t *len_read,
char *his_buf);
-extern int spa_history_log(spa_t *spa, const char *his_buf,
- history_log_type_t what);
-extern void spa_history_log_internal(history_internal_events_t event,
- spa_t *spa, dmu_tx_t *tx, const char *fmt, ...);
-extern void spa_history_log_version(spa_t *spa, history_internal_events_t evt);
+extern int spa_history_log(spa_t *spa, const char *his_buf);
+extern int spa_history_log_nvl(spa_t *spa, nvlist_t *nvl);
+extern void spa_history_log_version(spa_t *spa, const char *operation);
+extern void spa_history_log_internal(spa_t *spa, const char *operation,
+ dmu_tx_t *tx, const char *fmt, ...);
+extern void spa_history_log_internal_ds(struct dsl_dataset *ds, const char *op,
+ dmu_tx_t *tx, const char *fmt, ...);
+extern void spa_history_log_internal_dd(dsl_dir_t *dd, const char *operation,
+ dmu_tx_t *tx, const char *fmt, ...);
/* error handling */
struct zbookmark;
diff --git a/usr/src/uts/common/fs/zfs/sys/spa_impl.h b/usr/src/uts/common/fs/zfs/sys/spa_impl.h
index 163efd650c..5118954b00 100644
--- a/usr/src/uts/common/fs/zfs/sys/spa_impl.h
+++ b/usr/src/uts/common/fs/zfs/sys/spa_impl.h
@@ -20,7 +20,7 @@
*/
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2011 by Delphix. All rights reserved.
+ * Copyright (c) 2012 by Delphix. All rights reserved.
* Copyright 2011 Nexenta Systems, Inc. All rights reserved.
*/
@@ -127,6 +127,7 @@ struct spa {
uint64_t spa_import_flags; /* import specific flags */
taskq_t *spa_zio_taskq[ZIO_TYPES][ZIO_TASKQ_TYPES];
dsl_pool_t *spa_dsl_pool;
+ boolean_t spa_is_initializing; /* true while opening pool */
metaslab_class_t *spa_normal_class; /* normal data class */
metaslab_class_t *spa_log_class; /* intent log data class */
uint64_t spa_first_txg; /* first txg after spa_open() */
@@ -144,6 +145,7 @@ struct spa {
list_t spa_state_dirty_list; /* vdevs with dirty state */
spa_aux_vdev_t spa_spares; /* hot spares */
spa_aux_vdev_t spa_l2cache; /* L2ARC cache devices */
+ nvlist_t *spa_label_features; /* Features for reading MOS */
uint64_t spa_config_object; /* MOS object for pool config */
uint64_t spa_config_generation; /* config generation number */
uint64_t spa_syncing_txg; /* txg currently syncing */
@@ -220,7 +222,10 @@ struct spa {
boolean_t spa_autoreplace; /* autoreplace set in open */
int spa_vdev_locks; /* locks grabbed */
uint64_t spa_creation_version; /* version at pool creation */
- uint64_t spa_prev_software_version;
+ uint64_t spa_prev_software_version; /* See ub_software_version */
+ uint64_t spa_feat_for_write_obj; /* required to write to pool */
+ uint64_t spa_feat_for_read_obj; /* required to read from pool */
+ uint64_t spa_feat_desc_obj; /* Feature descriptions */
/*
* spa_refcnt & spa_config_lock must be the last elements
* because refcount_t changes size based on compilation options.
diff --git a/usr/src/uts/common/fs/zfs/sys/vdev.h b/usr/src/uts/common/fs/zfs/sys/vdev.h
index aa6559c801..2329d5b85c 100644
--- a/usr/src/uts/common/fs/zfs/sys/vdev.h
+++ b/usr/src/uts/common/fs/zfs/sys/vdev.h
@@ -18,6 +18,7 @@
*
* CDDL HEADER END
*/
+
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012 by Delphix. All rights reserved.
@@ -141,8 +142,8 @@ extern nvlist_t *vdev_config_generate(spa_t *spa, vdev_t *vd,
struct uberblock;
extern uint64_t vdev_label_offset(uint64_t psize, int l, uint64_t offset);
extern int vdev_label_number(uint64_t psise, uint64_t offset);
-extern nvlist_t *vdev_label_read_config(vdev_t *vd);
-extern void vdev_uberblock_load(zio_t *zio, vdev_t *vd, struct uberblock *ub);
+extern nvlist_t *vdev_label_read_config(vdev_t *vd, int label);
+extern void vdev_uberblock_load(vdev_t *, struct uberblock *, nvlist_t **);
typedef enum {
VDEV_LABEL_CREATE, /* create/add a new device */
diff --git a/usr/src/uts/common/fs/zfs/sys/vdev_impl.h b/usr/src/uts/common/fs/zfs/sys/vdev_impl.h
index 3a2d7a04d8..c772d954bb 100644
--- a/usr/src/uts/common/fs/zfs/sys/vdev_impl.h
+++ b/usr/src/uts/common/fs/zfs/sys/vdev_impl.h
@@ -203,7 +203,7 @@ struct vdev {
* For DTrace to work in userland (libzpool) context, these fields must
* remain at the end of the structure. DTrace will use the kernel's
* CTF definition for 'struct vdev', and since the size of a kmutex_t is
- * larger in userland, the offsets for the rest fields would be
+ * larger in userland, the offsets for the rest of the fields would be
* incorrect.
*/
kmutex_t vdev_dtl_lock; /* vdev_dtl_{map,resilver} */
@@ -258,6 +258,7 @@ typedef struct vdev_label {
#define VDEV_LABEL_START_SIZE (2 * sizeof (vdev_label_t) + VDEV_BOOT_SIZE)
#define VDEV_LABEL_END_SIZE (2 * sizeof (vdev_label_t))
#define VDEV_LABELS 4
+#define VDEV_BEST_LABEL VDEV_LABELS
#define VDEV_ALLOC_LOAD 0
#define VDEV_ALLOC_ADD 1
diff --git a/usr/src/uts/common/fs/zfs/sys/zap.h b/usr/src/uts/common/fs/zfs/sys/zap.h
index a1130bbbaa..4d7b315597 100644
--- a/usr/src/uts/common/fs/zfs/sys/zap.h
+++ b/usr/src/uts/common/fs/zfs/sys/zap.h
@@ -20,6 +20,7 @@
*/
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012 by Delphix. All rights reserved.
*/
#ifndef _SYS_ZAP_H
@@ -132,6 +133,8 @@ uint64_t zap_create_norm(objset_t *ds, int normflags, dmu_object_type_t ot,
uint64_t zap_create_flags(objset_t *os, int normflags, zap_flags_t flags,
dmu_object_type_t ot, int leaf_blockshift, int indirect_blockshift,
dmu_object_type_t bonustype, int bonuslen, dmu_tx_t *tx);
+uint64_t zap_create_link(objset_t *os, dmu_object_type_t ot,
+ uint64_t parent_obj, const char *name, dmu_tx_t *tx);
/*
* Create a new zapobj with no attributes from the given (unallocated)
@@ -300,12 +303,6 @@ int zap_add_int_key(objset_t *os, uint64_t obj,
int zap_lookup_int_key(objset_t *os, uint64_t obj,
uint64_t key, uint64_t *valuep);
-/*
- * They name is a stringified version of key; increment its value by
- * delta. Zero values will be zap_remove()-ed.
- */
-int zap_increment_int(objset_t *os, uint64_t obj, uint64_t key, int64_t delta,
- dmu_tx_t *tx);
int zap_increment(objset_t *os, uint64_t obj, const char *name, int64_t delta,
dmu_tx_t *tx);
diff --git a/usr/src/uts/common/fs/zfs/sys/zfeature.h b/usr/src/uts/common/fs/zfs/sys/zfeature.h
new file mode 100644
index 0000000000..481e85b1ba
--- /dev/null
+++ b/usr/src/uts/common/fs/zfs/sys/zfeature.h
@@ -0,0 +1,52 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (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) 2012 by Delphix. All rights reserved.
+ */
+
+#ifndef _SYS_ZFEATURE_H
+#define _SYS_ZFEATURE_H
+
+#include <sys/dmu.h>
+#include <sys/nvpair.h>
+#include "zfeature_common.h"
+
+#ifdef __cplusplus
+extern "C" {
+#endif
+
+extern boolean_t feature_is_supported(objset_t *os, uint64_t obj,
+ uint64_t desc_obj, nvlist_t *unsup_feat, nvlist_t *enabled_feat);
+
+struct spa;
+extern void spa_feature_create_zap_objects(struct spa *, dmu_tx_t *);
+extern void spa_feature_enable(struct spa *, zfeature_info_t *, dmu_tx_t *);
+extern void spa_feature_incr(struct spa *, zfeature_info_t *, dmu_tx_t *);
+extern void spa_feature_decr(struct spa *, zfeature_info_t *, dmu_tx_t *);
+extern boolean_t spa_feature_is_enabled(struct spa *, zfeature_info_t *);
+extern boolean_t spa_feature_is_active(struct spa *, zfeature_info_t *);
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif /* _SYS_ZFEATURE_H */
diff --git a/usr/src/uts/common/fs/zfs/sys/zfs_ioctl.h b/usr/src/uts/common/fs/zfs/sys/zfs_ioctl.h
index 84bf794fe5..4d781ad2a4 100644
--- a/usr/src/uts/common/fs/zfs/sys/zfs_ioctl.h
+++ b/usr/src/uts/common/fs/zfs/sys/zfs_ioctl.h
@@ -20,6 +20,7 @@
*/
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012 by Delphix. All rights reserved.
*/
#ifndef _SYS_ZFS_IOCTL_H
@@ -41,6 +42,15 @@ extern "C" {
#endif
/*
+ * The structures in this file are passed between userland and the
+ * kernel. Userland may be running a 32-bit process, while the kernel
+ * is 64-bit. Therefore, these structures need to compile the same in
+ * 32-bit and 64-bit. This means not using type "long", and adding
+ * explicit padding so that the 32-bit structure will not be packed more
+ * tightly than the 64-bit structure (which requires 64-bit alignment).
+ */
+
+/*
* Property values for snapdir
*/
#define ZFS_SNAPDIR_HIDDEN 0
@@ -256,22 +266,29 @@ typedef enum zfs_case {
} zfs_case_t;
typedef struct zfs_cmd {
- char zc_name[MAXPATHLEN];
+ char zc_name[MAXPATHLEN]; /* name of pool or dataset */
+ uint64_t zc_nvlist_src; /* really (char *) */
+ uint64_t zc_nvlist_src_size;
+ uint64_t zc_nvlist_dst; /* really (char *) */
+ uint64_t zc_nvlist_dst_size;
+ boolean_t zc_nvlist_dst_filled; /* put an nvlist in dst? */
+ int zc_pad2;
+
+ /*
+ * The following members are for legacy ioctls which haven't been
+ * converted to the new method.
+ */
+ uint64_t zc_history; /* really (char *) */
char zc_value[MAXPATHLEN * 2];
char zc_string[MAXNAMELEN];
char zc_top_ds[MAXPATHLEN];
uint64_t zc_guid;
uint64_t zc_nvlist_conf; /* really (char *) */
uint64_t zc_nvlist_conf_size;
- uint64_t zc_nvlist_src; /* really (char *) */
- uint64_t zc_nvlist_src_size;
- uint64_t zc_nvlist_dst; /* really (char *) */
- uint64_t zc_nvlist_dst_size;
uint64_t zc_cookie;
uint64_t zc_objset_type;
uint64_t zc_perm_action;
- uint64_t zc_history; /* really (char *) */
- uint64_t zc_history_len;
+ uint64_t zc_history_len;
uint64_t zc_history_offset;
uint64_t zc_obj;
uint64_t zc_iflags; /* internal to zfs(7fs) */
diff --git a/usr/src/uts/common/fs/zfs/sys/zio.h b/usr/src/uts/common/fs/zfs/sys/zio.h
index 032b77715f..ce3a983d9f 100644
--- a/usr/src/uts/common/fs/zfs/sys/zio.h
+++ b/usr/src/uts/common/fs/zfs/sys/zio.h
@@ -25,6 +25,7 @@
/*
* Copyright 2011 Nexenta Systems, Inc. All rights reserved.
* Copyright 2011 Joyent, Inc. All rights reserved.
+ * Copyright (c) 2012 by Delphix. All rights reserved.
*/
#ifndef _ZIO_H
@@ -275,6 +276,14 @@ typedef struct zbookmark {
#define ZB_ZIL_OBJECT (0ULL)
#define ZB_ZIL_LEVEL (-2LL)
+#define ZB_IS_ZERO(zb) \
+ ((zb)->zb_objset == 0 && (zb)->zb_object == 0 && \
+ (zb)->zb_level == 0 && (zb)->zb_blkid == 0)
+#define ZB_IS_ROOT(zb) \
+ ((zb)->zb_object == ZB_ROOT_OBJECT && \
+ (zb)->zb_level == ZB_ROOT_LEVEL && \
+ (zb)->zb_blkid == ZB_ROOT_BLKID)
+
typedef struct zio_prop {
enum zio_checksum zp_checksum;
enum zio_compress zp_compress;
@@ -292,6 +301,7 @@ typedef void zio_cksum_finish_f(zio_cksum_report_t *rep,
typedef void zio_cksum_free_f(void *cbdata, size_t size);
struct zio_bad_cksum; /* defined in zio_checksum.h */
+struct dnode_phys;
struct zio_cksum_report {
struct zio_cksum_report *zcr_next;
@@ -564,6 +574,10 @@ extern void zfs_ereport_post_checksum(spa_t *spa, vdev_t *vd,
/* Called from spa_sync(), but primarily an injection handler */
extern void spa_handle_ignored_writes(spa_t *spa);
+/* zbookmark functions */
+boolean_t zbookmark_is_before(const struct dnode_phys *dnp,
+ const zbookmark_t *zb1, const zbookmark_t *zb2);
+
#ifdef __cplusplus
}
#endif
diff --git a/usr/src/uts/common/fs/zfs/vdev.c b/usr/src/uts/common/fs/zfs/vdev.c
index 6606b1f486..6fbaf7b7ec 100644
--- a/usr/src/uts/common/fs/zfs/vdev.c
+++ b/usr/src/uts/common/fs/zfs/vdev.c
@@ -1328,7 +1328,8 @@ vdev_validate(vdev_t *vd, boolean_t strict)
uint64_t aux_guid = 0;
nvlist_t *nvl;
- if ((label = vdev_label_read_config(vd)) == NULL) {
+ if ((label = vdev_label_read_config(vd, VDEV_BEST_LABEL)) ==
+ NULL) {
vdev_set_state(vd, B_TRUE, VDEV_STATE_CANT_OPEN,
VDEV_AUX_BAD_LABEL);
return (0);
@@ -1969,14 +1970,14 @@ vdev_validate_aux(vdev_t *vd)
if (!vdev_readable(vd))
return (0);
- if ((label = vdev_label_read_config(vd)) == NULL) {
+ if ((label = vdev_label_read_config(vd, VDEV_BEST_LABEL)) == NULL) {
vdev_set_state(vd, B_TRUE, VDEV_STATE_CANT_OPEN,
VDEV_AUX_CORRUPT_DATA);
return (-1);
}
if (nvlist_lookup_uint64(label, ZPOOL_CONFIG_VERSION, &version) != 0 ||
- version > SPA_VERSION ||
+ !SPA_VERSION_IS_SUPPORTED(version) ||
nvlist_lookup_uint64(label, ZPOOL_CONFIG_GUID, &guid) != 0 ||
guid != vd->vdev_guid ||
nvlist_lookup_uint64(label, ZPOOL_CONFIG_POOL_STATE, &state) != 0) {
diff --git a/usr/src/uts/common/fs/zfs/vdev_label.c b/usr/src/uts/common/fs/zfs/vdev_label.c
index c08ed8ba04..b943647249 100644
--- a/usr/src/uts/common/fs/zfs/vdev_label.c
+++ b/usr/src/uts/common/fs/zfs/vdev_label.c
@@ -18,8 +18,10 @@
*
* CDDL HEADER END
*/
+
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012 by Delphix. All rights reserved.
*/
/*
@@ -121,6 +123,8 @@
* txg Transaction group in which this label was written
* pool_guid Unique identifier for this pool
* vdev_tree An nvlist describing vdev tree.
+ * features_for_read
+ * An nvlist of the features necessary for reading the MOS.
*
* Each leaf device label also contains the following:
*
@@ -428,8 +432,13 @@ vdev_top_config_generate(spa_t *spa, nvlist_t *config)
kmem_free(array, rvd->vdev_children * sizeof (uint64_t));
}
+/*
+ * Returns the configuration from the label of the given vdev. If 'label' is
+ * VDEV_BEST_LABEL, each label of the vdev will be read until a valid
+ * configuration is found; otherwise, only the specified label will be read.
+ */
nvlist_t *
-vdev_label_read_config(vdev_t *vd)
+vdev_label_read_config(vdev_t *vd, int label)
{
spa_t *spa = vd->vdev_spa;
nvlist_t *config = NULL;
@@ -447,6 +456,8 @@ vdev_label_read_config(vdev_t *vd)
retry:
for (int l = 0; l < VDEV_LABELS; l++) {
+ if (label >= 0 && label < VDEV_LABELS && label != l)
+ continue;
zio = zio_root(spa, NULL, NULL, flags);
@@ -496,7 +507,7 @@ vdev_inuse(vdev_t *vd, uint64_t crtxg, vdev_labeltype_t reason,
/*
* Read the label, if any, and perform some basic sanity checks.
*/
- if ((label = vdev_label_read_config(vd)) == NULL)
+ if ((label = vdev_label_read_config(vd, VDEV_BEST_LABEL)) == NULL)
return (B_FALSE);
(void) nvlist_lookup_uint64(label, ZPOOL_CONFIG_CREATE_TXG,
@@ -833,7 +844,7 @@ retry:
* come back up, we fail to see the uberblock for txg + 1 because, say,
* it was on a mirrored device and the replica to which we wrote txg + 1
* is now offline. If we then make some changes and sync txg + 1, and then
- * the missing replica comes back, then for a new seconds we'll have two
+ * the missing replica comes back, then for a few seconds we'll have two
* conflicting uberblocks on disk with the same txg. The solution is simple:
* among uberblocks with equal txg, choose the one with the latest timestamp.
*/
@@ -853,46 +864,50 @@ vdev_uberblock_compare(uberblock_t *ub1, uberblock_t *ub2)
return (0);
}
+struct ubl_cbdata {
+ uberblock_t *ubl_ubbest; /* Best uberblock */
+ vdev_t *ubl_vd; /* vdev associated with the above */
+ int ubl_label; /* Label associated with the above */
+};
+
static void
vdev_uberblock_load_done(zio_t *zio)
{
+ vdev_t *vd = zio->io_vd;
spa_t *spa = zio->io_spa;
zio_t *rio = zio->io_private;
uberblock_t *ub = zio->io_data;
- uberblock_t *ubbest = rio->io_private;
+ struct ubl_cbdata *cbp = rio->io_private;
- ASSERT3U(zio->io_size, ==, VDEV_UBERBLOCK_SIZE(zio->io_vd));
+ ASSERT3U(zio->io_size, ==, VDEV_UBERBLOCK_SIZE(vd));
if (zio->io_error == 0 && uberblock_verify(ub) == 0) {
mutex_enter(&rio->io_lock);
if (ub->ub_txg <= spa->spa_load_max_txg &&
- vdev_uberblock_compare(ub, ubbest) > 0)
- *ubbest = *ub;
+ vdev_uberblock_compare(ub, cbp->ubl_ubbest) > 0) {
+ /*
+ * Keep track of the vdev and label in which this
+ * uberblock was found. We will use this information
+ * later to obtain the config nvlist associated with
+ * this uberblock.
+ */
+ *cbp->ubl_ubbest = *ub;
+ cbp->ubl_vd = vd;
+ cbp->ubl_label = vdev_label_number(vd->vdev_psize,
+ zio->io_offset);
+ }
mutex_exit(&rio->io_lock);
}
zio_buf_free(zio->io_data, zio->io_size);
}
-void
-vdev_uberblock_load(zio_t *zio, vdev_t *vd, uberblock_t *ubbest)
+static void
+vdev_uberblock_load_impl(zio_t *zio, vdev_t *vd, int flags,
+ struct ubl_cbdata *cbp)
{
- spa_t *spa = vd->vdev_spa;
- vdev_t *rvd = spa->spa_root_vdev;
- int flags = ZIO_FLAG_CONFIG_WRITER | ZIO_FLAG_CANFAIL |
- ZIO_FLAG_SPECULATIVE | ZIO_FLAG_TRYHARD;
-
- if (vd == rvd) {
- ASSERT(zio == NULL);
- spa_config_enter(spa, SCL_ALL, FTAG, RW_WRITER);
- zio = zio_root(spa, NULL, ubbest, flags);
- bzero(ubbest, sizeof (uberblock_t));
- }
-
- ASSERT(zio != NULL);
-
for (int c = 0; c < vd->vdev_children; c++)
- vdev_uberblock_load(zio, vd->vdev_child[c], ubbest);
+ vdev_uberblock_load_impl(zio, vd->vdev_child[c], flags, cbp);
if (vd->vdev_ops->vdev_op_leaf && vdev_readable(vd)) {
for (int l = 0; l < VDEV_LABELS; l++) {
@@ -905,11 +920,45 @@ vdev_uberblock_load(zio_t *zio, vdev_t *vd, uberblock_t *ubbest)
}
}
}
+}
- if (vd == rvd) {
- (void) zio_wait(zio);
- spa_config_exit(spa, SCL_ALL, FTAG);
+/*
+ * Reads the 'best' uberblock from disk along with its associated
+ * configuration. First, we read the uberblock array of each label of each
+ * vdev, keeping track of the uberblock with the highest txg in each array.
+ * Then, we read the configuration from the same label as the best uberblock.
+ */
+void
+vdev_uberblock_load(vdev_t *rvd, uberblock_t *ub, nvlist_t **config)
+{
+ int i;
+ zio_t *zio;
+ spa_t *spa = rvd->vdev_spa;
+ struct ubl_cbdata cb;
+ int flags = ZIO_FLAG_CONFIG_WRITER | ZIO_FLAG_CANFAIL |
+ ZIO_FLAG_SPECULATIVE | ZIO_FLAG_TRYHARD;
+
+ ASSERT(ub);
+ ASSERT(config);
+
+ bzero(ub, sizeof (uberblock_t));
+ *config = NULL;
+
+ cb.ubl_ubbest = ub;
+ cb.ubl_vd = NULL;
+
+ spa_config_enter(spa, SCL_ALL, FTAG, RW_WRITER);
+ zio = zio_root(spa, NULL, &cb, flags);
+ vdev_uberblock_load_impl(zio, rvd, flags, &cb);
+ (void) zio_wait(zio);
+ if (cb.ubl_vd != NULL) {
+ for (i = cb.ubl_label % 2; i < VDEV_LABELS; i += 2) {
+ *config = vdev_label_read_config(cb.ubl_vd, i);
+ if (*config != NULL)
+ break;
+ }
}
+ spa_config_exit(spa, SCL_ALL, FTAG);
}
/*
diff --git a/usr/src/uts/common/fs/zfs/zap.c b/usr/src/uts/common/fs/zfs/zap.c
index 288a4d99ab..fa1d99fec9 100644
--- a/usr/src/uts/common/fs/zfs/zap.c
+++ b/usr/src/uts/common/fs/zfs/zap.c
@@ -20,6 +20,7 @@
*/
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012 by Delphix. All rights reserved.
*/
/*
@@ -946,6 +947,19 @@ fzap_prefetch(zap_name_t *zn)
* Helper functions for consumers.
*/
+uint64_t
+zap_create_link(objset_t *os, dmu_object_type_t ot, uint64_t parent_obj,
+ const char *name, dmu_tx_t *tx)
+{
+ uint64_t new_obj;
+
+ VERIFY((new_obj = zap_create(os, ot, DMU_OT_NONE, 0, tx)) > 0);
+ VERIFY(zap_add(os, parent_obj, name, sizeof (uint64_t), 1, &new_obj,
+ tx) == 0);
+
+ return (new_obj);
+}
+
int
zap_value_search(objset_t *os, uint64_t zapobj, uint64_t value, uint64_t mask,
char *name)
diff --git a/usr/src/uts/common/fs/zfs/zap_micro.c b/usr/src/uts/common/fs/zfs/zap_micro.c
index c148ea14cd..3e80fb9c5d 100644
--- a/usr/src/uts/common/fs/zfs/zap_micro.c
+++ b/usr/src/uts/common/fs/zfs/zap_micro.c
@@ -20,7 +20,7 @@
*/
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright (c) 2011 by Delphix. All rights reserved.
+ * Copyright (c) 2012 by Delphix. All rights reserved.
*/
#include <sys/zio.h>
@@ -461,7 +461,7 @@ zap_lockdir(objset_t *os, uint64_t obj, dmu_tx_t *tx,
{
dmu_object_info_t doi;
dmu_object_info_from_db(db, &doi);
- ASSERT(dmu_ot[doi.doi_type].ot_byteswap == zap_byteswap);
+ ASSERT3U(DMU_OT_BYTESWAP(doi.doi_type), ==, DMU_BSWAP_ZAP);
}
#endif
@@ -585,7 +585,7 @@ mzap_create_impl(objset_t *os, uint64_t obj, int normflags, zap_flags_t flags,
{
dmu_object_info_t doi;
dmu_object_info_from_db(db, &doi);
- ASSERT(dmu_ot[doi.doi_type].ot_byteswap == zap_byteswap);
+ ASSERT3U(DMU_OT_BYTESWAP(doi.doi_type), ==, DMU_BSWAP_ZAP);
}
#endif
diff --git a/usr/src/uts/common/fs/zfs/zfeature.c b/usr/src/uts/common/fs/zfs/zfeature.c
new file mode 100644
index 0000000000..b9250df4a9
--- /dev/null
+++ b/usr/src/uts/common/fs/zfs/zfeature.c
@@ -0,0 +1,419 @@
+/*
+ * CDDL HEADER START
+ *
+ * The contents of this file are subject to the terms of the
+ * Common Development and Distribution License (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) 2012 by Delphix. All rights reserved.
+ */
+
+#include <sys/zfs_context.h>
+#include <sys/zfeature.h>
+#include <sys/dmu.h>
+#include <sys/nvpair.h>
+#include <sys/zap.h>
+#include <sys/dmu_tx.h>
+#include "zfeature_common.h"
+#include <sys/spa_impl.h>
+
+/*
+ * ZFS Feature Flags
+ * -----------------
+ *
+ * ZFS feature flags are used to provide fine-grained versioning to the ZFS
+ * on-disk format. Once enabled on a pool feature flags replace the old
+ * spa_version() number.
+ *
+ * Each new on-disk format change will be given a uniquely identifying string
+ * guid rather than a version number. This avoids the problem of different
+ * organizations creating new on-disk formats with the same version number. To
+ * keep feature guids unique they should consist of the reverse dns name of the
+ * organization which implemented the feature and a short name for the feature,
+ * separated by a colon (e.g. com.delphix:async_destroy).
+ *
+ * Reference Counts
+ * ----------------
+ *
+ * Within each pool features can be in one of three states: disabled, enabled,
+ * or active. These states are differentiated by a reference count stored on
+ * disk for each feature:
+ *
+ * 1) If there is no reference count stored on disk the feature is disabled.
+ * 2) If the reference count is 0 a system administrator has enabled the
+ * feature, but the feature has not been used yet, so no on-disk
+ * format changes have been made.
+ * 3) If the reference count is greater than 0 the feature is active.
+ * The format changes required by the feature are currently on disk.
+ * Note that if the feature's format changes are reversed the feature
+ * may choose to set its reference count back to 0.
+ *
+ * Feature flags makes no differentiation between non-zero reference counts
+ * for an active feature (e.g. a reference count of 1 means the same thing as a
+ * reference count of 27834721), but feature implementations may choose to use
+ * the reference count to store meaningful information. For example, a new RAID
+ * implementation might set the reference count to the number of vdevs using
+ * it. If all those disks are removed from the pool the feature goes back to
+ * having a reference count of 0.
+ *
+ * It is the responsibility of the individual features to maintain a non-zero
+ * reference count as long as the feature's format changes are present on disk.
+ *
+ * Dependencies
+ * ------------
+ *
+ * Each feature may depend on other features. The only effect of this
+ * relationship is that when a feature is enabled all of its dependencies are
+ * automatically enabled as well. Any future work to support disabling of
+ * features would need to ensure that features cannot be disabled if other
+ * enabled features depend on them.
+ *
+ * On-disk Format
+ * --------------
+ *
+ * When feature flags are enabled spa_version() is set to SPA_VERSION_FEATURES
+ * (5000). In order for this to work the pool is automatically upgraded to
+ * SPA_VERSION_BEFORE_FEATURES (28) first, so all pre-feature flags on disk
+ * format changes will be in use.
+ *
+ * Information about features is stored in 3 ZAP objects in the pool's MOS.
+ * These objects are linked to by the following names in the pool directory
+ * object:
+ *
+ * 1) features_for_read: feature guid -> reference count
+ * Features needed to open the pool for reading.
+ * 2) features_for_write: feature guid -> reference count
+ * Features needed to open the pool for writing.
+ * 3) feature_descriptions: feature guid -> descriptive string
+ * A human readable string.
+ *
+ * All enabled features appear in either features_for_read or
+ * features_for_write, but not both.
+ *
+ * To open a pool in read-only mode only the features listed in
+ * features_for_read need to be supported.
+ *
+ * To open the pool in read-write mode features in both features_for_read and
+ * features_for_write need to be supported.
+ *
+ * Some features may be required to read the ZAP objects containing feature
+ * information. To allow software to check for compatibility with these features
+ * before the pool is opened their names must be stored in the label in a
+ * new "features_for_read" entry (note that features that are only required
+ * to write to a pool never need to be stored in the label since the
+ * features_for_write ZAP object can be read before the pool is written to).
+ * To save space in the label features must be explicitly marked as needing to
+ * be written to the label. Also, reference counts are not stored in the label,
+ * instead any feature whose reference count drops to 0 is removed from the
+ * label.
+ *
+ * Adding New Features
+ * -------------------
+ *
+ * Features must be registered in zpool_feature_init() function in
+ * zfeature_common.c using the zfeature_register() function. This function
+ * has arguments to specify if the feature should be stored in the
+ * features_for_read or features_for_write ZAP object and if it needs to be
+ * written to the label when active.
+ *
+ * Once a feature is registered it will appear as a "feature@<feature name>"
+ * property which can be set by an administrator. Feature implementors should
+ * use the spa_feature_is_enabled() and spa_feature_is_active() functions to
+ * query the state of a feature and the spa_feature_incr() and
+ * spa_feature_decr() functions to change an enabled feature's reference count.
+ * Reference counts may only be updated in the syncing context.
+ *
+ * Features may not perform enable-time initialization. Instead, any such
+ * initialization should occur when the feature is first used. This design
+ * enforces that on-disk changes be made only when features are used. Code
+ * should only check if a feature is enabled using spa_feature_is_enabled(),
+ * not by relying on any feature specific metadata existing. If a feature is
+ * enabled, but the feature's metadata is not on disk yet then it should be
+ * created as needed.
+ *
+ * As an example, consider the com.delphix:async_destroy feature. This feature
+ * relies on the existence of a bptree in the MOS that store blocks for
+ * asynchronous freeing. This bptree is not created when async_destroy is
+ * enabled. Instead, when a dataset is destroyed spa_feature_is_enabled() is
+ * called to check if async_destroy is enabled. If it is and the bptree object
+ * does not exist yet, the bptree object is created as part of the dataset
+ * destroy and async_destroy's reference count is incremented to indicate it
+ * has made an on-disk format change. Later, after the destroyed dataset's
+ * blocks have all been asynchronously freed there is no longer any use for the
+ * bptree object, so it is destroyed and async_destroy's reference count is
+ * decremented back to 0 to indicate that it has undone its on-disk format
+ * changes.
+ */
+
+typedef enum {
+ FEATURE_ACTION_ENABLE,
+ FEATURE_ACTION_INCR,
+ FEATURE_ACTION_DECR,
+} feature_action_t;
+
+/*
+ * Checks that the features active in the specified object are supported by
+ * this software. Adds each unsupported feature (name -> description) to
+ * the supplied nvlist.
+ */
+boolean_t
+feature_is_supported(objset_t *os, uint64_t obj, uint64_t desc_obj,
+ nvlist_t *unsup_feat, nvlist_t *enabled_feat)
+{
+ boolean_t supported;
+ zap_cursor_t zc;
+ zap_attribute_t za;
+
+ supported = B_TRUE;
+ for (zap_cursor_init(&zc, os, obj);
+ zap_cursor_retrieve(&zc, &za) == 0;
+ zap_cursor_advance(&zc)) {
+ ASSERT(za.za_integer_length == sizeof (uint64_t) &&
+ za.za_num_integers == 1);
+
+ if (NULL != enabled_feat) {
+ fnvlist_add_uint64(enabled_feat, za.za_name,
+ za.za_first_integer);
+ }
+
+ if (za.za_first_integer != 0 &&
+ !zfeature_is_supported(za.za_name)) {
+ supported = B_FALSE;
+
+ if (NULL != unsup_feat) {
+ char *desc = "";
+ char buf[MAXPATHLEN];
+
+ if (zap_lookup(os, desc_obj, za.za_name,
+ 1, sizeof (buf), buf) == 0)
+ desc = buf;
+
+ VERIFY(nvlist_add_string(unsup_feat, za.za_name,
+ desc) == 0);
+ }
+ }
+ }
+ zap_cursor_fini(&zc);
+
+ return (supported);
+}
+
+static int
+feature_get_refcount(objset_t *os, uint64_t read_obj, uint64_t write_obj,
+ zfeature_info_t *feature, uint64_t *res)
+{
+ int err;
+ uint64_t refcount;
+ uint64_t zapobj = feature->fi_can_readonly ? write_obj : read_obj;
+
+ ASSERT(0 != zapobj);
+
+ err = zap_lookup(os, zapobj, feature->fi_guid, sizeof (uint64_t), 1,
+ &refcount);
+ if (err != 0) {
+ if (err == ENOENT)
+ return (ENOTSUP);
+ else
+ return (err);
+ }
+ *res = refcount;
+ return (0);
+}
+
+static int
+feature_do_action(objset_t *os, uint64_t read_obj, uint64_t write_obj,
+ uint64_t desc_obj, zfeature_info_t *feature, feature_action_t action,
+ dmu_tx_t *tx)
+{
+ int error;
+ uint64_t refcount;
+ uint64_t zapobj = feature->fi_can_readonly ? write_obj : read_obj;
+
+ ASSERT(0 != zapobj);
+ ASSERT(zfeature_is_valid_guid(feature->fi_guid));
+
+ error = zap_lookup(os, zapobj, feature->fi_guid,
+ sizeof (uint64_t), 1, &refcount);
+
+ /*
+ * If we can't ascertain the status of the specified feature, an I/O
+ * error occurred.
+ */
+ if (error != 0 && error != ENOENT)
+ return (error);
+
+ switch (action) {
+ case FEATURE_ACTION_ENABLE:
+ /*
+ * If the feature is already enabled, ignore the request.
+ */
+ if (error == 0)
+ return (0);
+ refcount = 0;
+ break;
+ case FEATURE_ACTION_INCR:
+ if (error == ENOENT)
+ return (ENOTSUP);
+ if (refcount == UINT64_MAX)
+ return (EOVERFLOW);
+ refcount++;
+ break;
+ case FEATURE_ACTION_DECR:
+ if (error == ENOENT)
+ return (ENOTSUP);
+ if (refcount == 0)
+ return (EOVERFLOW);
+ refcount--;
+ break;
+ default:
+ ASSERT(0);
+ break;
+ }
+
+ if (action == FEATURE_ACTION_ENABLE) {
+ int i;
+
+ for (i = 0; feature->fi_depends[i] != NULL; i++) {
+ zfeature_info_t *dep = feature->fi_depends[i];
+
+ error = feature_do_action(os, read_obj, write_obj,
+ desc_obj, dep, FEATURE_ACTION_ENABLE, tx);
+ if (error != 0)
+ return (error);
+ }
+ }
+
+ error = zap_update(os, zapobj, feature->fi_guid,
+ sizeof (uint64_t), 1, &refcount, tx);
+ if (error != 0)
+ return (error);
+
+ if (action == FEATURE_ACTION_ENABLE) {
+ error = zap_update(os, desc_obj,
+ feature->fi_guid, 1, strlen(feature->fi_desc) + 1,
+ feature->fi_desc, tx);
+ if (error != 0)
+ return (error);
+ }
+
+ if (action == FEATURE_ACTION_INCR && refcount == 1 && feature->fi_mos) {
+ spa_activate_mos_feature(dmu_objset_spa(os), feature->fi_guid);
+ }
+
+ if (action == FEATURE_ACTION_DECR && refcount == 0) {
+ spa_deactivate_mos_feature(dmu_objset_spa(os),
+ feature->fi_guid);
+ }
+
+ return (0);
+}
+
+void
+spa_feature_create_zap_objects(spa_t *spa, dmu_tx_t *tx)
+{
+ /*
+ * We create feature flags ZAP objects in two instances: during pool
+ * creation and during pool upgrade.
+ */
+ ASSERT(dsl_pool_sync_context(spa_get_dsl(spa)) || (!spa->spa_sync_on &&
+ tx->tx_txg == TXG_INITIAL));
+
+ spa->spa_feat_for_read_obj = zap_create_link(spa->spa_meta_objset,
+ DMU_OTN_ZAP_METADATA, DMU_POOL_DIRECTORY_OBJECT,
+ DMU_POOL_FEATURES_FOR_READ, tx);
+ spa->spa_feat_for_write_obj = zap_create_link(spa->spa_meta_objset,
+ DMU_OTN_ZAP_METADATA, DMU_POOL_DIRECTORY_OBJECT,
+ DMU_POOL_FEATURES_FOR_WRITE, tx);
+ spa->spa_feat_desc_obj = zap_create_link(spa->spa_meta_objset,
+ DMU_OTN_ZAP_METADATA, DMU_POOL_DIRECTORY_OBJECT,
+ DMU_POOL_FEATURE_DESCRIPTIONS, tx);
+}
+
+/*
+ * Enable any required dependencies, then enable the requested feature.
+ */
+void
+spa_feature_enable(spa_t *spa, zfeature_info_t *feature, dmu_tx_t *tx)
+{
+ ASSERT3U(spa_version(spa), >=, SPA_VERSION_FEATURES);
+ VERIFY3U(0, ==, feature_do_action(spa->spa_meta_objset,
+ spa->spa_feat_for_read_obj, spa->spa_feat_for_write_obj,
+ spa->spa_feat_desc_obj, feature, FEATURE_ACTION_ENABLE, tx));
+}
+
+/*
+ * If the specified feature has not yet been enabled, this function returns
+ * ENOTSUP; otherwise, this function increments the feature's refcount (or
+ * returns EOVERFLOW if the refcount cannot be incremented). This function must
+ * be called from syncing context.
+ */
+void
+spa_feature_incr(spa_t *spa, zfeature_info_t *feature, dmu_tx_t *tx)
+{
+ ASSERT3U(spa_version(spa), >=, SPA_VERSION_FEATURES);
+ VERIFY3U(0, ==, feature_do_action(spa->spa_meta_objset,
+ spa->spa_feat_for_read_obj, spa->spa_feat_for_write_obj,
+ spa->spa_feat_desc_obj, feature, FEATURE_ACTION_INCR, tx));
+}
+
+/*
+ * If the specified feature has not yet been enabled, this function returns
+ * ENOTSUP; otherwise, this function decrements the feature's refcount (or
+ * returns EOVERFLOW if the refcount is already 0). This function must
+ * be called from syncing context.
+ */
+void
+spa_feature_decr(spa_t *spa, zfeature_info_t *feature, dmu_tx_t *tx)
+{
+ ASSERT3U(spa_version(spa), >=, SPA_VERSION_FEATURES);
+ VERIFY3U(0, ==, feature_do_action(spa->spa_meta_objset,
+ spa->spa_feat_for_read_obj, spa->spa_feat_for_write_obj,
+ spa->spa_feat_desc_obj, feature, FEATURE_ACTION_DECR, tx));
+}
+
+boolean_t
+spa_feature_is_enabled(spa_t *spa, zfeature_info_t *feature)
+{
+ int err;
+ uint64_t refcount;
+
+ if (spa_version(spa) < SPA_VERSION_FEATURES)
+ return (B_FALSE);
+
+ err = feature_get_refcount(spa->spa_meta_objset,
+ spa->spa_feat_for_read_obj, spa->spa_feat_for_write_obj,
+ feature, &refcount);
+ ASSERT(err == 0 || err == ENOTSUP);
+ return (err == 0);
+}
+
+boolean_t
+spa_feature_is_active(spa_t *spa, zfeature_info_t *feature)
+{
+ int err;
+ uint64_t refcount;
+
+ if (spa_version(spa) < SPA_VERSION_FEATURES)
+ return (B_FALSE);
+
+ err = feature_get_refcount(spa->spa_meta_objset,
+ spa->spa_feat_for_read_obj, spa->spa_feat_for_write_obj,
+ feature, &refcount);
+ ASSERT(err == 0 || err == ENOTSUP);
+ return (err == 0 && refcount > 0);
+}
diff --git a/usr/src/uts/common/fs/zfs/zfs_ctldir.c b/usr/src/uts/common/fs/zfs/zfs_ctldir.c
index 815f8895e7..d902ff637c 100644
--- a/usr/src/uts/common/fs/zfs/zfs_ctldir.c
+++ b/usr/src/uts/common/fs/zfs/zfs_ctldir.c
@@ -20,6 +20,7 @@
*/
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012 by Delphix. All rights reserved.
*/
/*
@@ -749,8 +750,7 @@ zfsctl_snapdir_mkdir(vnode_t *dvp, char *dirname, vattr_t *vap, vnode_t **vpp,
return (err);
if (err == 0) {
- err = dmu_objset_snapshot(name, dirname, NULL, NULL,
- B_FALSE, B_FALSE, -1);
+ err = dmu_objset_snapshot_one(name, dirname);
if (err)
return (err);
err = lookupnameat(dirname, seg, follow, NULL, vpp, dvp);
diff --git a/usr/src/uts/common/fs/zfs/zfs_ioctl.c b/usr/src/uts/common/fs/zfs/zfs_ioctl.c
index f2bf4fc98f..e4cca4a2c7 100644
--- a/usr/src/uts/common/fs/zfs/zfs_ioctl.c
+++ b/usr/src/uts/common/fs/zfs/zfs_ioctl.c
@@ -18,14 +18,117 @@
*
* CDDL HEADER END
*/
+
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* Portions Copyright 2011 Martin Matuska
* Copyright 2011 Nexenta Systems, Inc. All rights reserved.
+ * Copyright (c) 2012, Joyent, Inc. All rights reserved.
* Copyright (c) 2012 by Delphix. All rights reserved.
* Copyright (c) 2012, Joyent, Inc. All rights reserved.
*/
+/*
+ * ZFS ioctls.
+ *
+ * This file handles the ioctls to /dev/zfs, used for configuring ZFS storage
+ * pools and filesystems, e.g. with /sbin/zfs and /sbin/zpool.
+ *
+ * There are two ways that we handle ioctls: the legacy way where almost
+ * all of the logic is in the ioctl callback, and the new way where most
+ * of the marshalling is handled in the common entry point, zfsdev_ioctl().
+ *
+ * Non-legacy ioctls should be registered by calling
+ * zfs_ioctl_register() from zfs_ioctl_init(). The ioctl is invoked
+ * from userland by lzc_ioctl().
+ *
+ * The registration arguments are as follows:
+ *
+ * const char *name
+ * The name of the ioctl. This is used for history logging. If the
+ * ioctl returns successfully (the callback returns 0), and allow_log
+ * is true, then a history log entry will be recorded with the input &
+ * output nvlists. The log entry can be printed with "zpool history -i".
+ *
+ * zfs_ioc_t ioc
+ * The ioctl request number, which userland will pass to ioctl(2).
+ * The ioctl numbers can change from release to release, because
+ * the caller (libzfs) must be matched to the kernel.
+ *
+ * zfs_secpolicy_func_t *secpolicy
+ * This function will be called before the zfs_ioc_func_t, to
+ * determine if this operation is permitted. It should return EPERM
+ * on failure, and 0 on success. Checks include determining if the
+ * dataset is visible in this zone, and if the user has either all
+ * zfs privileges in the zone (SYS_MOUNT), or has been granted permission
+ * to do this operation on this dataset with "zfs allow".
+ *
+ * zfs_ioc_namecheck_t namecheck
+ * This specifies what to expect in the zfs_cmd_t:zc_name -- a pool
+ * name, a dataset name, or nothing. If the name is not well-formed,
+ * the ioctl will fail and the callback will not be called.
+ * Therefore, the callback can assume that the name is well-formed
+ * (e.g. is null-terminated, doesn't have more than one '@' character,
+ * doesn't have invalid characters).
+ *
+ * zfs_ioc_poolcheck_t pool_check
+ * This specifies requirements on the pool state. If the pool does
+ * not meet them (is suspended or is readonly), the ioctl will fail
+ * and the callback will not be called. If any checks are specified
+ * (i.e. it is not POOL_CHECK_NONE), namecheck must not be NO_NAME.
+ * Multiple checks can be or-ed together (e.g. POOL_CHECK_SUSPENDED |
+ * POOL_CHECK_READONLY).
+ *
+ * boolean_t smush_outnvlist
+ * If smush_outnvlist is true, then the output is presumed to be a
+ * list of errors, and it will be "smushed" down to fit into the
+ * caller's buffer, by removing some entries and replacing them with a
+ * single "N_MORE_ERRORS" entry indicating how many were removed. See
+ * nvlist_smush() for details. If smush_outnvlist is false, and the
+ * outnvlist does not fit into the userland-provided buffer, then the
+ * ioctl will fail with ENOMEM.
+ *
+ * zfs_ioc_func_t *func
+ * The callback function that will perform the operation.
+ *
+ * The callback should return 0 on success, or an error number on
+ * failure. If the function fails, the userland ioctl will return -1,
+ * and errno will be set to the callback's return value. The callback
+ * will be called with the following arguments:
+ *
+ * const char *name
+ * The name of the pool or dataset to operate on, from
+ * zfs_cmd_t:zc_name. The 'namecheck' argument specifies the
+ * expected type (pool, dataset, or none).
+ *
+ * nvlist_t *innvl
+ * The input nvlist, deserialized from zfs_cmd_t:zc_nvlist_src. Or
+ * NULL if no input nvlist was provided. Changes to this nvlist are
+ * ignored. If the input nvlist could not be deserialized, the
+ * ioctl will fail and the callback will not be called.
+ *
+ * nvlist_t *outnvl
+ * The output nvlist, initially empty. The callback can fill it in,
+ * and it will be returned to userland by serializing it into
+ * zfs_cmd_t:zc_nvlist_dst. If it is non-empty, and serialization
+ * fails (e.g. because the caller didn't supply a large enough
+ * buffer), then the overall ioctl will fail. See the
+ * 'smush_nvlist' argument above for additional behaviors.
+ *
+ * There are two typical uses of the output nvlist:
+ * - To return state, e.g. property values. In this case,
+ * smush_outnvlist should be false. If the buffer was not large
+ * enough, the caller will reallocate a larger buffer and try
+ * the ioctl again.
+ *
+ * - To return multiple errors from an ioctl which makes on-disk
+ * changes. In this case, smush_outnvlist should be true.
+ * Ioctls which make on-disk modifications should generally not
+ * use the outnvl if they succeed, because the caller can not
+ * distinguish between the operation failing, and
+ * deserialization failing.
+ */
+
#include <sys/types.h>
#include <sys/param.h>
#include <sys/errno.h>
@@ -52,6 +155,7 @@
#include <sys/dsl_prop.h>
#include <sys/dsl_deleg.h>
#include <sys/dmu_objset.h>
+#include <sys/dmu_impl.h>
#include <sys/ddi.h>
#include <sys/sunddi.h>
#include <sys/sunldi.h>
@@ -83,8 +187,13 @@ extern void zfs_fini(void);
ldi_ident_t zfs_li = NULL;
dev_info_t *zfs_dip;
-typedef int zfs_ioc_func_t(zfs_cmd_t *);
-typedef int zfs_secpolicy_func_t(zfs_cmd_t *, cred_t *);
+uint_t zfs_fsyncer_key;
+extern uint_t rrw_tsd_key;
+static uint_t zfs_allow_log_key;
+
+typedef int zfs_ioc_legacy_func_t(zfs_cmd_t *);
+typedef int zfs_ioc_func_t(const char *, nvlist_t *, nvlist_t *);
+typedef int zfs_secpolicy_func_t(zfs_cmd_t *, nvlist_t *, cred_t *);
typedef enum {
NO_NAME,
@@ -95,15 +204,18 @@ typedef enum {
typedef enum {
POOL_CHECK_NONE = 1 << 0,
POOL_CHECK_SUSPENDED = 1 << 1,
- POOL_CHECK_READONLY = 1 << 2
+ POOL_CHECK_READONLY = 1 << 2,
} zfs_ioc_poolcheck_t;
typedef struct zfs_ioc_vec {
+ zfs_ioc_legacy_func_t *zvec_legacy_func;
zfs_ioc_func_t *zvec_func;
zfs_secpolicy_func_t *zvec_secpolicy;
zfs_ioc_namecheck_t zvec_namecheck;
- boolean_t zvec_his_log;
+ boolean_t zvec_allow_log;
zfs_ioc_poolcheck_t zvec_pool_check;
+ boolean_t zvec_smush_outnvlist;
+ const char *zvec_name;
} zfs_ioc_vec_t;
/* This array is indexed by zfs_userquota_prop_t */
@@ -121,7 +233,8 @@ static int zfs_check_clearable(char *dataset, nvlist_t *props,
nvlist_t **errors);
static int zfs_fill_zplprops_root(uint64_t, nvlist_t *, nvlist_t *,
boolean_t *);
-int zfs_set_prop_nvlist(const char *, zprop_source_t, nvlist_t *, nvlist_t **);
+int zfs_set_prop_nvlist(const char *, zprop_source_t, nvlist_t *, nvlist_t *);
+static int get_nvlist(uint64_t nvl, uint64_t size, int iflag, nvlist_t **nvp);
/* _NOTE(PRINTFLIKE(4)) - this is printf-like, but lint is too whiney */
void
@@ -259,7 +372,7 @@ zfs_log_history(zfs_cmd_t *zc)
if (spa_open(zc->zc_name, &spa, FTAG) == 0) {
if (spa_version(spa) >= SPA_VERSION_ZPOOL_HISTORY)
- (void) spa_history_log(spa, buf, LOG_CMD_NORMAL);
+ (void) spa_history_log(spa, buf);
spa_close(spa, FTAG);
}
history_str_free(buf);
@@ -271,7 +384,7 @@ zfs_log_history(zfs_cmd_t *zc)
*/
/* ARGSUSED */
static int
-zfs_secpolicy_none(zfs_cmd_t *zc, cred_t *cr)
+zfs_secpolicy_none(zfs_cmd_t *zc, nvlist_t *innvl, cred_t *cr)
{
return (0);
}
@@ -282,7 +395,7 @@ zfs_secpolicy_none(zfs_cmd_t *zc, cred_t *cr)
*/
/* ARGSUSED */
static int
-zfs_secpolicy_read(zfs_cmd_t *zc, cred_t *cr)
+zfs_secpolicy_read(zfs_cmd_t *zc, nvlist_t *innvl, cred_t *cr)
{
if (INGLOBALZONE(curproc) ||
zone_dataset_visible(zc->zc_name, NULL))
@@ -351,26 +464,13 @@ zfs_dozonecheck_ds(const char *dataset, dsl_dataset_t *ds, cred_t *cr)
return (zfs_dozonecheck_impl(dataset, zoned, cr));
}
-/*
- * If name ends in a '@', then require recursive permissions.
- */
-int
+static int
zfs_secpolicy_write_perms(const char *name, const char *perm, cred_t *cr)
{
int error;
- boolean_t descendent = B_FALSE;
dsl_dataset_t *ds;
- char *at;
-
- at = strchr(name, '@');
- if (at != NULL && at[1] == '\0') {
- *at = '\0';
- descendent = B_TRUE;
- }
error = dsl_dataset_hold(name, FTAG, &ds);
- if (at != NULL)
- *at = '@';
if (error != 0)
return (error);
@@ -378,14 +478,14 @@ zfs_secpolicy_write_perms(const char *name, const char *perm, cred_t *cr)
if (error == 0) {
error = secpolicy_zfs(cr);
if (error)
- error = dsl_deleg_access_impl(ds, descendent, perm, cr);
+ error = dsl_deleg_access_impl(ds, perm, cr);
}
dsl_dataset_rele(ds, FTAG);
return (error);
}
-int
+static int
zfs_secpolicy_write_perms_ds(const char *name, dsl_dataset_t *ds,
const char *perm, cred_t *cr)
{
@@ -395,7 +495,7 @@ zfs_secpolicy_write_perms_ds(const char *name, dsl_dataset_t *ds,
if (error == 0) {
error = secpolicy_zfs(cr);
if (error)
- error = dsl_deleg_access_impl(ds, B_FALSE, perm, cr);
+ error = dsl_deleg_access_impl(ds, perm, cr);
}
return (error);
}
@@ -549,8 +649,9 @@ zfs_secpolicy_setprop(const char *dsname, zfs_prop_t prop, nvpair_t *propval,
return (zfs_secpolicy_write_perms(dsname, zfs_prop_to_name(prop), cr));
}
-int
-zfs_secpolicy_fsacl(zfs_cmd_t *zc, cred_t *cr)
+/* ARGSUSED */
+static int
+zfs_secpolicy_set_fsacl(zfs_cmd_t *zc, nvlist_t *innvl, cred_t *cr)
{
int error;
@@ -565,15 +666,17 @@ zfs_secpolicy_fsacl(zfs_cmd_t *zc, cred_t *cr)
return (0);
}
-int
-zfs_secpolicy_rollback(zfs_cmd_t *zc, cred_t *cr)
+/* ARGSUSED */
+static int
+zfs_secpolicy_rollback(zfs_cmd_t *zc, nvlist_t *innvl, cred_t *cr)
{
return (zfs_secpolicy_write_perms(zc->zc_name,
ZFS_DELEG_PERM_ROLLBACK, cr));
}
-int
-zfs_secpolicy_send(zfs_cmd_t *zc, cred_t *cr)
+/* ARGSUSED */
+static int
+zfs_secpolicy_send(zfs_cmd_t *zc, nvlist_t *innvl, cred_t *cr)
{
spa_t *spa;
dsl_pool_t *dp;
@@ -609,8 +712,17 @@ zfs_secpolicy_send(zfs_cmd_t *zc, cred_t *cr)
return (error);
}
+/* ARGSUSED */
+static int
+zfs_secpolicy_send_new(zfs_cmd_t *zc, nvlist_t *innvl, cred_t *cr)
+{
+ return (zfs_secpolicy_write_perms(zc->zc_name,
+ ZFS_DELEG_PERM_SEND, cr));
+}
+
+/* ARGSUSED */
static int
-zfs_secpolicy_deleg_share(zfs_cmd_t *zc, cred_t *cr)
+zfs_secpolicy_deleg_share(zfs_cmd_t *zc, nvlist_t *innvl, cred_t *cr)
{
vnode_t *vp;
int error;
@@ -634,7 +746,7 @@ zfs_secpolicy_deleg_share(zfs_cmd_t *zc, cred_t *cr)
}
int
-zfs_secpolicy_share(zfs_cmd_t *zc, cred_t *cr)
+zfs_secpolicy_share(zfs_cmd_t *zc, nvlist_t *innvl, cred_t *cr)
{
if (!INGLOBALZONE(curproc))
return (EPERM);
@@ -642,12 +754,12 @@ zfs_secpolicy_share(zfs_cmd_t *zc, cred_t *cr)
if (secpolicy_nfs(cr) == 0) {
return (0);
} else {
- return (zfs_secpolicy_deleg_share(zc, cr));
+ return (zfs_secpolicy_deleg_share(zc, innvl, cr));
}
}
int
-zfs_secpolicy_smb_acl(zfs_cmd_t *zc, cred_t *cr)
+zfs_secpolicy_smb_acl(zfs_cmd_t *zc, nvlist_t *innvl, cred_t *cr)
{
if (!INGLOBALZONE(curproc))
return (EPERM);
@@ -655,7 +767,7 @@ zfs_secpolicy_smb_acl(zfs_cmd_t *zc, cred_t *cr)
if (secpolicy_smb(cr) == 0) {
return (0);
} else {
- return (zfs_secpolicy_deleg_share(zc, cr));
+ return (zfs_secpolicy_deleg_share(zc, innvl, cr));
}
}
@@ -693,27 +805,55 @@ zfs_secpolicy_destroy_perms(const char *name, cred_t *cr)
return (zfs_secpolicy_write_perms(name, ZFS_DELEG_PERM_DESTROY, cr));
}
+/* ARGSUSED */
static int
-zfs_secpolicy_destroy(zfs_cmd_t *zc, cred_t *cr)
+zfs_secpolicy_destroy(zfs_cmd_t *zc, nvlist_t *innvl, cred_t *cr)
{
return (zfs_secpolicy_destroy_perms(zc->zc_name, cr));
}
/*
* Destroying snapshots with delegated permissions requires
- * descendent mount and destroy permissions.
+ * descendant mount and destroy permissions.
*/
+/* ARGSUSED */
static int
-zfs_secpolicy_destroy_recursive(zfs_cmd_t *zc, cred_t *cr)
+zfs_secpolicy_destroy_snaps(zfs_cmd_t *zc, nvlist_t *innvl, cred_t *cr)
{
- int error;
- char *dsname;
+ nvlist_t *snaps;
+ nvpair_t *pair, *nextpair;
+ int error = 0;
- dsname = kmem_asprintf("%s@", zc->zc_name);
+ if (nvlist_lookup_nvlist(innvl, "snaps", &snaps) != 0)
+ return (EINVAL);
+ for (pair = nvlist_next_nvpair(snaps, NULL); pair != NULL;
+ pair = nextpair) {
+ dsl_dataset_t *ds;
- error = zfs_secpolicy_destroy_perms(dsname, cr);
+ nextpair = nvlist_next_nvpair(snaps, pair);
+ error = dsl_dataset_hold(nvpair_name(pair), FTAG, &ds);
+ if (error == 0) {
+ dsl_dataset_rele(ds, FTAG);
+ } else if (error == ENOENT) {
+ /*
+ * Ignore any snapshots that don't exist (we consider
+ * them "already destroyed"). Remove the name from the
+ * nvl here in case the snapshot is created between
+ * now and when we try to destroy it (in which case
+ * we don't want to destroy it since we haven't
+ * checked for permission).
+ */
+ fnvlist_remove_nvpair(snaps, pair);
+ error = 0;
+ continue;
+ } else {
+ break;
+ }
+ error = zfs_secpolicy_destroy_perms(nvpair_name(pair), cr);
+ if (error != 0)
+ break;
+ }
- strfree(dsname);
return (error);
}
@@ -746,14 +886,16 @@ zfs_secpolicy_rename_perms(const char *from, const char *to, cred_t *cr)
return (error);
}
+/* ARGSUSED */
static int
-zfs_secpolicy_rename(zfs_cmd_t *zc, cred_t *cr)
+zfs_secpolicy_rename(zfs_cmd_t *zc, nvlist_t *innvl, cred_t *cr)
{
return (zfs_secpolicy_rename_perms(zc->zc_name, zc->zc_value, cr));
}
+/* ARGSUSED */
static int
-zfs_secpolicy_promote(zfs_cmd_t *zc, cred_t *cr)
+zfs_secpolicy_promote(zfs_cmd_t *zc, nvlist_t *innvl, cred_t *cr)
{
char parentname[MAXNAMELEN];
objset_t *clone;
@@ -793,8 +935,9 @@ zfs_secpolicy_promote(zfs_cmd_t *zc, cred_t *cr)
return (error);
}
+/* ARGSUSED */
static int
-zfs_secpolicy_receive(zfs_cmd_t *zc, cred_t *cr)
+zfs_secpolicy_recv(zfs_cmd_t *zc, nvlist_t *innvl, cred_t *cr)
{
int error;
@@ -817,49 +960,72 @@ zfs_secpolicy_snapshot_perms(const char *name, cred_t *cr)
ZFS_DELEG_PERM_SNAPSHOT, cr));
}
+/*
+ * Check for permission to create each snapshot in the nvlist.
+ */
+/* ARGSUSED */
static int
-zfs_secpolicy_snapshot(zfs_cmd_t *zc, cred_t *cr)
+zfs_secpolicy_snapshot(zfs_cmd_t *zc, nvlist_t *innvl, cred_t *cr)
{
+ nvlist_t *snaps;
+ int error;
+ nvpair_t *pair;
- return (zfs_secpolicy_snapshot_perms(zc->zc_name, cr));
+ if (nvlist_lookup_nvlist(innvl, "snaps", &snaps) != 0)
+ return (EINVAL);
+ for (pair = nvlist_next_nvpair(snaps, NULL); pair != NULL;
+ pair = nvlist_next_nvpair(snaps, pair)) {
+ char *name = nvpair_name(pair);
+ char *atp = strchr(name, '@');
+
+ if (atp == NULL) {
+ error = EINVAL;
+ break;
+ }
+ *atp = '\0';
+ error = zfs_secpolicy_snapshot_perms(name, cr);
+ *atp = '@';
+ if (error != 0)
+ break;
+ }
+ return (error);
+}
+
+/* ARGSUSED */
+static int
+zfs_secpolicy_log_history(zfs_cmd_t *zc, nvlist_t *innvl, cred_t *cr)
+{
+ /*
+ * Even root must have a proper TSD so that we know what pool
+ * to log to.
+ */
+ if (tsd_get(zfs_allow_log_key) == NULL)
+ return (EPERM);
+ return (0);
}
static int
-zfs_secpolicy_create(zfs_cmd_t *zc, cred_t *cr)
+zfs_secpolicy_create_clone(zfs_cmd_t *zc, nvlist_t *innvl, cred_t *cr)
{
char parentname[MAXNAMELEN];
int error;
+ char *origin;
if ((error = zfs_get_parent(zc->zc_name, parentname,
sizeof (parentname))) != 0)
return (error);
- if (zc->zc_value[0] != '\0') {
- if ((error = zfs_secpolicy_write_perms(zc->zc_value,
- ZFS_DELEG_PERM_CLONE, cr)) != 0)
- return (error);
- }
+ if (nvlist_lookup_string(innvl, "origin", &origin) == 0 &&
+ (error = zfs_secpolicy_write_perms(origin,
+ ZFS_DELEG_PERM_CLONE, cr)) != 0)
+ return (error);
if ((error = zfs_secpolicy_write_perms(parentname,
ZFS_DELEG_PERM_CREATE, cr)) != 0)
return (error);
- error = zfs_secpolicy_write_perms(parentname,
- ZFS_DELEG_PERM_MOUNT, cr);
-
- return (error);
-}
-
-static int
-zfs_secpolicy_umount(zfs_cmd_t *zc, cred_t *cr)
-{
- int error;
-
- error = secpolicy_fs_unmount(cr, NULL);
- if (error) {
- error = dsl_deleg_access(zc->zc_name, ZFS_DELEG_PERM_MOUNT, cr);
- }
- return (error);
+ return (zfs_secpolicy_write_perms(parentname,
+ ZFS_DELEG_PERM_MOUNT, cr));
}
/*
@@ -868,7 +1034,7 @@ zfs_secpolicy_umount(zfs_cmd_t *zc, cred_t *cr)
*/
/* ARGSUSED */
static int
-zfs_secpolicy_config(zfs_cmd_t *zc, cred_t *cr)
+zfs_secpolicy_config(zfs_cmd_t *zc, nvlist_t *innvl, cred_t *cr)
{
if (secpolicy_sys_config(cr, B_FALSE) != 0)
return (EPERM);
@@ -881,7 +1047,7 @@ zfs_secpolicy_config(zfs_cmd_t *zc, cred_t *cr)
*/
/* ARGSUSED */
static int
-zfs_secpolicy_diff(zfs_cmd_t *zc, cred_t *cr)
+zfs_secpolicy_diff(zfs_cmd_t *zc, nvlist_t *innvl, cred_t *cr)
{
int error;
@@ -897,13 +1063,14 @@ zfs_secpolicy_diff(zfs_cmd_t *zc, cred_t *cr)
*/
/* ARGSUSED */
static int
-zfs_secpolicy_inject(zfs_cmd_t *zc, cred_t *cr)
+zfs_secpolicy_inject(zfs_cmd_t *zc, nvlist_t *innvl, cred_t *cr)
{
return (secpolicy_zinject(cr));
}
+/* ARGSUSED */
static int
-zfs_secpolicy_inherit(zfs_cmd_t *zc, cred_t *cr)
+zfs_secpolicy_inherit_prop(zfs_cmd_t *zc, nvlist_t *innvl, cred_t *cr)
{
zfs_prop_t prop = zfs_name_to_prop(zc->zc_value);
@@ -919,9 +1086,9 @@ zfs_secpolicy_inherit(zfs_cmd_t *zc, cred_t *cr)
}
static int
-zfs_secpolicy_userspace_one(zfs_cmd_t *zc, cred_t *cr)
+zfs_secpolicy_userspace_one(zfs_cmd_t *zc, nvlist_t *innvl, cred_t *cr)
{
- int err = zfs_secpolicy_read(zc, cr);
+ int err = zfs_secpolicy_read(zc, innvl, cr);
if (err)
return (err);
@@ -948,9 +1115,9 @@ zfs_secpolicy_userspace_one(zfs_cmd_t *zc, cred_t *cr)
}
static int
-zfs_secpolicy_userspace_many(zfs_cmd_t *zc, cred_t *cr)
+zfs_secpolicy_userspace_many(zfs_cmd_t *zc, nvlist_t *innvl, cred_t *cr)
{
- int err = zfs_secpolicy_read(zc, cr);
+ int err = zfs_secpolicy_read(zc, innvl, cr);
if (err)
return (err);
@@ -961,22 +1128,25 @@ zfs_secpolicy_userspace_many(zfs_cmd_t *zc, cred_t *cr)
userquota_perms[zc->zc_objset_type], cr));
}
+/* ARGSUSED */
static int
-zfs_secpolicy_userspace_upgrade(zfs_cmd_t *zc, cred_t *cr)
+zfs_secpolicy_userspace_upgrade(zfs_cmd_t *zc, nvlist_t *innvl, cred_t *cr)
{
return (zfs_secpolicy_setprop(zc->zc_name, ZFS_PROP_VERSION,
NULL, cr));
}
+/* ARGSUSED */
static int
-zfs_secpolicy_hold(zfs_cmd_t *zc, cred_t *cr)
+zfs_secpolicy_hold(zfs_cmd_t *zc, nvlist_t *innvl, cred_t *cr)
{
return (zfs_secpolicy_write_perms(zc->zc_name,
ZFS_DELEG_PERM_HOLD, cr));
}
+/* ARGSUSED */
static int
-zfs_secpolicy_release(zfs_cmd_t *zc, cred_t *cr)
+zfs_secpolicy_release(zfs_cmd_t *zc, nvlist_t *innvl, cred_t *cr)
{
return (zfs_secpolicy_write_perms(zc->zc_name,
ZFS_DELEG_PERM_RELEASE, cr));
@@ -986,7 +1156,7 @@ zfs_secpolicy_release(zfs_cmd_t *zc, cred_t *cr)
* Policy for allowing temporary snapshots to be taken or released
*/
static int
-zfs_secpolicy_tmp_snapshot(zfs_cmd_t *zc, cred_t *cr)
+zfs_secpolicy_tmp_snapshot(zfs_cmd_t *zc, nvlist_t *innvl, cred_t *cr)
{
/*
* A temporary snapshot is the same as a snapshot,
@@ -999,13 +1169,13 @@ zfs_secpolicy_tmp_snapshot(zfs_cmd_t *zc, cred_t *cr)
ZFS_DELEG_PERM_DIFF, cr)) == 0)
return (0);
- error = zfs_secpolicy_snapshot(zc, cr);
+ error = zfs_secpolicy_snapshot_perms(zc->zc_name, cr);
if (!error)
- error = zfs_secpolicy_hold(zc, cr);
+ error = zfs_secpolicy_hold(zc, innvl, cr);
if (!error)
- error = zfs_secpolicy_release(zc, cr);
+ error = zfs_secpolicy_release(zc, innvl, cr);
if (!error)
- error = zfs_secpolicy_destroy(zc, cr);
+ error = zfs_secpolicy_destroy(zc, innvl, cr);
return (error);
}
@@ -1044,36 +1214,40 @@ get_nvlist(uint64_t nvl, uint64_t size, int iflag, nvlist_t **nvp)
return (0);
}
+/*
+ * Reduce the size of this nvlist until it can be serialized in 'max' bytes.
+ * Entries will be removed from the end of the nvlist, and one int32 entry
+ * named "N_MORE_ERRORS" will be added indicating how many entries were
+ * removed.
+ */
static int
-fit_error_list(zfs_cmd_t *zc, nvlist_t **errors)
+nvlist_smush(nvlist_t *errors, size_t max)
{
size_t size;
- VERIFY(nvlist_size(*errors, &size, NV_ENCODE_NATIVE) == 0);
+ size = fnvlist_size(errors);
- if (size > zc->zc_nvlist_dst_size) {
+ if (size > max) {
nvpair_t *more_errors;
int n = 0;
- if (zc->zc_nvlist_dst_size < 1024)
+ if (max < 1024)
return (ENOMEM);
- VERIFY(nvlist_add_int32(*errors, ZPROP_N_MORE_ERRORS, 0) == 0);
- more_errors = nvlist_prev_nvpair(*errors, NULL);
+ fnvlist_add_int32(errors, ZPROP_N_MORE_ERRORS, 0);
+ more_errors = nvlist_prev_nvpair(errors, NULL);
do {
- nvpair_t *pair = nvlist_prev_nvpair(*errors,
+ nvpair_t *pair = nvlist_prev_nvpair(errors,
more_errors);
- VERIFY(nvlist_remove_nvpair(*errors, pair) == 0);
+ fnvlist_remove_nvpair(errors, pair);
n++;
- VERIFY(nvlist_size(*errors, &size,
- NV_ENCODE_NATIVE) == 0);
- } while (size > zc->zc_nvlist_dst_size);
+ size = fnvlist_size(errors);
+ } while (size > max);
- VERIFY(nvlist_remove_nvpair(*errors, more_errors) == 0);
- VERIFY(nvlist_add_int32(*errors, ZPROP_N_MORE_ERRORS, n) == 0);
- ASSERT(nvlist_size(*errors, &size, NV_ENCODE_NATIVE) == 0);
- ASSERT(size <= zc->zc_nvlist_dst_size);
+ fnvlist_remove_nvpair(errors, more_errors);
+ fnvlist_add_int32(errors, ZPROP_N_MORE_ERRORS, n);
+ ASSERT3U(fnvlist_size(errors), <=, max);
}
return (0);
@@ -1086,21 +1260,20 @@ put_nvlist(zfs_cmd_t *zc, nvlist_t *nvl)
int error = 0;
size_t size;
- VERIFY(nvlist_size(nvl, &size, NV_ENCODE_NATIVE) == 0);
+ size = fnvlist_size(nvl);
if (size > zc->zc_nvlist_dst_size) {
error = ENOMEM;
} else {
- packed = kmem_alloc(size, KM_SLEEP);
- VERIFY(nvlist_pack(nvl, &packed, &size, NV_ENCODE_NATIVE,
- KM_SLEEP) == 0);
+ packed = fnvlist_pack(nvl, &size);
if (ddi_copyout(packed, (void *)(uintptr_t)zc->zc_nvlist_dst,
size, zc->zc_iflags) != 0)
error = EFAULT;
- kmem_free(packed, size);
+ fnvlist_pack_free(packed, size);
}
zc->zc_nvlist_dst_size = size;
+ zc->zc_nvlist_dst_filled = B_TRUE;
return (error);
}
@@ -1133,6 +1306,8 @@ getzfsvfs(const char *dsname, zfsvfs_t **zfvp)
/*
* Find a zfsvfs_t for a mounted filesystem, or create our own, in which
* case its z_vfs will be NULL, and it will be opened as the owner.
+ * If 'writer' is set, the z_teardown_lock will be held for RW_WRITER,
+ * which prevents all vnode ops from running.
*/
static int
zfsvfs_hold(const char *name, void *tag, zfsvfs_t **zfvp, boolean_t writer)
@@ -1177,7 +1352,6 @@ zfs_ioc_pool_create(zfs_cmd_t *zc)
nvlist_t *config, *props = NULL;
nvlist_t *rootprops = NULL;
nvlist_t *zplprops = NULL;
- char *buf;
if (error = get_nvlist(zc->zc_nvlist_conf, zc->zc_nvlist_conf_size,
zc->zc_iflags, &config))
@@ -1196,7 +1370,7 @@ zfs_ioc_pool_create(zfs_cmd_t *zc)
(void) nvlist_lookup_uint64(props,
zpool_prop_to_name(ZPOOL_PROP_VERSION), &version);
- if (version < SPA_VERSION_INITIAL || version > SPA_VERSION) {
+ if (!SPA_VERSION_IS_SUPPORTED(version)) {
error = EINVAL;
goto pool_props_bad;
}
@@ -1217,9 +1391,7 @@ zfs_ioc_pool_create(zfs_cmd_t *zc)
goto pool_props_bad;
}
- buf = history_str_get(zc);
-
- error = spa_create(zc->zc_name, config, props, buf, zplprops);
+ error = spa_create(zc->zc_name, config, props, zplprops);
/*
* Set the remaining root properties
@@ -1228,9 +1400,6 @@ zfs_ioc_pool_create(zfs_cmd_t *zc)
ZPROP_SRC_LOCAL, rootprops, NULL)) != 0)
(void) spa_destroy(zc->zc_name);
- if (buf != NULL)
- history_str_free(buf);
-
pool_props_bad:
nvlist_free(rootprops);
nvlist_free(zplprops);
@@ -1320,6 +1489,15 @@ zfs_ioc_pool_configs(zfs_cmd_t *zc)
return (error);
}
+/*
+ * inputs:
+ * zc_name name of the pool
+ *
+ * outputs:
+ * zc_cookie real errno
+ * zc_nvlist_dst config nvlist
+ * zc_nvlist_dst_size size of config nvlist
+ */
static int
zfs_ioc_pool_stats(zfs_cmd_t *zc)
{
@@ -1421,7 +1599,8 @@ zfs_ioc_pool_upgrade(zfs_cmd_t *zc)
if ((error = spa_open(zc->zc_name, &spa, FTAG)) != 0)
return (error);
- if (zc->zc_cookie < spa_version(spa) || zc->zc_cookie > SPA_VERSION) {
+ if (zc->zc_cookie < spa_version(spa) ||
+ !SPA_VERSION_IS_SUPPORTED(zc->zc_cookie)) {
spa_close(spa, FTAG);
return (EINVAL);
}
@@ -2244,31 +2423,25 @@ zfs_prop_set_special(const char *dsname, zprop_source_t source,
/*
* This function is best effort. If it fails to set any of the given properties,
- * it continues to set as many as it can and returns the first error
- * encountered. If the caller provides a non-NULL errlist, it also gives the
- * complete list of names of all the properties it failed to set along with the
- * corresponding error numbers. The caller is responsible for freeing the
- * returned errlist.
+ * it continues to set as many as it can and returns the last error
+ * encountered. If the caller provides a non-NULL errlist, it will be filled in
+ * with the list of names of all the properties that failed along with the
+ * corresponding error numbers.
*
- * If every property is set successfully, zero is returned and the list pointed
- * at by errlist is NULL.
+ * If every property is set successfully, zero is returned and errlist is not
+ * modified.
*/
int
zfs_set_prop_nvlist(const char *dsname, zprop_source_t source, nvlist_t *nvl,
- nvlist_t **errlist)
+ nvlist_t *errlist)
{
nvpair_t *pair;
nvpair_t *propval;
int rv = 0;
uint64_t intval;
char *strval;
- nvlist_t *genericnvl;
- nvlist_t *errors;
- nvlist_t *retrynvl;
-
- VERIFY(nvlist_alloc(&genericnvl, NV_UNIQUE_NAME, KM_SLEEP) == 0);
- VERIFY(nvlist_alloc(&errors, NV_UNIQUE_NAME, KM_SLEEP) == 0);
- VERIFY(nvlist_alloc(&retrynvl, NV_UNIQUE_NAME, KM_SLEEP) == 0);
+ nvlist_t *genericnvl = fnvlist_alloc();
+ nvlist_t *retrynvl = fnvlist_alloc();
retry:
pair = NULL;
@@ -2281,7 +2454,7 @@ retry:
propval = pair;
if (nvpair_type(pair) == DATA_TYPE_NVLIST) {
nvlist_t *attrs;
- VERIFY(nvpair_value_nvlist(pair, &attrs) == 0);
+ attrs = fnvpair_value_nvlist(pair);
if (nvlist_lookup_nvpair(attrs, ZPROP_VALUE,
&propval) != 0)
err = EINVAL;
@@ -2306,8 +2479,7 @@ retry:
} else if (nvpair_type(propval) == DATA_TYPE_UINT64) {
const char *unused;
- VERIFY(nvpair_value_uint64(propval,
- &intval) == 0);
+ intval = fnvpair_value_uint64(propval);
switch (zfs_prop_get_type(prop)) {
case PROP_TYPE_NUMBER:
@@ -2351,8 +2523,11 @@ retry:
}
}
- if (err != 0)
- VERIFY(nvlist_add_int32(errors, propname, err) == 0);
+ if (err != 0) {
+ if (errlist != NULL)
+ fnvlist_add_int32(errlist, propname, err);
+ rv = err;
+ }
}
if (nvl != retrynvl && !nvlist_empty(retrynvl)) {
@@ -2374,44 +2549,33 @@ retry:
propval = pair;
if (nvpair_type(pair) == DATA_TYPE_NVLIST) {
nvlist_t *attrs;
- VERIFY(nvpair_value_nvlist(pair, &attrs) == 0);
- VERIFY(nvlist_lookup_nvpair(attrs, ZPROP_VALUE,
- &propval) == 0);
+ attrs = fnvpair_value_nvlist(pair);
+ propval = fnvlist_lookup_nvpair(attrs,
+ ZPROP_VALUE);
}
if (nvpair_type(propval) == DATA_TYPE_STRING) {
- VERIFY(nvpair_value_string(propval,
- &strval) == 0);
+ strval = fnvpair_value_string(propval);
err = dsl_prop_set(dsname, propname, source, 1,
strlen(strval) + 1, strval);
} else {
- VERIFY(nvpair_value_uint64(propval,
- &intval) == 0);
+ intval = fnvpair_value_uint64(propval);
err = dsl_prop_set(dsname, propname, source, 8,
1, &intval);
}
if (err != 0) {
- VERIFY(nvlist_add_int32(errors, propname,
- err) == 0);
+ if (errlist != NULL) {
+ fnvlist_add_int32(errlist, propname,
+ err);
+ }
+ rv = err;
}
}
}
nvlist_free(genericnvl);
nvlist_free(retrynvl);
- if ((pair = nvlist_next_nvpair(errors, NULL)) == NULL) {
- nvlist_free(errors);
- errors = NULL;
- } else {
- VERIFY(nvpair_value_int32(pair, &rv) == 0);
- }
-
- if (errlist == NULL)
- nvlist_free(errors);
- else
- *errlist = errors;
-
return (rv);
}
@@ -2419,7 +2583,7 @@ retry:
* Check that all the properties are valid user properties.
*/
static int
-zfs_check_userprops(char *fsname, nvlist_t *nvl)
+zfs_check_userprops(const char *fsname, nvlist_t *nvl)
{
nvpair_t *pair = NULL;
int error = 0;
@@ -2499,7 +2663,7 @@ zfs_ioc_set_prop(zfs_cmd_t *zc)
boolean_t received = zc->zc_cookie;
zprop_source_t source = (received ? ZPROP_SRC_RECEIVED :
ZPROP_SRC_LOCAL);
- nvlist_t *errors = NULL;
+ nvlist_t *errors;
int error;
if ((error = get_nvlist(zc->zc_nvlist_src, zc->zc_nvlist_src_size,
@@ -2522,7 +2686,8 @@ zfs_ioc_set_prop(zfs_cmd_t *zc)
}
}
- error = zfs_set_prop_nvlist(zc->zc_name, source, nvl, &errors);
+ errors = fnvlist_alloc();
+ error = zfs_set_prop_nvlist(zc->zc_name, source, nvl, errors);
if (zc->zc_nvlist_dst != NULL && errors != NULL) {
(void) put_nvlist(zc, errors);
@@ -2604,7 +2769,7 @@ zfs_ioc_inherit_prop(zfs_cmd_t *zc)
return (EINVAL);
}
- /* the property name has been validated by zfs_secpolicy_inherit() */
+ /* property name has been validated by zfs_secpolicy_inherit_prop() */
return (dsl_prop_set(zc->zc_name, zc->zc_value, source, 0, 0, NULL));
}
@@ -2951,26 +3116,30 @@ zfs_fill_zplprops_root(uint64_t spa_vers, nvlist_t *createprops,
}
/*
- * inputs:
- * zc_objset_type type of objset to create (fs vs zvol)
- * zc_name name of new objset
- * zc_value name of snapshot to clone from (may be empty)
- * zc_nvlist_src{_size} nvlist of properties to apply
+ * innvl: {
+ * "type" -> dmu_objset_type_t (int32)
+ * (optional) "props" -> { prop -> value }
+ * }
*
- * outputs: none
+ * outnvl: propname -> error code (int32)
*/
static int
-zfs_ioc_create(zfs_cmd_t *zc)
+zfs_ioc_create(const char *fsname, nvlist_t *innvl, nvlist_t *outnvl)
{
- objset_t *clone;
int error = 0;
- zfs_creat_t zct;
+ zfs_creat_t zct = { 0 };
nvlist_t *nvprops = NULL;
void (*cbfunc)(objset_t *os, void *arg, cred_t *cr, dmu_tx_t *tx);
- dmu_objset_type_t type = zc->zc_objset_type;
+ int32_t type32;
+ dmu_objset_type_t type;
+ boolean_t is_insensitive = B_FALSE;
- switch (type) {
+ if (nvlist_lookup_int32(innvl, "type", &type32) != 0)
+ return (EINVAL);
+ type = type32;
+ (void) nvlist_lookup_nvlist(innvl, "props", &nvprops);
+ switch (type) {
case DMU_OST_ZFS:
cbfunc = zfs_create_cb;
break;
@@ -2983,230 +3152,290 @@ zfs_ioc_create(zfs_cmd_t *zc)
cbfunc = NULL;
break;
}
- if (strchr(zc->zc_name, '@') ||
- strchr(zc->zc_name, '%'))
+ if (strchr(fsname, '@') ||
+ strchr(fsname, '%'))
return (EINVAL);
- if (zc->zc_nvlist_src != NULL &&
- (error = get_nvlist(zc->zc_nvlist_src, zc->zc_nvlist_src_size,
- zc->zc_iflags, &nvprops)) != 0)
- return (error);
-
- zct.zct_zplprops = NULL;
zct.zct_props = nvprops;
- if (zc->zc_value[0] != '\0') {
- /*
- * We're creating a clone of an existing snapshot.
- */
- zc->zc_value[sizeof (zc->zc_value) - 1] = '\0';
- if (dataset_namecheck(zc->zc_value, NULL, NULL) != 0) {
- nvlist_free(nvprops);
+ if (cbfunc == NULL)
+ return (EINVAL);
+
+ if (type == DMU_OST_ZVOL) {
+ uint64_t volsize, volblocksize;
+
+ if (nvprops == NULL)
+ return (EINVAL);
+ if (nvlist_lookup_uint64(nvprops,
+ zfs_prop_to_name(ZFS_PROP_VOLSIZE), &volsize) != 0)
return (EINVAL);
- }
- error = dmu_objset_hold(zc->zc_value, FTAG, &clone);
- if (error) {
- nvlist_free(nvprops);
+ if ((error = nvlist_lookup_uint64(nvprops,
+ zfs_prop_to_name(ZFS_PROP_VOLBLOCKSIZE),
+ &volblocksize)) != 0 && error != ENOENT)
+ return (EINVAL);
+
+ if (error != 0)
+ volblocksize = zfs_prop_default_numeric(
+ ZFS_PROP_VOLBLOCKSIZE);
+
+ if ((error = zvol_check_volblocksize(
+ volblocksize)) != 0 ||
+ (error = zvol_check_volsize(volsize,
+ volblocksize)) != 0)
return (error);
- }
+ } else if (type == DMU_OST_ZFS) {
+ int error;
- error = dmu_objset_clone(zc->zc_name, dmu_objset_ds(clone), 0);
- dmu_objset_rele(clone, FTAG);
- if (error) {
- nvlist_free(nvprops);
+ /*
+ * We have to have normalization and
+ * case-folding flags correct when we do the
+ * file system creation, so go figure them out
+ * now.
+ */
+ VERIFY(nvlist_alloc(&zct.zct_zplprops,
+ NV_UNIQUE_NAME, KM_SLEEP) == 0);
+ error = zfs_fill_zplprops(fsname, nvprops,
+ zct.zct_zplprops, &is_insensitive);
+ if (error != 0) {
+ nvlist_free(zct.zct_zplprops);
return (error);
}
- } else {
- boolean_t is_insensitive = B_FALSE;
+ }
- if (cbfunc == NULL) {
- nvlist_free(nvprops);
- return (EINVAL);
- }
+ error = dmu_objset_create(fsname, type,
+ is_insensitive ? DS_FLAG_CI_DATASET : 0, cbfunc, &zct);
+ nvlist_free(zct.zct_zplprops);
- if (type == DMU_OST_ZVOL) {
- uint64_t volsize, volblocksize;
+ /*
+ * It would be nice to do this atomically.
+ */
+ if (error == 0) {
+ error = zfs_set_prop_nvlist(fsname, ZPROP_SRC_LOCAL,
+ nvprops, outnvl);
+ if (error != 0)
+ (void) dmu_objset_destroy(fsname, B_FALSE);
+ }
+ return (error);
+}
- if (nvprops == NULL ||
- nvlist_lookup_uint64(nvprops,
- zfs_prop_to_name(ZFS_PROP_VOLSIZE),
- &volsize) != 0) {
- nvlist_free(nvprops);
- return (EINVAL);
- }
+/*
+ * innvl: {
+ * "origin" -> name of origin snapshot
+ * (optional) "props" -> { prop -> value }
+ * }
+ *
+ * outnvl: propname -> error code (int32)
+ */
+static int
+zfs_ioc_clone(const char *fsname, nvlist_t *innvl, nvlist_t *outnvl)
+{
+ int error = 0;
+ nvlist_t *nvprops = NULL;
+ char *origin_name;
+ dsl_dataset_t *origin;
- if ((error = nvlist_lookup_uint64(nvprops,
- zfs_prop_to_name(ZFS_PROP_VOLBLOCKSIZE),
- &volblocksize)) != 0 && error != ENOENT) {
- nvlist_free(nvprops);
- return (EINVAL);
- }
+ if (nvlist_lookup_string(innvl, "origin", &origin_name) != 0)
+ return (EINVAL);
+ (void) nvlist_lookup_nvlist(innvl, "props", &nvprops);
- if (error != 0)
- volblocksize = zfs_prop_default_numeric(
- ZFS_PROP_VOLBLOCKSIZE);
+ if (strchr(fsname, '@') ||
+ strchr(fsname, '%'))
+ return (EINVAL);
- if ((error = zvol_check_volblocksize(
- volblocksize)) != 0 ||
- (error = zvol_check_volsize(volsize,
- volblocksize)) != 0) {
- nvlist_free(nvprops);
- return (error);
- }
- } else if (type == DMU_OST_ZFS) {
- int error;
+ if (dataset_namecheck(origin_name, NULL, NULL) != 0)
+ return (EINVAL);
- /*
- * We have to have normalization and
- * case-folding flags correct when we do the
- * file system creation, so go figure them out
- * now.
- */
- VERIFY(nvlist_alloc(&zct.zct_zplprops,
- NV_UNIQUE_NAME, KM_SLEEP) == 0);
- error = zfs_fill_zplprops(zc->zc_name, nvprops,
- zct.zct_zplprops, &is_insensitive);
- if (error != 0) {
- nvlist_free(nvprops);
- nvlist_free(zct.zct_zplprops);
- return (error);
- }
- }
- error = dmu_objset_create(zc->zc_name, type,
- is_insensitive ? DS_FLAG_CI_DATASET : 0, cbfunc, &zct);
- nvlist_free(zct.zct_zplprops);
- }
+ error = dsl_dataset_hold(origin_name, FTAG, &origin);
+ if (error)
+ return (error);
+
+ error = dmu_objset_clone(fsname, origin, 0);
+ dsl_dataset_rele(origin, FTAG);
+ if (error)
+ return (error);
/*
* It would be nice to do this atomically.
*/
if (error == 0) {
- error = zfs_set_prop_nvlist(zc->zc_name, ZPROP_SRC_LOCAL,
- nvprops, NULL);
+ error = zfs_set_prop_nvlist(fsname, ZPROP_SRC_LOCAL,
+ nvprops, outnvl);
if (error != 0)
- (void) dmu_objset_destroy(zc->zc_name, B_FALSE);
+ (void) dmu_objset_destroy(fsname, B_FALSE);
}
- nvlist_free(nvprops);
return (error);
}
/*
- * inputs:
- * zc_name name of filesystem
- * zc_value short name of snapshot
- * zc_cookie recursive flag
- * zc_nvlist_src[_size] property list
+ * innvl: {
+ * "snaps" -> { snapshot1, snapshot2 }
+ * (optional) "props" -> { prop -> value (string) }
+ * }
+ *
+ * outnvl: snapshot -> error code (int32)
*
- * outputs:
- * zc_value short snapname (i.e. part after the '@')
*/
static int
-zfs_ioc_snapshot(zfs_cmd_t *zc)
+zfs_ioc_snapshot(const char *poolname, nvlist_t *innvl, nvlist_t *outnvl)
{
- nvlist_t *nvprops = NULL;
- int error;
- boolean_t recursive = zc->zc_cookie;
+ nvlist_t *snaps;
+ nvlist_t *props = NULL;
+ int error, poollen;
+ nvpair_t *pair;
- if (snapshot_namecheck(zc->zc_value, NULL, NULL) != 0)
+ (void) nvlist_lookup_nvlist(innvl, "props", &props);
+ if ((error = zfs_check_userprops(poolname, props)) != 0)
+ return (error);
+
+ if (!nvlist_empty(props) &&
+ zfs_earlier_version(poolname, SPA_VERSION_SNAP_PROPS))
+ return (ENOTSUP);
+
+ if (nvlist_lookup_nvlist(innvl, "snaps", &snaps) != 0)
return (EINVAL);
+ poollen = strlen(poolname);
+ for (pair = nvlist_next_nvpair(snaps, NULL); pair != NULL;
+ pair = nvlist_next_nvpair(snaps, pair)) {
+ const char *name = nvpair_name(pair);
+ const char *cp = strchr(name, '@');
- if (zc->zc_nvlist_src != NULL &&
- (error = get_nvlist(zc->zc_nvlist_src, zc->zc_nvlist_src_size,
- zc->zc_iflags, &nvprops)) != 0)
- return (error);
+ /*
+ * The snap name must contain an @, and the part after it must
+ * contain only valid characters.
+ */
+ if (cp == NULL || snapshot_namecheck(cp + 1, NULL, NULL) != 0)
+ return (EINVAL);
- error = zfs_check_userprops(zc->zc_name, nvprops);
- if (error)
- goto out;
+ /*
+ * The snap must be in the specified pool.
+ */
+ if (strncmp(name, poolname, poollen) != 0 ||
+ (name[poollen] != '/' && name[poollen] != '@'))
+ return (EXDEV);
+
+ /* This must be the only snap of this fs. */
+ for (nvpair_t *pair2 = nvlist_next_nvpair(snaps, pair);
+ pair2 != NULL; pair2 = nvlist_next_nvpair(snaps, pair2)) {
+ if (strncmp(name, nvpair_name(pair2), cp - name + 1)
+ == 0) {
+ return (EXDEV);
+ }
+ }
+ }
- if (!nvlist_empty(nvprops) &&
- zfs_earlier_version(zc->zc_name, SPA_VERSION_SNAP_PROPS)) {
- error = ENOTSUP;
- goto out;
+ error = dmu_objset_snapshot(snaps, props, outnvl);
+ return (error);
+}
+
+/*
+ * innvl: "message" -> string
+ */
+/* ARGSUSED */
+static int
+zfs_ioc_log_history(const char *unused, nvlist_t *innvl, nvlist_t *outnvl)
+{
+ char *message;
+ spa_t *spa;
+ int error;
+ char *poolname;
+
+ /*
+ * The poolname in the ioctl is not set, we get it from the TSD,
+ * which was set at the end of the last successful ioctl that allows
+ * logging. The secpolicy func already checked that it is set.
+ * Only one log ioctl is allowed after each successful ioctl, so
+ * we clear the TSD here.
+ */
+ poolname = tsd_get(zfs_allow_log_key);
+ (void) tsd_set(zfs_allow_log_key, NULL);
+ error = spa_open(poolname, &spa, FTAG);
+ strfree(poolname);
+ if (error != 0)
+ return (error);
+
+ if (nvlist_lookup_string(innvl, "message", &message) != 0) {
+ spa_close(spa, FTAG);
+ return (EINVAL);
}
- error = dmu_objset_snapshot(zc->zc_name, zc->zc_value, NULL,
- nvprops, recursive, B_FALSE, -1);
+ if (spa_version(spa) < SPA_VERSION_ZPOOL_HISTORY) {
+ spa_close(spa, FTAG);
+ return (ENOTSUP);
+ }
-out:
- nvlist_free(nvprops);
+ error = spa_history_log(spa, message);
+ spa_close(spa, FTAG);
return (error);
}
+/* ARGSUSED */
int
zfs_unmount_snap(const char *name, void *arg)
{
- vfs_t *vfsp = NULL;
+ vfs_t *vfsp;
+ int err;
- if (arg) {
- char *snapname = arg;
- char *fullname = kmem_asprintf("%s@%s", name, snapname);
- vfsp = zfs_get_vfs(fullname);
- strfree(fullname);
- } else if (strchr(name, '@')) {
- vfsp = zfs_get_vfs(name);
- }
+ if (strchr(name, '@') == NULL)
+ return (0);
- if (vfsp) {
- /*
- * Always force the unmount for snapshots.
- */
- int flag = MS_FORCE;
- int err;
+ vfsp = zfs_get_vfs(name);
+ if (vfsp == NULL)
+ return (0);
- if ((err = vn_vfswlock(vfsp->vfs_vnodecovered)) != 0) {
- VFS_RELE(vfsp);
- return (err);
- }
+ if ((err = vn_vfswlock(vfsp->vfs_vnodecovered)) != 0) {
VFS_RELE(vfsp);
- if ((err = dounmount(vfsp, flag, kcred)) != 0)
- return (err);
+ return (err);
}
- return (0);
+ VFS_RELE(vfsp);
+
+ /*
+ * Always force the unmount for snapshots.
+ */
+ return (dounmount(vfsp, MS_FORCE, kcred));
}
/*
- * inputs:
- * zc_name name of filesystem, snaps must be under it
- * zc_nvlist_src[_size] full names of snapshots to destroy
- * zc_defer_destroy mark for deferred destroy
+ * innvl: {
+ * "snaps" -> { snapshot1, snapshot2 }
+ * (optional boolean) "defer"
+ * }
+ *
+ * outnvl: snapshot -> error code (int32)
*
- * outputs:
- * zc_name on failure, name of failed snapshot
*/
static int
-zfs_ioc_destroy_snaps_nvl(zfs_cmd_t *zc)
+zfs_ioc_destroy_snaps(const char *poolname, nvlist_t *innvl, nvlist_t *outnvl)
{
- int err, len;
- nvlist_t *nvl;
+ int poollen;
+ nvlist_t *snaps;
nvpair_t *pair;
+ boolean_t defer;
- if ((err = get_nvlist(zc->zc_nvlist_src, zc->zc_nvlist_src_size,
- zc->zc_iflags, &nvl)) != 0)
- return (err);
+ if (nvlist_lookup_nvlist(innvl, "snaps", &snaps) != 0)
+ return (EINVAL);
+ defer = nvlist_exists(innvl, "defer");
- len = strlen(zc->zc_name);
- for (pair = nvlist_next_nvpair(nvl, NULL); pair != NULL;
- pair = nvlist_next_nvpair(nvl, pair)) {
+ poollen = strlen(poolname);
+ for (pair = nvlist_next_nvpair(snaps, NULL); pair != NULL;
+ pair = nvlist_next_nvpair(snaps, pair)) {
const char *name = nvpair_name(pair);
+
/*
- * The snap name must be underneath the zc_name. This ensures
- * that our permission checks were legitimate.
+ * The snap must be in the specified pool.
*/
- if (strncmp(zc->zc_name, name, len) != 0 ||
- (name[len] != '@' && name[len] != '/')) {
- nvlist_free(nvl);
- return (EINVAL);
- }
+ if (strncmp(name, poolname, poollen) != 0 ||
+ (name[poollen] != '/' && name[poollen] != '@'))
+ return (EXDEV);
+ /*
+ * Ignore failures to unmount; dmu_snapshots_destroy_nvl()
+ * will deal with this gracefully (by filling in outnvl).
+ */
(void) zfs_unmount_snap(name, NULL);
}
- err = dmu_snapshots_destroy_nvl(nvl, zc->zc_defer_destroy,
- zc->zc_name);
- nvlist_free(nvl);
- return (err);
+ return (dmu_snapshots_destroy_nvl(snaps, defer, outnvl));
}
/*
@@ -3510,7 +3739,7 @@ zfs_check_clearable(char *dataset, nvlist_t *props, nvlist_t **errlist)
(void) strcpy(zc->zc_value, nvpair_name(pair));
if ((err = zfs_check_settable(dataset, pair, CRED())) != 0 ||
- (err = zfs_secpolicy_inherit(zc, CRED())) != 0) {
+ (err = zfs_secpolicy_inherit_prop(zc, NULL, CRED())) != 0) {
VERIFY(nvlist_remove_nvpair(props, pair) == 0);
VERIFY(nvlist_add_int32(errors,
zc->zc_value, err) == 0);
@@ -3718,8 +3947,6 @@ zfs_ioc_recv(zfs_cmd_t *zc)
* dmu_recv_begin() succeeds.
*/
if (props) {
- nvlist_t *errlist;
-
if (dmu_objset_from_ds(drc.drc_logical_ds, &os) == 0) {
if (drc.drc_newfs) {
if (spa_version(os->os_spa) >=
@@ -3738,12 +3965,12 @@ zfs_ioc_recv(zfs_cmd_t *zc)
}
(void) zfs_set_prop_nvlist(tofs, ZPROP_SRC_RECEIVED,
- props, &errlist);
- (void) nvlist_merge(errors, errlist, 0);
- nvlist_free(errlist);
+ props, errors);
}
- if (fit_error_list(zc, &errors) != 0 || put_nvlist(zc, errors) != 0) {
+ if (zc->zc_nvlist_dst_size != 0 &&
+ (nvlist_smush(errors, zc->zc_nvlist_dst_size) != 0 ||
+ put_nvlist(zc, errors) != 0)) {
/*
* Caller made zc->zc_nvlist_dst less than the minimum expected
* size or supplied an invalid address.
@@ -3875,15 +4102,13 @@ zfs_ioc_send(zfs_cmd_t *zc)
rw_enter(&dp->dp_config_rwlock, RW_READER);
error = dsl_dataset_hold_obj(dp, zc->zc_sendobj, FTAG, &ds);
rw_exit(&dp->dp_config_rwlock);
- if (error) {
- spa_close(spa, FTAG);
+ spa_close(spa, FTAG);
+ if (error)
return (error);
- }
error = dmu_objset_from_ds(ds, &tosnap);
if (error) {
dsl_dataset_rele(ds, FTAG);
- spa_close(spa, FTAG);
return (error);
}
@@ -3891,7 +4116,6 @@ zfs_ioc_send(zfs_cmd_t *zc)
rw_enter(&dp->dp_config_rwlock, RW_READER);
error = dsl_dataset_hold_obj(dp, zc->zc_fromobj, FTAG, &dsfrom);
rw_exit(&dp->dp_config_rwlock);
- spa_close(spa, FTAG);
if (error) {
dsl_dataset_rele(ds, FTAG);
return (error);
@@ -3902,12 +4126,37 @@ zfs_ioc_send(zfs_cmd_t *zc)
dsl_dataset_rele(ds, FTAG);
return (error);
}
- } else {
- spa_close(spa, FTAG);
+ }
+
+ if (zc->zc_obj) {
+ dsl_pool_t *dp = ds->ds_dir->dd_pool;
+
+ if (fromsnap != NULL) {
+ dsl_dataset_rele(dsfrom, FTAG);
+ dsl_dataset_rele(ds, FTAG);
+ return (EINVAL);
+ }
+
+ if (dsl_dir_is_clone(ds->ds_dir)) {
+ rw_enter(&dp->dp_config_rwlock, RW_READER);
+ error = dsl_dataset_hold_obj(dp,
+ ds->ds_dir->dd_phys->dd_origin_obj, FTAG, &dsfrom);
+ rw_exit(&dp->dp_config_rwlock);
+ if (error) {
+ dsl_dataset_rele(ds, FTAG);
+ return (error);
+ }
+ error = dmu_objset_from_ds(dsfrom, &fromsnap);
+ if (error) {
+ dsl_dataset_rele(dsfrom, FTAG);
+ dsl_dataset_rele(ds, FTAG);
+ return (error);
+ }
+ }
}
if (estimate) {
- error = dmu_send_estimate(tosnap, fromsnap, zc->zc_obj,
+ error = dmu_send_estimate(tosnap, fromsnap,
&zc->zc_objset_type);
} else {
file_t *fp = getf(zc->zc_cookie);
@@ -3919,8 +4168,8 @@ zfs_ioc_send(zfs_cmd_t *zc)
}
off = fp->f_offset;
- error = dmu_sendbackup(tosnap, fromsnap, zc->zc_obj,
- fp->f_vnode, &off);
+ error = dmu_send(tosnap, fromsnap,
+ zc->zc_cookie, fp->f_vnode, &off);
if (VOP_SEEK(fp->f_vnode, fp->f_offset, &off, NULL) == 0)
fp->f_offset = off;
@@ -3932,6 +4181,49 @@ zfs_ioc_send(zfs_cmd_t *zc)
return (error);
}
+/*
+ * inputs:
+ * zc_name name of snapshot on which to report progress
+ * zc_cookie file descriptor of send stream
+ *
+ * outputs:
+ * zc_cookie number of bytes written in send stream thus far
+ */
+static int
+zfs_ioc_send_progress(zfs_cmd_t *zc)
+{
+ dsl_dataset_t *ds;
+ dmu_sendarg_t *dsp = NULL;
+ int error;
+
+ if ((error = dsl_dataset_hold(zc->zc_name, FTAG, &ds)) != 0)
+ return (error);
+
+ mutex_enter(&ds->ds_sendstream_lock);
+
+ /*
+ * Iterate over all the send streams currently active on this dataset.
+ * If there's one which matches the specified file descriptor _and_ the
+ * stream was started by the current process, return the progress of
+ * that stream.
+ */
+ for (dsp = list_head(&ds->ds_sendstreams); dsp != NULL;
+ dsp = list_next(&ds->ds_sendstreams, dsp)) {
+ if (dsp->dsa_outfd == zc->zc_cookie &&
+ dsp->dsa_proc == curproc)
+ break;
+ }
+
+ if (dsp != NULL)
+ zc->zc_cookie = *(dsp->dsa_off);
+ else
+ error = ENOENT;
+
+ mutex_exit(&ds->ds_sendstream_lock);
+ dsl_dataset_rele(ds, FTAG);
+ return (error);
+}
+
static int
zfs_ioc_inject_fault(zfs_cmd_t *zc)
{
@@ -4390,6 +4682,7 @@ zfs_ioc_next_obj(zfs_cmd_t *zc)
* zc_cleanup_fd cleanup-on-exit file descriptor for calling process
*
* outputs:
+ * zc_value short name of new snapshot
*/
static int
zfs_ioc_tmp_snapshot(zfs_cmd_t *zc)
@@ -4397,22 +4690,21 @@ zfs_ioc_tmp_snapshot(zfs_cmd_t *zc)
char *snap_name;
int error;
- snap_name = kmem_asprintf("%s-%016llx", zc->zc_value,
+ snap_name = kmem_asprintf("%s@%s-%016llx", zc->zc_name, zc->zc_value,
(u_longlong_t)ddi_get_lbolt64());
- if (strlen(snap_name) >= MAXNAMELEN) {
+ if (strlen(snap_name) >= MAXPATHLEN) {
strfree(snap_name);
return (E2BIG);
}
- error = dmu_objset_snapshot(zc->zc_name, snap_name, snap_name,
- NULL, B_FALSE, B_TRUE, zc->zc_cleanup_fd);
+ error = dmu_objset_snapshot_tmp(snap_name, "%temp", zc->zc_cleanup_fd);
if (error != 0) {
strfree(snap_name);
return (error);
}
- (void) strcpy(zc->zc_value, snap_name);
+ (void) strcpy(zc->zc_value, strchr(snap_name, '@') + 1);
strfree(snap_name);
return (0);
}
@@ -4766,170 +5058,427 @@ zfs_ioc_space_written(zfs_cmd_t *zc)
dsl_dataset_rele(new, FTAG);
return (error);
}
-
/*
- * inputs:
- * zc_name full name of last snapshot
- * zc_value full name of first snapshot
+ * innvl: {
+ * "firstsnap" -> snapshot name
+ * }
*
- * outputs:
- * zc_cookie space in bytes
- * zc_objset_type compressed space in bytes
- * zc_perm_action uncompressed space in bytes
+ * outnvl: {
+ * "used" -> space in bytes
+ * "compressed" -> compressed space in bytes
+ * "uncompressed" -> uncompressed space in bytes
+ * }
*/
static int
-zfs_ioc_space_snaps(zfs_cmd_t *zc)
+zfs_ioc_space_snaps(const char *lastsnap, nvlist_t *innvl, nvlist_t *outnvl)
{
int error;
dsl_dataset_t *new, *old;
+ char *firstsnap;
+ uint64_t used, comp, uncomp;
- error = dsl_dataset_hold(zc->zc_name, FTAG, &new);
+ if (nvlist_lookup_string(innvl, "firstsnap", &firstsnap) != 0)
+ return (EINVAL);
+
+ error = dsl_dataset_hold(lastsnap, FTAG, &new);
if (error != 0)
return (error);
- error = dsl_dataset_hold(zc->zc_value, FTAG, &old);
+ error = dsl_dataset_hold(firstsnap, FTAG, &old);
if (error != 0) {
dsl_dataset_rele(new, FTAG);
return (error);
}
- error = dsl_dataset_space_wouldfree(old, new, &zc->zc_cookie,
- &zc->zc_objset_type, &zc->zc_perm_action);
+ error = dsl_dataset_space_wouldfree(old, new, &used, &comp, &uncomp);
dsl_dataset_rele(old, FTAG);
dsl_dataset_rele(new, FTAG);
+ fnvlist_add_uint64(outnvl, "used", used);
+ fnvlist_add_uint64(outnvl, "compressed", comp);
+ fnvlist_add_uint64(outnvl, "uncompressed", uncomp);
return (error);
}
/*
- * pool create, destroy, and export don't log the history as part of
- * zfsdev_ioctl, but rather zfs_ioc_pool_create, and zfs_ioc_pool_export
- * do the logging of those commands.
+ * innvl: {
+ * "fd" -> file descriptor to write stream to (int32)
+ * (optional) "fromsnap" -> full snap name to send an incremental from
+ * }
+ *
+ * outnvl is unused
*/
-static zfs_ioc_vec_t zfs_ioc_vec[] = {
- { zfs_ioc_pool_create, zfs_secpolicy_config, POOL_NAME, B_FALSE,
- POOL_CHECK_NONE },
- { zfs_ioc_pool_destroy, zfs_secpolicy_config, POOL_NAME, B_FALSE,
- POOL_CHECK_NONE },
- { zfs_ioc_pool_import, zfs_secpolicy_config, POOL_NAME, B_TRUE,
- POOL_CHECK_NONE },
- { zfs_ioc_pool_export, zfs_secpolicy_config, POOL_NAME, B_FALSE,
- POOL_CHECK_NONE },
- { zfs_ioc_pool_configs, zfs_secpolicy_none, NO_NAME, B_FALSE,
- POOL_CHECK_NONE },
- { zfs_ioc_pool_stats, zfs_secpolicy_read, POOL_NAME, B_FALSE,
- POOL_CHECK_NONE },
- { zfs_ioc_pool_tryimport, zfs_secpolicy_config, NO_NAME, B_FALSE,
- POOL_CHECK_NONE },
- { zfs_ioc_pool_scan, zfs_secpolicy_config, POOL_NAME, B_TRUE,
- POOL_CHECK_SUSPENDED | POOL_CHECK_READONLY },
- { zfs_ioc_pool_freeze, zfs_secpolicy_config, NO_NAME, B_FALSE,
- POOL_CHECK_READONLY },
- { zfs_ioc_pool_upgrade, zfs_secpolicy_config, POOL_NAME, B_TRUE,
- POOL_CHECK_SUSPENDED | POOL_CHECK_READONLY },
- { zfs_ioc_pool_get_history, zfs_secpolicy_config, POOL_NAME, B_FALSE,
- POOL_CHECK_NONE },
- { zfs_ioc_vdev_add, zfs_secpolicy_config, POOL_NAME, B_TRUE,
- POOL_CHECK_SUSPENDED | POOL_CHECK_READONLY },
- { zfs_ioc_vdev_remove, zfs_secpolicy_config, POOL_NAME, B_TRUE,
- POOL_CHECK_SUSPENDED | POOL_CHECK_READONLY },
- { zfs_ioc_vdev_set_state, zfs_secpolicy_config, POOL_NAME, B_TRUE,
- POOL_CHECK_SUSPENDED | POOL_CHECK_READONLY },
- { zfs_ioc_vdev_attach, zfs_secpolicy_config, POOL_NAME, B_TRUE,
- POOL_CHECK_SUSPENDED | POOL_CHECK_READONLY },
- { zfs_ioc_vdev_detach, zfs_secpolicy_config, POOL_NAME, B_TRUE,
- POOL_CHECK_SUSPENDED | POOL_CHECK_READONLY },
- { zfs_ioc_vdev_setpath, zfs_secpolicy_config, POOL_NAME, B_FALSE,
- POOL_CHECK_SUSPENDED | POOL_CHECK_READONLY },
- { zfs_ioc_vdev_setfru, zfs_secpolicy_config, POOL_NAME, B_FALSE,
- POOL_CHECK_SUSPENDED | POOL_CHECK_READONLY },
- { zfs_ioc_objset_stats, zfs_secpolicy_read, DATASET_NAME, B_FALSE,
- POOL_CHECK_SUSPENDED },
- { zfs_ioc_objset_zplprops, zfs_secpolicy_read, DATASET_NAME, B_FALSE,
- POOL_CHECK_NONE },
- { zfs_ioc_dataset_list_next, zfs_secpolicy_read, DATASET_NAME, B_FALSE,
- POOL_CHECK_SUSPENDED },
- { zfs_ioc_snapshot_list_next, zfs_secpolicy_read, DATASET_NAME, B_FALSE,
- POOL_CHECK_SUSPENDED },
- { zfs_ioc_set_prop, zfs_secpolicy_none, DATASET_NAME, B_TRUE,
- POOL_CHECK_SUSPENDED | POOL_CHECK_READONLY },
- { zfs_ioc_create, zfs_secpolicy_create, DATASET_NAME, B_TRUE,
- POOL_CHECK_SUSPENDED | POOL_CHECK_READONLY },
- { zfs_ioc_destroy, zfs_secpolicy_destroy, DATASET_NAME, B_TRUE,
- POOL_CHECK_SUSPENDED | POOL_CHECK_READONLY },
- { zfs_ioc_rollback, zfs_secpolicy_rollback, DATASET_NAME, B_TRUE,
- POOL_CHECK_SUSPENDED | POOL_CHECK_READONLY },
- { zfs_ioc_rename, zfs_secpolicy_rename, DATASET_NAME, B_TRUE,
- POOL_CHECK_SUSPENDED | POOL_CHECK_READONLY },
- { zfs_ioc_recv, zfs_secpolicy_receive, DATASET_NAME, B_TRUE,
- POOL_CHECK_SUSPENDED | POOL_CHECK_READONLY },
- { zfs_ioc_send, zfs_secpolicy_send, DATASET_NAME, B_FALSE,
- POOL_CHECK_NONE },
- { zfs_ioc_inject_fault, zfs_secpolicy_inject, NO_NAME, B_FALSE,
- POOL_CHECK_NONE },
- { zfs_ioc_clear_fault, zfs_secpolicy_inject, NO_NAME, B_FALSE,
- POOL_CHECK_NONE },
- { zfs_ioc_inject_list_next, zfs_secpolicy_inject, NO_NAME, B_FALSE,
- POOL_CHECK_NONE },
- { zfs_ioc_error_log, zfs_secpolicy_inject, POOL_NAME, B_FALSE,
- POOL_CHECK_NONE },
- { zfs_ioc_clear, zfs_secpolicy_config, POOL_NAME, B_TRUE,
- POOL_CHECK_NONE },
- { zfs_ioc_promote, zfs_secpolicy_promote, DATASET_NAME, B_TRUE,
- POOL_CHECK_SUSPENDED | POOL_CHECK_READONLY },
- { zfs_ioc_snapshot, zfs_secpolicy_snapshot, DATASET_NAME, B_TRUE,
- POOL_CHECK_SUSPENDED | POOL_CHECK_READONLY },
- { zfs_ioc_dsobj_to_dsname, zfs_secpolicy_diff, POOL_NAME, B_FALSE,
- POOL_CHECK_NONE },
- { zfs_ioc_obj_to_path, zfs_secpolicy_diff, DATASET_NAME, B_FALSE,
- POOL_CHECK_SUSPENDED },
- { zfs_ioc_pool_set_props, zfs_secpolicy_config, POOL_NAME, B_TRUE,
- POOL_CHECK_SUSPENDED | POOL_CHECK_READONLY },
- { zfs_ioc_pool_get_props, zfs_secpolicy_read, POOL_NAME, B_FALSE,
- POOL_CHECK_NONE },
- { zfs_ioc_set_fsacl, zfs_secpolicy_fsacl, DATASET_NAME, B_TRUE,
- POOL_CHECK_SUSPENDED | POOL_CHECK_READONLY },
- { zfs_ioc_get_fsacl, zfs_secpolicy_read, DATASET_NAME, B_FALSE,
- POOL_CHECK_NONE },
- { zfs_ioc_share, zfs_secpolicy_share, DATASET_NAME, B_FALSE,
- POOL_CHECK_NONE },
- { zfs_ioc_inherit_prop, zfs_secpolicy_inherit, DATASET_NAME, B_TRUE,
- POOL_CHECK_SUSPENDED | POOL_CHECK_READONLY },
- { zfs_ioc_smb_acl, zfs_secpolicy_smb_acl, DATASET_NAME, B_FALSE,
- POOL_CHECK_NONE },
- { zfs_ioc_userspace_one, zfs_secpolicy_userspace_one, DATASET_NAME,
- B_FALSE, POOL_CHECK_NONE },
- { zfs_ioc_userspace_many, zfs_secpolicy_userspace_many, DATASET_NAME,
- B_FALSE, POOL_CHECK_NONE },
- { zfs_ioc_userspace_upgrade, zfs_secpolicy_userspace_upgrade,
- DATASET_NAME, B_FALSE, POOL_CHECK_SUSPENDED | POOL_CHECK_READONLY },
- { zfs_ioc_hold, zfs_secpolicy_hold, DATASET_NAME, B_TRUE,
- POOL_CHECK_SUSPENDED | POOL_CHECK_READONLY },
- { zfs_ioc_release, zfs_secpolicy_release, DATASET_NAME, B_TRUE,
- POOL_CHECK_SUSPENDED | POOL_CHECK_READONLY },
- { zfs_ioc_get_holds, zfs_secpolicy_read, DATASET_NAME, B_FALSE,
- POOL_CHECK_SUSPENDED },
- { zfs_ioc_objset_recvd_props, zfs_secpolicy_read, DATASET_NAME, B_FALSE,
- POOL_CHECK_NONE },
- { zfs_ioc_vdev_split, zfs_secpolicy_config, POOL_NAME, B_TRUE,
- POOL_CHECK_SUSPENDED | POOL_CHECK_READONLY },
- { zfs_ioc_next_obj, zfs_secpolicy_read, DATASET_NAME, B_FALSE,
- POOL_CHECK_NONE },
- { zfs_ioc_diff, zfs_secpolicy_diff, DATASET_NAME, B_FALSE,
- POOL_CHECK_NONE },
- { zfs_ioc_tmp_snapshot, zfs_secpolicy_tmp_snapshot, DATASET_NAME,
- B_FALSE, POOL_CHECK_SUSPENDED | POOL_CHECK_READONLY },
- { zfs_ioc_obj_to_stats, zfs_secpolicy_diff, DATASET_NAME, B_FALSE,
- POOL_CHECK_SUSPENDED },
- { zfs_ioc_space_written, zfs_secpolicy_read, DATASET_NAME, B_FALSE,
- POOL_CHECK_SUSPENDED },
- { zfs_ioc_space_snaps, zfs_secpolicy_read, DATASET_NAME, B_FALSE,
- POOL_CHECK_SUSPENDED },
- { zfs_ioc_destroy_snaps_nvl, zfs_secpolicy_destroy_recursive,
- DATASET_NAME, B_TRUE, POOL_CHECK_SUSPENDED | POOL_CHECK_READONLY },
- { zfs_ioc_pool_reguid, zfs_secpolicy_config, POOL_NAME, B_TRUE,
- POOL_CHECK_SUSPENDED | POOL_CHECK_READONLY },
- { zfs_ioc_pool_reopen, zfs_secpolicy_config, POOL_NAME, B_TRUE,
- POOL_CHECK_SUSPENDED },
-};
+/* ARGSUSED */
+static int
+zfs_ioc_send_new(const char *snapname, nvlist_t *innvl, nvlist_t *outnvl)
+{
+ objset_t *fromsnap = NULL;
+ objset_t *tosnap;
+ int error;
+ offset_t off;
+ char *fromname;
+ int fd;
+
+ error = nvlist_lookup_int32(innvl, "fd", &fd);
+ if (error != 0)
+ return (EINVAL);
+
+ error = dmu_objset_hold(snapname, FTAG, &tosnap);
+ if (error)
+ return (error);
+
+ error = nvlist_lookup_string(innvl, "fromsnap", &fromname);
+ if (error == 0) {
+ error = dmu_objset_hold(fromname, FTAG, &fromsnap);
+ if (error) {
+ dmu_objset_rele(tosnap, FTAG);
+ return (error);
+ }
+ }
+
+ file_t *fp = getf(fd);
+ if (fp == NULL) {
+ dmu_objset_rele(tosnap, FTAG);
+ if (fromsnap != NULL)
+ dmu_objset_rele(fromsnap, FTAG);
+ return (EBADF);
+ }
+
+ off = fp->f_offset;
+ error = dmu_send(tosnap, fromsnap, fd, fp->f_vnode, &off);
+
+ if (VOP_SEEK(fp->f_vnode, fp->f_offset, &off, NULL) == 0)
+ fp->f_offset = off;
+ releasef(fd);
+ if (fromsnap != NULL)
+ dmu_objset_rele(fromsnap, FTAG);
+ dmu_objset_rele(tosnap, FTAG);
+ return (error);
+}
+
+/*
+ * Determine approximately how large a zfs send stream will be -- the number
+ * of bytes that will be written to the fd supplied to zfs_ioc_send_new().
+ *
+ * innvl: {
+ * (optional) "fromsnap" -> full snap name to send an incremental from
+ * }
+ *
+ * outnvl: {
+ * "space" -> bytes of space (uint64)
+ * }
+ */
+static int
+zfs_ioc_send_space(const char *snapname, nvlist_t *innvl, nvlist_t *outnvl)
+{
+ objset_t *fromsnap = NULL;
+ objset_t *tosnap;
+ int error;
+ char *fromname;
+ uint64_t space;
+
+ error = dmu_objset_hold(snapname, FTAG, &tosnap);
+ if (error)
+ return (error);
+
+ error = nvlist_lookup_string(innvl, "fromsnap", &fromname);
+ if (error == 0) {
+ error = dmu_objset_hold(fromname, FTAG, &fromsnap);
+ if (error) {
+ dmu_objset_rele(tosnap, FTAG);
+ return (error);
+ }
+ }
+
+ error = dmu_send_estimate(tosnap, fromsnap, &space);
+ fnvlist_add_uint64(outnvl, "space", space);
+
+ if (fromsnap != NULL)
+ dmu_objset_rele(fromsnap, FTAG);
+ dmu_objset_rele(tosnap, FTAG);
+ return (error);
+}
+
+
+static zfs_ioc_vec_t zfs_ioc_vec[ZFS_IOC_LAST - ZFS_IOC_FIRST];
+
+static void
+zfs_ioctl_register_legacy(zfs_ioc_t ioc, zfs_ioc_legacy_func_t *func,
+ zfs_secpolicy_func_t *secpolicy, zfs_ioc_namecheck_t namecheck,
+ boolean_t log_history, zfs_ioc_poolcheck_t pool_check)
+{
+ zfs_ioc_vec_t *vec = &zfs_ioc_vec[ioc - ZFS_IOC_FIRST];
+
+ ASSERT3U(ioc, >=, ZFS_IOC_FIRST);
+ ASSERT3U(ioc, <, ZFS_IOC_LAST);
+ ASSERT3P(vec->zvec_legacy_func, ==, NULL);
+ ASSERT3P(vec->zvec_func, ==, NULL);
+
+ vec->zvec_legacy_func = func;
+ vec->zvec_secpolicy = secpolicy;
+ vec->zvec_namecheck = namecheck;
+ vec->zvec_allow_log = log_history;
+ vec->zvec_pool_check = pool_check;
+}
+
+/*
+ * See the block comment at the beginning of this file for details on
+ * each argument to this function.
+ */
+static void
+zfs_ioctl_register(const char *name, zfs_ioc_t ioc, zfs_ioc_func_t *func,
+ zfs_secpolicy_func_t *secpolicy, zfs_ioc_namecheck_t namecheck,
+ zfs_ioc_poolcheck_t pool_check, boolean_t smush_outnvlist,
+ boolean_t allow_log)
+{
+ zfs_ioc_vec_t *vec = &zfs_ioc_vec[ioc - ZFS_IOC_FIRST];
+
+ ASSERT3U(ioc, >=, ZFS_IOC_FIRST);
+ ASSERT3U(ioc, <, ZFS_IOC_LAST);
+ ASSERT3P(vec->zvec_legacy_func, ==, NULL);
+ ASSERT3P(vec->zvec_func, ==, NULL);
+
+ /* if we are logging, the name must be valid */
+ ASSERT(!allow_log || namecheck != NO_NAME);
+
+ vec->zvec_name = name;
+ vec->zvec_func = func;
+ vec->zvec_secpolicy = secpolicy;
+ vec->zvec_namecheck = namecheck;
+ vec->zvec_pool_check = pool_check;
+ vec->zvec_smush_outnvlist = smush_outnvlist;
+ vec->zvec_allow_log = allow_log;
+}
+
+static void
+zfs_ioctl_register_pool(zfs_ioc_t ioc, zfs_ioc_legacy_func_t *func,
+ zfs_secpolicy_func_t *secpolicy, boolean_t log_history,
+ zfs_ioc_poolcheck_t pool_check)
+{
+ zfs_ioctl_register_legacy(ioc, func, secpolicy,
+ POOL_NAME, log_history, pool_check);
+}
+
+static void
+zfs_ioctl_register_dataset_nolog(zfs_ioc_t ioc, zfs_ioc_legacy_func_t *func,
+ zfs_secpolicy_func_t *secpolicy, zfs_ioc_poolcheck_t pool_check)
+{
+ zfs_ioctl_register_legacy(ioc, func, secpolicy,
+ DATASET_NAME, B_FALSE, pool_check);
+}
+
+static void
+zfs_ioctl_register_pool_modify(zfs_ioc_t ioc, zfs_ioc_legacy_func_t *func)
+{
+ zfs_ioctl_register_legacy(ioc, func, zfs_secpolicy_config,
+ POOL_NAME, B_TRUE, POOL_CHECK_SUSPENDED | POOL_CHECK_READONLY);
+}
+
+static void
+zfs_ioctl_register_pool_meta(zfs_ioc_t ioc, zfs_ioc_legacy_func_t *func,
+ zfs_secpolicy_func_t *secpolicy)
+{
+ zfs_ioctl_register_legacy(ioc, func, secpolicy,
+ NO_NAME, B_FALSE, POOL_CHECK_NONE);
+}
+
+static void
+zfs_ioctl_register_dataset_read_secpolicy(zfs_ioc_t ioc,
+ zfs_ioc_legacy_func_t *func, zfs_secpolicy_func_t *secpolicy)
+{
+ zfs_ioctl_register_legacy(ioc, func, secpolicy,
+ DATASET_NAME, B_FALSE, POOL_CHECK_SUSPENDED);
+}
+
+static void
+zfs_ioctl_register_dataset_read(zfs_ioc_t ioc, zfs_ioc_legacy_func_t *func)
+{
+ zfs_ioctl_register_dataset_read_secpolicy(ioc, func,
+ zfs_secpolicy_read);
+}
+
+static void
+zfs_ioctl_register_dataset_modify(zfs_ioc_t ioc, zfs_ioc_legacy_func_t *func,
+ zfs_secpolicy_func_t *secpolicy)
+{
+ zfs_ioctl_register_legacy(ioc, func, secpolicy,
+ DATASET_NAME, B_TRUE, POOL_CHECK_SUSPENDED | POOL_CHECK_READONLY);
+}
+
+static void
+zfs_ioctl_init(void)
+{
+ zfs_ioctl_register("snapshot", ZFS_IOC_SNAPSHOT,
+ zfs_ioc_snapshot, zfs_secpolicy_snapshot, POOL_NAME,
+ POOL_CHECK_SUSPENDED | POOL_CHECK_READONLY, B_TRUE, B_TRUE);
+
+ zfs_ioctl_register("log_history", ZFS_IOC_LOG_HISTORY,
+ zfs_ioc_log_history, zfs_secpolicy_log_history, NO_NAME,
+ POOL_CHECK_SUSPENDED | POOL_CHECK_READONLY, B_FALSE, B_FALSE);
+
+ zfs_ioctl_register("space_snaps", ZFS_IOC_SPACE_SNAPS,
+ zfs_ioc_space_snaps, zfs_secpolicy_read, DATASET_NAME,
+ POOL_CHECK_SUSPENDED, B_FALSE, B_FALSE);
+
+ zfs_ioctl_register("send", ZFS_IOC_SEND_NEW,
+ zfs_ioc_send_new, zfs_secpolicy_send_new, DATASET_NAME,
+ POOL_CHECK_SUSPENDED, B_FALSE, B_FALSE);
+
+ zfs_ioctl_register("send_space", ZFS_IOC_SEND_SPACE,
+ zfs_ioc_send_space, zfs_secpolicy_read, DATASET_NAME,
+ POOL_CHECK_SUSPENDED, B_FALSE, B_FALSE);
+
+ zfs_ioctl_register("create", ZFS_IOC_CREATE,
+ zfs_ioc_create, zfs_secpolicy_create_clone, DATASET_NAME,
+ POOL_CHECK_SUSPENDED | POOL_CHECK_READONLY, B_TRUE, B_TRUE);
+
+ zfs_ioctl_register("clone", ZFS_IOC_CLONE,
+ zfs_ioc_clone, zfs_secpolicy_create_clone, DATASET_NAME,
+ POOL_CHECK_SUSPENDED | POOL_CHECK_READONLY, B_TRUE, B_TRUE);
+
+ zfs_ioctl_register("destroy_snaps", ZFS_IOC_DESTROY_SNAPS,
+ zfs_ioc_destroy_snaps, zfs_secpolicy_destroy_snaps, POOL_NAME,
+ POOL_CHECK_SUSPENDED | POOL_CHECK_READONLY, B_TRUE, B_TRUE);
+
+ /* IOCTLS that use the legacy function signature */
+
+ zfs_ioctl_register_legacy(ZFS_IOC_POOL_FREEZE, zfs_ioc_pool_freeze,
+ zfs_secpolicy_config, NO_NAME, B_FALSE, POOL_CHECK_READONLY);
+
+ zfs_ioctl_register_pool(ZFS_IOC_POOL_CREATE, zfs_ioc_pool_create,
+ zfs_secpolicy_config, B_TRUE, POOL_CHECK_NONE);
+ zfs_ioctl_register_pool_modify(ZFS_IOC_POOL_SCAN,
+ zfs_ioc_pool_scan);
+ zfs_ioctl_register_pool_modify(ZFS_IOC_POOL_UPGRADE,
+ zfs_ioc_pool_upgrade);
+ zfs_ioctl_register_pool_modify(ZFS_IOC_VDEV_ADD,
+ zfs_ioc_vdev_add);
+ zfs_ioctl_register_pool_modify(ZFS_IOC_VDEV_REMOVE,
+ zfs_ioc_vdev_remove);
+ zfs_ioctl_register_pool_modify(ZFS_IOC_VDEV_SET_STATE,
+ zfs_ioc_vdev_set_state);
+ zfs_ioctl_register_pool_modify(ZFS_IOC_VDEV_ATTACH,
+ zfs_ioc_vdev_attach);
+ zfs_ioctl_register_pool_modify(ZFS_IOC_VDEV_DETACH,
+ zfs_ioc_vdev_detach);
+ zfs_ioctl_register_pool_modify(ZFS_IOC_VDEV_SETPATH,
+ zfs_ioc_vdev_setpath);
+ zfs_ioctl_register_pool_modify(ZFS_IOC_VDEV_SETFRU,
+ zfs_ioc_vdev_setfru);
+ zfs_ioctl_register_pool_modify(ZFS_IOC_POOL_SET_PROPS,
+ zfs_ioc_pool_set_props);
+ zfs_ioctl_register_pool_modify(ZFS_IOC_VDEV_SPLIT,
+ zfs_ioc_vdev_split);
+ zfs_ioctl_register_pool_modify(ZFS_IOC_POOL_REGUID,
+ zfs_ioc_pool_reguid);
+
+ zfs_ioctl_register_pool_meta(ZFS_IOC_POOL_CONFIGS,
+ zfs_ioc_pool_configs, zfs_secpolicy_none);
+ zfs_ioctl_register_pool_meta(ZFS_IOC_POOL_TRYIMPORT,
+ zfs_ioc_pool_tryimport, zfs_secpolicy_config);
+ zfs_ioctl_register_pool_meta(ZFS_IOC_INJECT_FAULT,
+ zfs_ioc_inject_fault, zfs_secpolicy_inject);
+ zfs_ioctl_register_pool_meta(ZFS_IOC_CLEAR_FAULT,
+ zfs_ioc_clear_fault, zfs_secpolicy_inject);
+ zfs_ioctl_register_pool_meta(ZFS_IOC_INJECT_LIST_NEXT,
+ zfs_ioc_inject_list_next, zfs_secpolicy_inject);
+
+ /*
+ * pool destroy, and export don't log the history as part of
+ * zfsdev_ioctl, but rather zfs_ioc_pool_export
+ * does the logging of those commands.
+ */
+ zfs_ioctl_register_pool(ZFS_IOC_POOL_DESTROY, zfs_ioc_pool_destroy,
+ zfs_secpolicy_config, B_FALSE, POOL_CHECK_NONE);
+ zfs_ioctl_register_pool(ZFS_IOC_POOL_EXPORT, zfs_ioc_pool_export,
+ zfs_secpolicy_config, B_FALSE, POOL_CHECK_NONE);
+
+ zfs_ioctl_register_pool(ZFS_IOC_POOL_STATS, zfs_ioc_pool_stats,
+ zfs_secpolicy_read, B_FALSE, POOL_CHECK_NONE);
+ zfs_ioctl_register_pool(ZFS_IOC_POOL_GET_PROPS, zfs_ioc_pool_get_props,
+ zfs_secpolicy_read, B_FALSE, POOL_CHECK_NONE);
+
+ zfs_ioctl_register_pool(ZFS_IOC_ERROR_LOG, zfs_ioc_error_log,
+ zfs_secpolicy_inject, B_FALSE, POOL_CHECK_SUSPENDED);
+ zfs_ioctl_register_pool(ZFS_IOC_DSOBJ_TO_DSNAME,
+ zfs_ioc_dsobj_to_dsname,
+ zfs_secpolicy_diff, B_FALSE, POOL_CHECK_SUSPENDED);
+ zfs_ioctl_register_pool(ZFS_IOC_POOL_GET_HISTORY,
+ zfs_ioc_pool_get_history,
+ zfs_secpolicy_config, B_FALSE, POOL_CHECK_SUSPENDED);
+
+ zfs_ioctl_register_pool(ZFS_IOC_POOL_IMPORT, zfs_ioc_pool_import,
+ zfs_secpolicy_config, B_TRUE, POOL_CHECK_NONE);
+
+ zfs_ioctl_register_pool(ZFS_IOC_CLEAR, zfs_ioc_clear,
+ zfs_secpolicy_config, B_TRUE, POOL_CHECK_SUSPENDED);
+ zfs_ioctl_register_pool(ZFS_IOC_POOL_REOPEN, zfs_ioc_pool_reopen,
+ zfs_secpolicy_config, B_TRUE, POOL_CHECK_SUSPENDED);
+
+ zfs_ioctl_register_dataset_read(ZFS_IOC_SPACE_WRITTEN,
+ zfs_ioc_space_written);
+ zfs_ioctl_register_dataset_read(ZFS_IOC_GET_HOLDS,
+ zfs_ioc_get_holds);
+ zfs_ioctl_register_dataset_read(ZFS_IOC_OBJSET_RECVD_PROPS,
+ zfs_ioc_objset_recvd_props);
+ zfs_ioctl_register_dataset_read(ZFS_IOC_NEXT_OBJ,
+ zfs_ioc_next_obj);
+ zfs_ioctl_register_dataset_read(ZFS_IOC_GET_FSACL,
+ zfs_ioc_get_fsacl);
+ zfs_ioctl_register_dataset_read(ZFS_IOC_OBJSET_STATS,
+ zfs_ioc_objset_stats);
+ zfs_ioctl_register_dataset_read(ZFS_IOC_OBJSET_ZPLPROPS,
+ zfs_ioc_objset_zplprops);
+ zfs_ioctl_register_dataset_read(ZFS_IOC_DATASET_LIST_NEXT,
+ zfs_ioc_dataset_list_next);
+ zfs_ioctl_register_dataset_read(ZFS_IOC_SNAPSHOT_LIST_NEXT,
+ zfs_ioc_snapshot_list_next);
+ zfs_ioctl_register_dataset_read(ZFS_IOC_SEND_PROGRESS,
+ zfs_ioc_send_progress);
+
+ zfs_ioctl_register_dataset_read_secpolicy(ZFS_IOC_DIFF,
+ zfs_ioc_diff, zfs_secpolicy_diff);
+ zfs_ioctl_register_dataset_read_secpolicy(ZFS_IOC_OBJ_TO_STATS,
+ zfs_ioc_obj_to_stats, zfs_secpolicy_diff);
+ zfs_ioctl_register_dataset_read_secpolicy(ZFS_IOC_OBJ_TO_PATH,
+ zfs_ioc_obj_to_path, zfs_secpolicy_diff);
+ zfs_ioctl_register_dataset_read_secpolicy(ZFS_IOC_USERSPACE_ONE,
+ zfs_ioc_userspace_one, zfs_secpolicy_userspace_one);
+ zfs_ioctl_register_dataset_read_secpolicy(ZFS_IOC_USERSPACE_MANY,
+ zfs_ioc_userspace_many, zfs_secpolicy_userspace_many);
+ zfs_ioctl_register_dataset_read_secpolicy(ZFS_IOC_SEND,
+ zfs_ioc_send, zfs_secpolicy_send);
+
+ zfs_ioctl_register_dataset_modify(ZFS_IOC_SET_PROP, zfs_ioc_set_prop,
+ zfs_secpolicy_none);
+ zfs_ioctl_register_dataset_modify(ZFS_IOC_DESTROY, zfs_ioc_destroy,
+ zfs_secpolicy_destroy);
+ zfs_ioctl_register_dataset_modify(ZFS_IOC_ROLLBACK, zfs_ioc_rollback,
+ zfs_secpolicy_rollback);
+ zfs_ioctl_register_dataset_modify(ZFS_IOC_RENAME, zfs_ioc_rename,
+ zfs_secpolicy_rename);
+ zfs_ioctl_register_dataset_modify(ZFS_IOC_RECV, zfs_ioc_recv,
+ zfs_secpolicy_recv);
+ zfs_ioctl_register_dataset_modify(ZFS_IOC_PROMOTE, zfs_ioc_promote,
+ zfs_secpolicy_promote);
+ zfs_ioctl_register_dataset_modify(ZFS_IOC_HOLD, zfs_ioc_hold,
+ zfs_secpolicy_hold);
+ zfs_ioctl_register_dataset_modify(ZFS_IOC_RELEASE, zfs_ioc_release,
+ zfs_secpolicy_release);
+ zfs_ioctl_register_dataset_modify(ZFS_IOC_INHERIT_PROP,
+ zfs_ioc_inherit_prop, zfs_secpolicy_inherit_prop);
+ zfs_ioctl_register_dataset_modify(ZFS_IOC_SET_FSACL, zfs_ioc_set_fsacl,
+ zfs_secpolicy_set_fsacl);
+
+ zfs_ioctl_register_dataset_nolog(ZFS_IOC_SHARE, zfs_ioc_share,
+ zfs_secpolicy_share, POOL_CHECK_NONE);
+ zfs_ioctl_register_dataset_nolog(ZFS_IOC_SMB_ACL, zfs_ioc_smb_acl,
+ zfs_secpolicy_smb_acl, POOL_CHECK_NONE);
+ zfs_ioctl_register_dataset_nolog(ZFS_IOC_USERSPACE_UPGRADE,
+ zfs_ioc_userspace_upgrade, zfs_secpolicy_userspace_upgrade,
+ POOL_CHECK_SUSPENDED | POOL_CHECK_READONLY);
+ zfs_ioctl_register_dataset_nolog(ZFS_IOC_TMP_SNAPSHOT,
+ zfs_ioc_tmp_snapshot, zfs_secpolicy_tmp_snapshot,
+ POOL_CHECK_SUSPENDED | POOL_CHECK_READONLY);
+}
int
pool_status_check(const char *name, zfs_ioc_namecheck_t type,
@@ -5066,67 +5615,145 @@ static int
zfsdev_ioctl(dev_t dev, int cmd, intptr_t arg, int flag, cred_t *cr, int *rvalp)
{
zfs_cmd_t *zc;
- uint_t vec;
- int error, rc;
+ uint_t vecnum;
+ int error, rc, len;
minor_t minor = getminor(dev);
+ const zfs_ioc_vec_t *vec;
+ char *saved_poolname = NULL;
+ nvlist_t *innvl = NULL;
if (minor != 0 &&
zfsdev_get_soft_state(minor, ZSST_CTLDEV) == NULL)
return (zvol_ioctl(dev, cmd, arg, flag, cr, rvalp));
- vec = cmd - ZFS_IOC;
+ vecnum = cmd - ZFS_IOC_FIRST;
ASSERT3U(getmajor(dev), ==, ddi_driver_major(zfs_dip));
- if (vec >= sizeof (zfs_ioc_vec) / sizeof (zfs_ioc_vec[0]))
+ if (vecnum >= sizeof (zfs_ioc_vec) / sizeof (zfs_ioc_vec[0]))
return (EINVAL);
+ vec = &zfs_ioc_vec[vecnum];
zc = kmem_zalloc(sizeof (zfs_cmd_t), KM_SLEEP);
error = ddi_copyin((void *)arg, zc, sizeof (zfs_cmd_t), flag);
- if (error != 0)
+ if (error != 0) {
error = EFAULT;
+ goto out;
+ }
- if ((error == 0) && !(flag & FKIOCTL))
- error = zfs_ioc_vec[vec].zvec_secpolicy(zc, cr);
+ zc->zc_iflags = flag & FKIOCTL;
+ if (zc->zc_nvlist_src_size != 0) {
+ error = get_nvlist(zc->zc_nvlist_src, zc->zc_nvlist_src_size,
+ zc->zc_iflags, &innvl);
+ if (error != 0)
+ goto out;
+ }
/*
* Ensure that all pool/dataset names are valid before we pass down to
* the lower layers.
*/
- if (error == 0) {
- zc->zc_name[sizeof (zc->zc_name) - 1] = '\0';
- zc->zc_iflags = flag & FKIOCTL;
- switch (zfs_ioc_vec[vec].zvec_namecheck) {
- case POOL_NAME:
- if (pool_namecheck(zc->zc_name, NULL, NULL) != 0)
- error = EINVAL;
+ zc->zc_name[sizeof (zc->zc_name) - 1] = '\0';
+ switch (vec->zvec_namecheck) {
+ case POOL_NAME:
+ if (pool_namecheck(zc->zc_name, NULL, NULL) != 0)
+ error = EINVAL;
+ else
error = pool_status_check(zc->zc_name,
- zfs_ioc_vec[vec].zvec_namecheck,
- zfs_ioc_vec[vec].zvec_pool_check);
- break;
+ vec->zvec_namecheck, vec->zvec_pool_check);
+ break;
- case DATASET_NAME:
- if (dataset_namecheck(zc->zc_name, NULL, NULL) != 0)
- error = EINVAL;
+ case DATASET_NAME:
+ if (dataset_namecheck(zc->zc_name, NULL, NULL) != 0)
+ error = EINVAL;
+ else
error = pool_status_check(zc->zc_name,
- zfs_ioc_vec[vec].zvec_namecheck,
- zfs_ioc_vec[vec].zvec_pool_check);
- break;
+ vec->zvec_namecheck, vec->zvec_pool_check);
+ break;
- case NO_NAME:
- break;
- }
+ case NO_NAME:
+ break;
}
- if (error == 0)
- error = zfs_ioc_vec[vec].zvec_func(zc);
+ if (error == 0 && !(flag & FKIOCTL))
+ error = vec->zvec_secpolicy(zc, innvl, cr);
+
+ if (error != 0)
+ goto out;
+
+ /* legacy ioctls can modify zc_name */
+ len = strcspn(zc->zc_name, "/@") + 1;
+ saved_poolname = kmem_alloc(len, KM_SLEEP);
+ (void) strlcpy(saved_poolname, zc->zc_name, len);
+
+ if (vec->zvec_func != NULL) {
+ nvlist_t *outnvl;
+ int puterror = 0;
+ spa_t *spa;
+ nvlist_t *lognv = NULL;
+
+ ASSERT(vec->zvec_legacy_func == NULL);
+
+ /*
+ * Add the innvl to the lognv before calling the func,
+ * in case the func changes the innvl.
+ */
+ if (vec->zvec_allow_log) {
+ lognv = fnvlist_alloc();
+ fnvlist_add_string(lognv, ZPOOL_HIST_IOCTL,
+ vec->zvec_name);
+ if (!nvlist_empty(innvl)) {
+ fnvlist_add_nvlist(lognv, ZPOOL_HIST_INPUT_NVL,
+ innvl);
+ }
+ }
+
+ outnvl = fnvlist_alloc();
+ error = vec->zvec_func(zc->zc_name, innvl, outnvl);
+
+ if (error == 0 && vec->zvec_allow_log &&
+ spa_open(zc->zc_name, &spa, FTAG) == 0) {
+ if (!nvlist_empty(outnvl)) {
+ fnvlist_add_nvlist(lognv, ZPOOL_HIST_OUTPUT_NVL,
+ outnvl);
+ }
+ (void) spa_history_log_nvl(spa, lognv);
+ spa_close(spa, FTAG);
+ }
+ fnvlist_free(lognv);
+
+ if (!nvlist_empty(outnvl) || zc->zc_nvlist_dst_size != 0) {
+ int smusherror = 0;
+ if (vec->zvec_smush_outnvlist) {
+ smusherror = nvlist_smush(outnvl,
+ zc->zc_nvlist_dst_size);
+ }
+ if (smusherror == 0)
+ puterror = put_nvlist(zc, outnvl);
+ }
+
+ if (puterror != 0)
+ error = puterror;
+
+ nvlist_free(outnvl);
+ } else {
+ error = vec->zvec_legacy_func(zc);
+ }
+
+out:
+ nvlist_free(innvl);
rc = ddi_copyout(zc, (void *)arg, sizeof (zfs_cmd_t), flag);
- if (error == 0) {
- if (rc != 0)
- error = EFAULT;
- if (zfs_ioc_vec[vec].zvec_his_log)
- zfs_log_history(zc);
+ if (error == 0 && rc != 0)
+ error = EFAULT;
+ if (error == 0 && vec->zvec_allow_log) {
+ char *s = tsd_get(zfs_allow_log_key);
+ if (s != NULL)
+ strfree(s);
+ (void) tsd_set(zfs_allow_log_key, saved_poolname);
+ } else {
+ if (saved_poolname != NULL)
+ strfree(saved_poolname);
}
kmem_free(zc, sizeof (zfs_cmd_t));
@@ -5242,9 +5869,12 @@ static struct modlinkage modlinkage = {
NULL
};
-
-uint_t zfs_fsyncer_key;
-extern uint_t rrw_tsd_key;
+static void
+zfs_allow_log_destroy(void *arg)
+{
+ char *poolname = arg;
+ strfree(poolname);
+}
int
_init(void)
@@ -5254,6 +5884,7 @@ _init(void)
spa_init(FREAD | FWRITE);
zfs_init();
zvol_init();
+ zfs_ioctl_init();
if ((error = mod_install(&modlinkage)) != 0) {
zvol_fini();
@@ -5263,7 +5894,8 @@ _init(void)
}
tsd_create(&zfs_fsyncer_key, NULL);
- tsd_create(&rrw_tsd_key, NULL);
+ tsd_create(&rrw_tsd_key, rrw_tsd_destroy);
+ tsd_create(&zfs_allow_log_key, zfs_allow_log_destroy);
error = ldi_ident_from_mod(&modlinkage, &zfs_li);
ASSERT(error == 0);
diff --git a/usr/src/uts/common/fs/zfs/zfs_vfsops.c b/usr/src/uts/common/fs/zfs/zfs_vfsops.c
index 14b888b29e..21ac731c1e 100644
--- a/usr/src/uts/common/fs/zfs/zfs_vfsops.c
+++ b/usr/src/uts/common/fs/zfs/zfs_vfsops.c
@@ -20,6 +20,7 @@
*/
/*
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012 by Delphix. All rights reserved.
*/
/* Portions Copyright 2010 Robert Milkowski */
@@ -2248,9 +2249,8 @@ zfs_set_version(zfsvfs_t *zfsvfs, uint64_t newvers)
sa_register_update_callback(os, zfs_sa_upgrade);
}
- spa_history_log_internal(LOG_DS_UPGRADE,
- dmu_objset_spa(os), tx, "oldver=%llu newver=%llu dataset = %llu",
- zfsvfs->z_version, newvers, dmu_objset_id(os));
+ spa_history_log_internal_ds(dmu_objset_ds(os), "upgrade", tx,
+ "from %llu to %llu", zfsvfs->z_version, newvers);
dmu_tx_commit(tx);
diff --git a/usr/src/uts/common/fs/zfs/zio.c b/usr/src/uts/common/fs/zfs/zio.c
index 89c88bc181..c6feed86bf 100644
--- a/usr/src/uts/common/fs/zfs/zio.c
+++ b/usr/src/uts/common/fs/zfs/zio.c
@@ -625,7 +625,7 @@ zio_write(zio_t *pio, spa_t *spa, uint64_t txg, blkptr_t *bp,
zp->zp_checksum < ZIO_CHECKSUM_FUNCTIONS &&
zp->zp_compress >= ZIO_COMPRESS_OFF &&
zp->zp_compress < ZIO_COMPRESS_FUNCTIONS &&
- zp->zp_type < DMU_OT_NUMTYPES &&
+ DMU_OT_IS_VALID(zp->zp_type) &&
zp->zp_level < 32 &&
zp->zp_copies > 0 &&
zp->zp_copies <= spa_max_replication(spa) &&
@@ -911,7 +911,7 @@ zio_read_bp_init(zio_t *zio)
zio_push_transform(zio, cbuf, psize, psize, zio_decompress);
}
- if (!dmu_ot[BP_GET_TYPE(bp)].ot_metadata && BP_GET_LEVEL(bp) == 0)
+ if (!DMU_OT_IS_METADATA(BP_GET_TYPE(bp)) && BP_GET_LEVEL(bp) == 0)
zio->io_flags |= ZIO_FLAG_DONT_CACHE;
if (BP_GET_TYPE(bp) == DMU_OT_DDT_ZAP)
@@ -3000,3 +3000,45 @@ static zio_pipe_stage_t *zio_pipeline[] = {
zio_checksum_verify,
zio_done
};
+
+/* dnp is the dnode for zb1->zb_object */
+boolean_t
+zbookmark_is_before(const dnode_phys_t *dnp, const zbookmark_t *zb1,
+ const zbookmark_t *zb2)
+{
+ uint64_t zb1nextL0, zb2thisobj;
+
+ ASSERT(zb1->zb_objset == zb2->zb_objset);
+ ASSERT(zb2->zb_level == 0);
+
+ /*
+ * A bookmark in the deadlist is considered to be after
+ * everything else.
+ */
+ if (zb2->zb_object == DMU_DEADLIST_OBJECT)
+ return (B_TRUE);
+
+ /* The objset_phys_t isn't before anything. */
+ if (dnp == NULL)
+ return (B_FALSE);
+
+ zb1nextL0 = (zb1->zb_blkid + 1) <<
+ ((zb1->zb_level) * (dnp->dn_indblkshift - SPA_BLKPTRSHIFT));
+
+ zb2thisobj = zb2->zb_object ? zb2->zb_object :
+ zb2->zb_blkid << (DNODE_BLOCK_SHIFT - DNODE_SHIFT);
+
+ if (zb1->zb_object == DMU_META_DNODE_OBJECT) {
+ uint64_t nextobj = zb1nextL0 *
+ (dnp->dn_datablkszsec << SPA_MINBLOCKSHIFT) >> DNODE_SHIFT;
+ return (nextobj <= zb2thisobj);
+ }
+
+ if (zb1->zb_object < zb2thisobj)
+ return (B_TRUE);
+ if (zb1->zb_object > zb2thisobj)
+ return (B_FALSE);
+ if (zb2->zb_object == DMU_META_DNODE_OBJECT)
+ return (B_FALSE);
+ return (zb1nextL0 <= zb2->zb_blkid);
+}
diff --git a/usr/src/uts/common/fs/zfs/zvol.c b/usr/src/uts/common/fs/zfs/zvol.c
index 4dc63888fd..f0a7fe7ece 100644
--- a/usr/src/uts/common/fs/zfs/zvol.c
+++ b/usr/src/uts/common/fs/zfs/zvol.c
@@ -24,6 +24,7 @@
* Portions Copyright 2010 Robert Milkowski
*
* Copyright 2011 Nexenta Systems, Inc. All rights reserved.
+ * Copyright (c) 2012 by Delphix. All rights reserved.
*/
/*
@@ -137,7 +138,7 @@ typedef struct zvol_state {
int zvol_maxphys = DMU_MAX_ACCESS/2;
extern int zfs_set_prop_nvlist(const char *, zprop_source_t,
- nvlist_t *, nvlist_t **);
+ nvlist_t *, nvlist_t *);
static int zvol_remove_zv(zvol_state_t *);
static int zvol_get_data(void *arg, lr_write_t *lr, char *buf, zio_t *zio);
static int zvol_dumpify(zvol_state_t *zv);
@@ -1909,7 +1910,7 @@ zvol_dumpify(zvol_state_t *zv)
if (zap_lookup(zv->zv_objset, ZVOL_ZAP_OBJ, ZVOL_DUMPSIZE,
8, 1, &dumpsize) != 0 || dumpsize != zv->zv_volsize) {
- boolean_t resize = (dumpsize > 0) ? B_TRUE : B_FALSE;
+ boolean_t resize = (dumpsize > 0);
if ((error = zvol_dump_init(zv, resize)) != 0) {
(void) zvol_dump_fini(zv);
diff --git a/usr/src/uts/common/io/blkdev/blkdev.c b/usr/src/uts/common/io/blkdev/blkdev.c
index 7b722f126c..497bf8d9d3 100644
--- a/usr/src/uts/common/io/blkdev/blkdev.c
+++ b/usr/src/uts/common/io/blkdev/blkdev.c
@@ -20,7 +20,7 @@
*/
/*
* Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
+ * Copyright 2011, 2012 Nexenta Systems, Inc. All rights reserved.
* Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved.
*/
@@ -396,10 +396,13 @@ bd_attach(dev_info_t *dip, ddi_attach_cmd_t cmd)
bzero(&drive, sizeof (drive));
bd->d_ops.o_drive_info(bd->d_private, &drive);
bd->d_qsize = drive.d_qsize;
- bd->d_maxxfer = drive.d_maxxfer;
bd->d_removable = drive.d_removable;
bd->d_hotpluggable = drive.d_hotpluggable;
+ if (drive.d_maxxfer && drive.d_maxxfer < bd->d_maxxfer)
+ bd->d_maxxfer = drive.d_maxxfer;
+
+
rv = cmlb_attach(dip, &bd_tg_ops, DTYPE_DIRECT,
bd->d_removable, bd->d_hotpluggable,
drive.d_lun >= 0 ? DDI_NT_BLOCK_CHAN : DDI_NT_BLOCK,
@@ -556,7 +559,6 @@ bd_xfer_alloc(bd_t *bd, struct buf *bp, int (*func)(void *, bd_xfer_t *),
}
ASSERT(bp);
- ASSERT(bp->b_bcount);
xi->i_bp = bp;
xi->i_func = func;
@@ -900,32 +902,51 @@ bd_dump(dev_t dev, caddr_t caddr, daddr_t blkno, int nblk)
return (rv);
}
+void
+bd_minphys(struct buf *bp)
+{
+ minor_t inst;
+ bd_t *bd;
+ inst = BDINST(bp->b_edev);
+
+ bd = ddi_get_soft_state(bd_state, inst);
+
+ /*
+ * In a non-debug kernel, bd_strategy will catch !bd as
+ * well, and will fail nicely.
+ */
+ ASSERT(bd);
+
+ if (bp->b_bcount > bd->d_maxxfer)
+ bp->b_bcount = bd->d_maxxfer;
+}
+
static int
bd_read(dev_t dev, struct uio *uio, cred_t *credp)
{
_NOTE(ARGUNUSED(credp));
- return (physio(bd_strategy, NULL, dev, B_READ, minphys, uio));
+ return (physio(bd_strategy, NULL, dev, B_READ, bd_minphys, uio));
}
static int
bd_write(dev_t dev, struct uio *uio, cred_t *credp)
{
_NOTE(ARGUNUSED(credp));
- return (physio(bd_strategy, NULL, dev, B_WRITE, minphys, uio));
+ return (physio(bd_strategy, NULL, dev, B_WRITE, bd_minphys, uio));
}
static int
bd_aread(dev_t dev, struct aio_req *aio, cred_t *credp)
{
_NOTE(ARGUNUSED(credp));
- return (aphysio(bd_strategy, anocancel, dev, B_READ, minphys, aio));
+ return (aphysio(bd_strategy, anocancel, dev, B_READ, bd_minphys, aio));
}
static int
bd_awrite(dev_t dev, struct aio_req *aio, cred_t *credp)
{
_NOTE(ARGUNUSED(credp));
- return (aphysio(bd_strategy, anocancel, dev, B_WRITE, minphys, aio));
+ return (aphysio(bd_strategy, anocancel, dev, B_WRITE, bd_minphys, aio));
}
static int
@@ -1095,9 +1116,11 @@ bd_ioctl(dev_t dev, int cmd, intptr_t arg, int flag, cred_t *credp, int *rvalp)
return (0);
}
case DKIOCFLUSHWRITECACHE: {
- struct dk_callback *dkc;
+ struct dk_callback *dkc = NULL;
+
+ if (flag & FKIOCTL)
+ dkc = (void *)arg;
- dkc = flag & FKIOCTL ? (void *)arg : NULL;
rv = bd_flush_write_cache(bd, dkc);
return (rv);
}
@@ -1438,24 +1461,24 @@ bd_flush_write_cache(bd_t *bd, struct dk_callback *dkc)
return (rv);
}
- if (dkc != NULL) {
+ /* Make an asynchronous flush, but only if there is a callback */
+ if (dkc != NULL && dkc->dkc_callback != NULL) {
/* Make a private copy of the callback structure */
dc = kmem_alloc(sizeof (*dc), KM_SLEEP);
*dc = *dkc;
bp->b_private = dc;
bp->b_iodone = bd_flush_write_cache_done;
+
+ bd_submit(bd, xi);
+ return (0);
}
+ /* In case there is no callback, perform a synchronous flush */
bd_submit(bd, xi);
- if (dkc == NULL) {
- /* wait synchronously */
- (void) biowait(bp);
- rv = geterror(bp);
- freerbuf(bp);
- } else {
- /* deferred via callback */
- rv = 0;
- }
+ (void) biowait(bp);
+ rv = geterror(bp);
+ freerbuf(bp);
+
return (rv);
}
@@ -1593,7 +1616,7 @@ bd_xfer_done(bd_xfer_t *xfer, int err)
{
bd_xfer_impl_t *xi = (void *)xfer;
buf_t *bp = xi->i_bp;
- int rv;
+ int rv = DDI_SUCCESS;
bd_t *bd = xi->i_bd;
size_t len;
diff --git a/usr/src/uts/common/io/comstar/port/iscsit/iscsit.c b/usr/src/uts/common/io/comstar/port/iscsit/iscsit.c
index 59bdf682e0..46d4341bc5 100644
--- a/usr/src/uts/common/io/comstar/port/iscsit/iscsit.c
+++ b/usr/src/uts/common/io/comstar/port/iscsit/iscsit.c
@@ -20,9 +20,8 @@
*/
/*
* Copyright (c) 2008, 2010, Oracle and/or its affiliates. All rights reserved.
- */
-/*
- * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
+ *
+ * Copyright 2012 Nexenta Systems, Inc. All rights reserved.
*/
#include <sys/cpuvar.h>
@@ -3161,9 +3160,21 @@ iscsit_add_pdu_to_queue(iscsit_sess_t *ist, idm_pdu_t *rx_pdu)
mutex_exit(&ict->ict_mutex);
index = ntohl(cmdsn) % ISCSIT_RXPDU_QUEUE_LEN;
- ASSERT(cbuf->cb_buffer[index] == NULL);
- cbuf->cb_buffer[index] = rx_pdu;
- cbuf->cb_num_elems++;
+ /*
+ * In the normal case, assuming that the Initiator is not
+ * buggy and that we don't have packet duplication occuring,
+ * the entry in the array will be NULL. However, we may have
+ * received a duplicate PDU with cmdsn > expsn , and in that
+ * case we just ignore this PDU -- the previously received one
+ * remains queued for processing. We need to be careful not
+ * to leak this one however.
+ */
+ if (cbuf->cb_buffer[index] != NULL) {
+ idm_pdu_complete(rx_pdu, IDM_STATUS_FAIL);
+ } else {
+ cbuf->cb_buffer[index] = rx_pdu;
+ cbuf->cb_num_elems++;
+ }
}
static idm_pdu_t *
diff --git a/usr/src/uts/common/io/fibre-channel/fca/fcoei/fcoei_eth.c b/usr/src/uts/common/io/fibre-channel/fca/fcoei/fcoei_eth.c
index 249d0ffabd..889ee6ac11 100644
--- a/usr/src/uts/common/io/fibre-channel/fca/fcoei/fcoei_eth.c
+++ b/usr/src/uts/common/io/fibre-channel/fca/fcoei/fcoei_eth.c
@@ -969,7 +969,7 @@ fcoei_fill_els_fpkt_resp(fcoe_frame_t *frm, fcoei_exchange_t *xch, int size)
prli_acc->image_pair_established =
(FCOE_B2V_2(src + offset) & BIT_13) ? 1 : 0;
prli_acc->accept_response_code =
- (uint16_t)(FCOE_B2V_2(src + offset) & 0x0F00);
+ (FCOE_B2V_2(src + offset) & 0x0F00) >> 8;
/*
* process associator
*/
diff --git a/usr/src/uts/common/io/fibre-channel/fca/fcoei/fcoei_lv.c b/usr/src/uts/common/io/fibre-channel/fca/fcoei/fcoei_lv.c
index 66a61e620e..abf1c26387 100644
--- a/usr/src/uts/common/io/fibre-channel/fca/fcoei/fcoei_lv.c
+++ b/usr/src/uts/common/io/fibre-channel/fca/fcoei/fcoei_lv.c
@@ -1089,16 +1089,16 @@ fcoei_initiate_fcp_cmd(fcoei_exchange_t *xch)
frm->frm_payload[offset] = fcp_cmd_iu->fcp_cntl.cntl_qtype & 0x07;
offset += 1;
frm->frm_payload[offset] =
- (fcp_cmd_iu->fcp_cntl.cntl_kill_tsk * BIT_7) |
- (fcp_cmd_iu->fcp_cntl.cntl_clr_aca * BIT_6) |
- (fcp_cmd_iu->fcp_cntl.cntl_reset_tgt * BIT_5) |
- (fcp_cmd_iu->fcp_cntl.cntl_reset_lun * BIT_4) |
- (fcp_cmd_iu->fcp_cntl.cntl_clr_tsk * BIT_2) |
- (fcp_cmd_iu->fcp_cntl.cntl_abort_tsk * BIT_1);
+ (fcp_cmd_iu->fcp_cntl.cntl_kill_tsk << 7) |
+ (fcp_cmd_iu->fcp_cntl.cntl_clr_aca << 6) |
+ (fcp_cmd_iu->fcp_cntl.cntl_reset_tgt << 5) |
+ (fcp_cmd_iu->fcp_cntl.cntl_reset_lun << 4) |
+ (fcp_cmd_iu->fcp_cntl.cntl_clr_tsk << 2) |
+ (fcp_cmd_iu->fcp_cntl.cntl_abort_tsk << 1);
offset += 1;
frm->frm_payload[offset] =
- (fcp_cmd_iu->fcp_cntl.cntl_read_data * BIT_1) |
- (fcp_cmd_iu->fcp_cntl.cntl_write_data * BIT_0);
+ (fcp_cmd_iu->fcp_cntl.cntl_read_data << 1) |
+ (fcp_cmd_iu->fcp_cntl.cntl_write_data);
/*
* fcp_cdb
*/
@@ -1455,9 +1455,10 @@ fcoei_fill_els_prli_cmd(fc_packet_t *fpkt, fcoe_frame_t *frm)
* PRLI flags, only 3 bits are valid
*/
offset = 6;
- FCOE_V2B_2((uint8_t)((fcp_spp->orig_process_assoc_valid * BIT_15) |
- (fcp_spp->resp_process_assoc_valid * BIT_14) |
- (fcp_spp->establish_image_pair * BIT_13)), FPLD + offset);
+
+ FCOE_V2B_2(((fcp_spp->orig_process_assoc_valid << 15) |
+ (fcp_spp->resp_process_assoc_valid << 14) |
+ (fcp_spp->establish_image_pair << 13)), FPLD + offset);
/*
* process associator
@@ -1472,12 +1473,12 @@ fcoei_fill_els_prli_cmd(fc_packet_t *fpkt, fcoe_frame_t *frm)
* FC-4 type
*/
offset = 16;
- FCOE_V2B_4((fcp_spp->retry * BIT_8) |
- (fcp_spp->confirmed_compl_allowed * BIT_7) |
- (fcp_spp->data_overlay_allowed * BIT_6) |
- (fcp_spp->initiator_fn * BIT_5) | (fcp_spp->target_fn * BIT_4) |
- (fcp_spp->read_xfer_rdy_disabled * BIT_1) |
- (fcp_spp->write_xfer_rdy_disabled * BIT_0), FPLD + offset);
+ FCOE_V2B_4((fcp_spp->retry << 8) |
+ (fcp_spp->confirmed_compl_allowed << 7) |
+ (fcp_spp->data_overlay_allowed << 6) |
+ (fcp_spp->initiator_fn << 5) | (fcp_spp->target_fn << 4) |
+ (fcp_spp->read_xfer_rdy_disabled << 1) |
+ (fcp_spp->write_xfer_rdy_disabled), FPLD + offset);
}
/*
diff --git a/usr/src/uts/common/io/scsi/adapters/mpt_sas/mptsas.c b/usr/src/uts/common/io/scsi/adapters/mpt_sas/mptsas.c
index 7d7bf7a032..e7974fb538 100644
--- a/usr/src/uts/common/io/scsi/adapters/mpt_sas/mptsas.c
+++ b/usr/src/uts/common/io/scsi/adapters/mpt_sas/mptsas.c
@@ -21,6 +21,7 @@
/*
* Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright 2012 Nexenta Systems, Inc. All rights reserved.
*/
/*
@@ -1761,7 +1762,7 @@ mptsas_do_detach(dev_info_t *dip)
MPTSAS_DISABLE_INTR(mpt);
mptsas_raid_action_system_shutdown(mpt);
mpt->m_softstate |= MPTSAS_SS_MSG_UNIT_RESET;
- (void) mptsas_ioc_reset(mpt);
+ (void) mptsas_ioc_reset(mpt, FALSE);
mutex_exit(&mpt->m_mutex);
mptsas_rem_intrs(mpt);
ddi_taskq_destroy(mpt->m_event_taskq);
@@ -12338,7 +12339,7 @@ mptsas_init_chip(mptsas_t *mpt, int first_time)
/*
* Reset the chip
*/
- rval = mptsas_ioc_reset(mpt);
+ rval = mptsas_ioc_reset(mpt, first_time);
if (rval == MPTSAS_RESET_FAIL) {
mptsas_log(mpt, CE_WARN, "hard reset failed!");
goto fail;
diff --git a/usr/src/uts/common/io/scsi/adapters/mpt_sas/mptsas_impl.c b/usr/src/uts/common/io/scsi/adapters/mpt_sas/mptsas_impl.c
index b1aa4f8ee6..af35fe3aac 100644
--- a/usr/src/uts/common/io/scsi/adapters/mpt_sas/mptsas_impl.c
+++ b/usr/src/uts/common/io/scsi/adapters/mpt_sas/mptsas_impl.c
@@ -21,6 +21,7 @@
/*
* Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright 2012 Nexenta Systems, Inc. All rights reserved.
*/
/*
@@ -955,7 +956,7 @@ mptsas_kick_start(mptsas_t *mpt)
}
int
-mptsas_ioc_reset(mptsas_t *mpt)
+mptsas_ioc_reset(mptsas_t *mpt, int first_time)
{
int polls = 0;
uint32_t reset_msg;
@@ -973,8 +974,16 @@ mptsas_ioc_reset(mptsas_t *mpt)
* it a message unit reset to put it back in the ready state
*/
if (ioc_state & MPI2_IOC_STATE_OPERATIONAL) {
- if (mpt->m_event_replay && (mpt->m_softstate &
- MPTSAS_SS_MSG_UNIT_RESET)) {
+ /*
+ * If the first time, try MUR anyway, because we haven't even
+ * queried the card for m_event_replay and other capabilities.
+ * Other platforms do it this way, we can still do a hard
+ * reset if we need to, MUR takes less time than a full
+ * adapter reset, and there are reports that some HW
+ * combinations will lock up when receiving a hard reset.
+ */
+ if ((first_time || mpt->m_event_replay) &&
+ (mpt->m_softstate & MPTSAS_SS_MSG_UNIT_RESET)) {
mpt->m_softstate &= ~MPTSAS_SS_MSG_UNIT_RESET;
reset_msg = MPI2_FUNCTION_IOC_MESSAGE_UNIT_RESET;
ddi_put32(mpt->m_datap, &mpt->m_reg->Doorbell,
diff --git a/usr/src/uts/common/io/usb/clients/usbser/usbftdi/uftdi_dsd.c b/usr/src/uts/common/io/usb/clients/usbser/usbftdi/uftdi_dsd.c
index 62a57618b0..97e73e907e 100644
--- a/usr/src/uts/common/io/usb/clients/usbser/usbftdi/uftdi_dsd.c
+++ b/usr/src/uts/common/io/usb/clients/usbser/usbftdi/uftdi_dsd.c
@@ -95,11 +95,11 @@ static usb_pipe_handle_t uftdi_in_pipe(ds_hdl_t, uint_t);
/* configuration routines */
static void uftdi_cleanup(uftdi_state_t *, int);
static int uftdi_dev_attach(uftdi_state_t *);
-static int uftdi_open_hw_port(uftdi_state_t *, int, int);
+static int uftdi_open_hw_port(uftdi_state_t *, int);
/* hotplug */
static int uftdi_restore_device_state(uftdi_state_t *);
-static int uftdi_restore_port_state(uftdi_state_t *, int);
+static int uftdi_restore_port_state(uftdi_state_t *);
/* power management */
static int uftdi_create_pm_components(uftdi_state_t *);
@@ -202,6 +202,8 @@ uftdi_attach(ds_attach_info_t *aip)
return (USB_FAILURE);
}
+ uf->uf_hwport = FTDI_PIT_SIOA + uf->uf_dev_data->dev_curr_if;
+
mutex_init(&uf->uf_lock, NULL, MUTEX_DRIVER,
uf->uf_dev_data->dev_iblock_cookie);
@@ -281,6 +283,15 @@ uftdi_attach(ds_attach_info_t *aip)
break;
}
break;
+ case USB_VENDOR_MARVELL:
+ switch (dd->idProduct) {
+ case USB_PRODUCT_MARVELL_SHEEVAPLUG_JTAG:
+ break;
+ default:
+ recognized = B_FALSE;
+ break;
+ }
+ break;
default:
recognized = B_FALSE;
break;
@@ -296,8 +307,8 @@ uftdi_attach(ds_attach_info_t *aip)
}
USB_DPRINTF_L3(DPRINT_ATTACH, uf->uf_lh,
- "uftdi: matched vendor 0x%x product 0x%x",
- dd->idVendor, dd->idProduct);
+ "uftdi: matched vendor 0x%x product 0x%x port %d",
+ dd->idVendor, dd->idProduct, uf->uf_hwport);
uf->uf_def_ph = uf->uf_dev_data->dev_default_ph;
@@ -363,6 +374,8 @@ uftdi_register_cb(ds_hdl_t hdl, uint_t portno, ds_cb_t *cb)
{
uftdi_state_t *uf = (uftdi_state_t *)hdl;
+ ASSERT(portno == 0);
+
uf->uf_cb = *cb;
return (USB_SUCCESS);
}
@@ -377,6 +390,8 @@ uftdi_unregister_cb(ds_hdl_t hdl, uint_t portno)
{
uftdi_state_t *uf = (uftdi_state_t *)hdl;
+ ASSERT(portno == 0);
+
bzero(&uf->uf_cb, sizeof (uf->uf_cb));
}
@@ -393,6 +408,8 @@ uftdi_open_port(ds_hdl_t hdl, uint_t portno)
USB_DPRINTF_L4(DPRINT_OPEN, uf->uf_lh, "uftdi_open_port %d", portno);
+ ASSERT(portno == 0);
+
mutex_enter(&uf->uf_lock);
if (uf->uf_dev_state == USB_DEV_DISCONNECTED ||
uf->uf_port_state != UFTDI_PORT_CLOSED) {
@@ -405,7 +422,7 @@ uftdi_open_port(ds_hdl_t hdl, uint_t portno)
return (rval);
/* initialize hardware serial port */
- rval = uftdi_open_hw_port(uf, portno, 0);
+ rval = uftdi_open_hw_port(uf, 0);
if (rval == USB_SUCCESS) {
mutex_enter(&uf->uf_lock);
@@ -435,6 +452,8 @@ uftdi_close_port(ds_hdl_t hdl, uint_t portno)
USB_DPRINTF_L4(DPRINT_CLOSE, uf->uf_lh, "uftdi_close_port %d", portno);
+ ASSERT(portno == 0);
+
mutex_enter(&uf->uf_lock);
/* free resources and finalize state */
@@ -754,7 +773,7 @@ uftdi_param2regs(uftdi_state_t *uf, ds_port_params_t *tp, uftdi_regs_t *ur)
* If there are errors, return the device to its previous state.
*/
static int
-uftdi_setregs(uftdi_state_t *uf, uint_t portno, uftdi_regs_t *ur)
+uftdi_setregs(uftdi_state_t *uf, uftdi_regs_t *ur)
{
int rval;
uftdi_regs_t uold;
@@ -767,10 +786,10 @@ uftdi_setregs(uftdi_state_t *uf, uint_t portno, uftdi_regs_t *ur)
ur = &uold; /* NULL => restore previous values */
rval = uftdi_cmd_vendor_write0(uf, FTDI_SIO_SET_BAUD_RATE,
- ur->ur_baud, portno);
+ ur->ur_baud, uf->uf_hwport);
if (rval != USB_SUCCESS) {
(void) uftdi_cmd_vendor_write0(uf, FTDI_SIO_SET_BAUD_RATE,
- uold.ur_baud, portno);
+ uold.ur_baud, uf->uf_hwport);
goto out;
} else {
mutex_enter(&uf->uf_lock);
@@ -779,10 +798,10 @@ uftdi_setregs(uftdi_state_t *uf, uint_t portno, uftdi_regs_t *ur)
}
rval = uftdi_cmd_vendor_write0(uf, FTDI_SIO_SET_DATA,
- ur->ur_data, portno);
+ ur->ur_data, uf->uf_hwport);
if (rval != USB_SUCCESS) {
(void) uftdi_cmd_vendor_write0(uf, FTDI_SIO_SET_DATA,
- uold.ur_data, portno);
+ uold.ur_data, uf->uf_hwport);
goto out;
} else {
mutex_enter(&uf->uf_lock);
@@ -791,10 +810,10 @@ uftdi_setregs(uftdi_state_t *uf, uint_t portno, uftdi_regs_t *ur)
}
rval = uftdi_cmd_vendor_write0(uf, FTDI_SIO_SET_FLOW_CTRL,
- ur->ur_flowval, ur->ur_flowidx | portno);
+ ur->ur_flowval, ur->ur_flowidx | uf->uf_hwport);
if (rval != USB_SUCCESS) {
(void) uftdi_cmd_vendor_write0(uf, FTDI_SIO_SET_FLOW_CTRL,
- uold.ur_flowval, uold.ur_flowidx | portno);
+ uold.ur_flowval, uold.ur_flowidx | uf->uf_hwport);
goto out;
} else {
mutex_enter(&uf->uf_lock);
@@ -816,11 +835,13 @@ uftdi_set_port_params(ds_hdl_t hdl, uint_t portno, ds_port_params_t *tp)
int rval;
uftdi_regs_t uregs;
+ ASSERT(portno == 0);
+
USB_DPRINTF_L4(DPRINT_CTLOP, uf->uf_lh, "uftdi_set_port_params");
rval = uftdi_param2regs(uf, tp, &uregs);
if (rval == USB_SUCCESS)
- rval = uftdi_setregs(uf, portno, &uregs);
+ rval = uftdi_setregs(uf, &uregs);
return (rval);
}
@@ -834,6 +855,8 @@ uftdi_set_modem_ctl(ds_hdl_t hdl, uint_t portno, int mask, int val)
int rval;
uint16_t mctl;
+ ASSERT(portno == 0);
+
USB_DPRINTF_L4(DPRINT_CTLOP, uf->uf_lh, "uftdi_set_modem_ctl");
/*
@@ -846,7 +869,7 @@ uftdi_set_modem_ctl(ds_hdl_t hdl, uint_t portno, int mask, int val)
FTDI_SIO_SET_DTR_HIGH : FTDI_SIO_SET_DTR_LOW;
rval = uftdi_cmd_vendor_write0(uf,
- FTDI_SIO_MODEM_CTRL, mctl, portno);
+ FTDI_SIO_MODEM_CTRL, mctl, uf->uf_hwport);
if (rval == USB_SUCCESS) {
mutex_enter(&uf->uf_lock);
@@ -862,7 +885,7 @@ uftdi_set_modem_ctl(ds_hdl_t hdl, uint_t portno, int mask, int val)
FTDI_SIO_SET_RTS_HIGH : FTDI_SIO_SET_RTS_LOW;
rval = uftdi_cmd_vendor_write0(uf,
- FTDI_SIO_MODEM_CTRL, mctl, portno);
+ FTDI_SIO_MODEM_CTRL, mctl, uf->uf_hwport);
if (rval == USB_SUCCESS) {
mutex_enter(&uf->uf_lock);
@@ -929,6 +952,8 @@ uftdi_break_ctl(ds_hdl_t hdl, uint_t portno, int ctl)
uftdi_regs_t *ur = &uf->uf_softr;
uint16_t data;
+ ASSERT(portno == 0);
+
USB_DPRINTF_L4(DPRINT_CTLOP, uf->uf_lh, "uftdi_break_ctl");
mutex_enter(&uf->uf_lock);
@@ -936,7 +961,7 @@ uftdi_break_ctl(ds_hdl_t hdl, uint_t portno, int ctl)
mutex_exit(&uf->uf_lock);
return (uftdi_cmd_vendor_write0(uf, FTDI_SIO_SET_DATA,
- data, portno));
+ data, uf->uf_hwport));
}
@@ -949,6 +974,8 @@ uftdi_tx(ds_hdl_t hdl, uint_t portno, mblk_t *mp)
{
uftdi_state_t *uf = (uftdi_state_t *)hdl;
+ ASSERT(portno == 0);
+
USB_DPRINTF_L4(DPRINT_CTLOP, uf->uf_lh, "uftdi_tx");
ASSERT(mp != NULL && MBLKL(mp) >= 1);
@@ -972,6 +999,8 @@ uftdi_rx(ds_hdl_t hdl, uint_t portno)
uftdi_state_t *uf = (uftdi_state_t *)hdl;
mblk_t *mp;
+ ASSERT(portno == 0);
+
USB_DPRINTF_L4(DPRINT_CTLOP, uf->uf_lh, "uftdi_rx");
mutex_enter(&uf->uf_lock);
@@ -992,6 +1021,8 @@ uftdi_stop(ds_hdl_t hdl, uint_t portno, int dir)
{
uftdi_state_t *uf = (uftdi_state_t *)hdl;
+ ASSERT(portno == 0);
+
USB_DPRINTF_L4(DPRINT_CTLOP, uf->uf_lh, "uftdi_stop");
if (dir & DS_TX) {
@@ -1011,6 +1042,8 @@ uftdi_start(ds_hdl_t hdl, uint_t portno, int dir)
{
uftdi_state_t *uf = (uftdi_state_t *)hdl;
+ ASSERT(portno == 0);
+
USB_DPRINTF_L4(DPRINT_CTLOP, uf->uf_lh, "uftdi_start");
if (dir & DS_TX) {
@@ -1033,6 +1066,8 @@ uftdi_fifo_flush(ds_hdl_t hdl, uint_t portno, int dir)
{
uftdi_state_t *uf = (uftdi_state_t *)hdl;
+ ASSERT(portno == 0);
+
USB_DPRINTF_L4(DPRINT_CTLOP, uf->uf_lh,
"uftdi_fifo_flush: dir=0x%x", dir);
@@ -1052,11 +1087,11 @@ uftdi_fifo_flush(ds_hdl_t hdl, uint_t portno, int dir)
if (dir & DS_TX)
(void) uftdi_cmd_vendor_write0(uf,
- FTDI_SIO_RESET, FTDI_SIO_RESET_PURGE_TX, portno);
+ FTDI_SIO_RESET, FTDI_SIO_RESET_PURGE_TX, uf->uf_hwport);
if (dir & DS_RX)
(void) uftdi_cmd_vendor_write0(uf,
- FTDI_SIO_RESET, FTDI_SIO_RESET_PURGE_RX, portno);
+ FTDI_SIO_RESET, FTDI_SIO_RESET_PURGE_RX, uf->uf_hwport);
return (USB_SUCCESS);
}
@@ -1075,6 +1110,8 @@ uftdi_fifo_drain(ds_hdl_t hdl, uint_t portno, int timeout)
const uint8_t txempty =
FTDI_LSR_STATUS_TEMT | FTDI_LSR_STATUS_THRE;
+ ASSERT(portno == 0);
+
USB_DPRINTF_L4(DPRINT_CTLOP, uf->uf_lh, "uftdi_fifo_drain");
mutex_enter(&uf->uf_lock);
@@ -1194,7 +1231,7 @@ uftdi_restore_device_state(uftdi_state_t *uf)
state = uf->uf_dev_state = USB_DEV_ONLINE;
mutex_exit(&uf->uf_lock);
- if ((uftdi_restore_port_state(uf, 0) != USB_SUCCESS)) {
+ if ((uftdi_restore_port_state(uf) != USB_SUCCESS)) {
USB_DPRINTF_L2(DPRINT_HOTPLUG, uf->uf_lh,
"uftdi_restore_device_state: failed");
}
@@ -1207,7 +1244,7 @@ uftdi_restore_device_state(uftdi_state_t *uf)
* restore ports state after CPR resume or reconnect
*/
static int
-uftdi_restore_port_state(uftdi_state_t *uf, int portno)
+uftdi_restore_port_state(uftdi_state_t *uf)
{
int rval;
@@ -1219,7 +1256,7 @@ uftdi_restore_port_state(uftdi_state_t *uf, int portno)
mutex_exit(&uf->uf_lock);
/* open hardware serial port, restoring old settings */
- if ((rval = uftdi_open_hw_port(uf, portno, 1)) != USB_SUCCESS) {
+ if ((rval = uftdi_open_hw_port(uf, 1)) != USB_SUCCESS) {
USB_DPRINTF_L2(DPRINT_HOTPLUG, uf->uf_lh,
"uftdi_restore_port_state: failed");
}
@@ -1935,7 +1972,7 @@ uftdi_wait_tx_drain(uftdi_state_t *uf, int timeout)
* initialize hardware serial port
*/
static int
-uftdi_open_hw_port(uftdi_state_t *uf, int portno, int dorestore)
+uftdi_open_hw_port(uftdi_state_t *uf, int dorestore)
{
int rval;
@@ -1943,7 +1980,7 @@ uftdi_open_hw_port(uftdi_state_t *uf, int portno, int dorestore)
* Perform a full reset on the device
*/
rval = uftdi_cmd_vendor_write0(uf,
- FTDI_SIO_RESET, FTDI_SIO_RESET_SIO, portno);
+ FTDI_SIO_RESET, FTDI_SIO_RESET_SIO, uf->uf_hwport);
if (rval != USB_SUCCESS) {
USB_DPRINTF_L2(DPRINT_DEF_PIPE, uf->uf_lh,
"uftdi_open_hw_port: failed to reset!");
@@ -1954,7 +1991,7 @@ uftdi_open_hw_port(uftdi_state_t *uf, int portno, int dorestore)
/*
* Restore settings from our soft copy of HW registers
*/
- (void) uftdi_setregs(uf, portno, NULL);
+ (void) uftdi_setregs(uf, NULL);
} else {
/*
* 9600 baud, 2 stop bits, no parity, 8-bit, h/w flow control
@@ -1979,7 +2016,7 @@ uftdi_open_hw_port(uftdi_state_t *uf, int portno, int dorestore)
sizeof (ents) / sizeof (ents[0])
};
- rval = uftdi_set_port_params(uf, portno, &params);
+ rval = uftdi_set_port_params(uf, 0, &params);
if (rval != USB_SUCCESS) {
USB_DPRINTF_L2(DPRINT_DEF_PIPE, uf->uf_lh,
"uftdi_open_hw_port: failed 9600/2/n/8 rval %d",
@@ -2052,6 +2089,8 @@ uftdi_put_head(mblk_t **mpp, mblk_t *bp)
static usb_pipe_handle_t
uftdi_out_pipe(ds_hdl_t hdl, uint_t portno)
{
+ ASSERT(portno == 0);
+
return (((uftdi_state_t *)hdl)->uf_bulkout_ph);
}
@@ -2059,5 +2098,7 @@ uftdi_out_pipe(ds_hdl_t hdl, uint_t portno)
static usb_pipe_handle_t
uftdi_in_pipe(ds_hdl_t hdl, uint_t portno)
{
+ ASSERT(portno == 0);
+
return (((uftdi_state_t *)hdl)->uf_bulkin_ph);
}
diff --git a/usr/src/uts/common/io/usb/usbdevs b/usr/src/uts/common/io/usb/usbdevs
index 80318fed78..ba22bd81e2 100644
--- a/usr/src/uts/common/io/usb/usbdevs
+++ b/usr/src/uts/common/io/usb/usbdevs
@@ -675,6 +675,7 @@ vendor 3COM2 0x6891 3Com
vendor INTEL 0x8086 Intel
vendor SITECOM2 0x9016 Sitecom
vendor MOSCHIP 0x9710 MosChip Semiconductor
+vendor MARVELL 0x9e88 Marvell Technology Group Ltd.
vendor 3COM3 0xa727 3Com
vendor HP2 0xf003 Hewlett Packard
vendor USRP 0xfffe GNU Radio USRP
@@ -1664,6 +1665,9 @@ product LUWEN EASYDISK 0x0005 EasyDisc
/* Macally products */
product MACALLY MOUSE1 0x0101 mouse
+/* Marvell Technology Group, Ltd. products */
+product MARVELL SHEEVAPLUG_JTAG 0x9e8f SheevaPlug JTAGKey
+
/* MCT Corp. */
product MCT HUB0100 0x0100 Hub
product MCT DU_H3SP_USB232 0x0200 D-Link DU-H3SP USB BAY Hub
diff --git a/usr/src/uts/common/os/printf.c b/usr/src/uts/common/os/printf.c
index 1caedb33b6..c9e1524de0 100644
--- a/usr/src/uts/common/os/printf.c
+++ b/usr/src/uts/common/os/printf.c
@@ -21,6 +21,8 @@
/*
* Copyright 2009 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
+ *
+ * Copyright 2012 Nexenta Systems, Inc. All rights reserved.
*/
#include <sys/param.h>
@@ -48,6 +50,7 @@
#include <sys/panic.h>
#include <sys/spl.h>
#include <sys/zone.h>
+#include <sys/sunddi.h>
/*
* In some debugging situations it's useful to log all messages to panicbuf,
@@ -287,6 +290,21 @@ zcmn_err(zoneid_t zoneid, int ce, const char *fmt, ...)
va_end(adx);
}
+/*PRINTFLIKE3*/
+void
+dev_err(dev_info_t *dip, int ce, char *fmt, ...)
+{
+ va_list ap;
+ char buf[LOG_MSGSIZE];
+
+ (void) snprintf(buf, sizeof (buf), "%s%d: %s",
+ ddi_driver_name(dip), ddi_get_instance(dip), fmt);
+
+ va_start(ap, fmt);
+ vcmn_err(ce, buf, ap);
+ va_end(ap);
+}
+
int
assfail(const char *a, const char *f, int l)
{
diff --git a/usr/src/uts/common/os/vmem.c b/usr/src/uts/common/os/vmem.c
index d444def5cc..771c439744 100644
--- a/usr/src/uts/common/os/vmem.c
+++ b/usr/src/uts/common/os/vmem.c
@@ -24,6 +24,10 @@
*/
/*
+ * Copyright (c) 2012 by Delphix. All rights reserved.
+ */
+
+/*
* Big Theory Statement for the virtual memory allocator.
*
* For a more complete description of the main ideas, see:
@@ -1706,6 +1710,19 @@ vmem_update(void *dummy)
(void) timeout(vmem_update, dummy, vmem_update_interval * hz);
}
+void
+vmem_qcache_reap(vmem_t *vmp)
+{
+ int i;
+
+ /*
+ * Reap any quantum caches that may be part of this vmem.
+ */
+ for (i = 0; i < VMEM_NQCACHE_MAX; i++)
+ if (vmp->vm_qcache[i])
+ kmem_cache_reap_now(vmp->vm_qcache[i]);
+}
+
/*
* Prepare vmem for use.
*/
diff --git a/usr/src/uts/common/smbsrv/smb_kproto.h b/usr/src/uts/common/smbsrv/smb_kproto.h
index 317a48d000..a0c6766406 100644
--- a/usr/src/uts/common/smbsrv/smb_kproto.h
+++ b/usr/src/uts/common/smbsrv/smb_kproto.h
@@ -21,7 +21,7 @@
/*
* Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved.
- * Copyright 2011 Nexenta Systems, Inc. All rights reserved.
+ * Copyright 2012 Nexenta Systems, Inc. All rights reserved.
*/
/*
@@ -381,7 +381,7 @@ void smb_server_get_cfg(smb_server_t *, smb_kmod_cfg_t *);
int smb_server_spooldoc(smb_ioc_spooldoc_t *);
int smb_spool_add_doc(smb_kspooldoc_t *);
-int smb_spool_add_fid(uint16_t);
+void smb_spool_add_fid(smb_server_t *, uint16_t);
void smb_server_inc_nbt_sess(smb_server_t *);
void smb_server_dec_nbt_sess(smb_server_t *);
diff --git a/usr/src/uts/common/sys/ccompile.h b/usr/src/uts/common/sys/ccompile.h
index 956c056e95..690bb7afb7 100644
--- a/usr/src/uts/common/sys/ccompile.h
+++ b/usr/src/uts/common/sys/ccompile.h
@@ -83,13 +83,23 @@ extern "C" {
*
* Should only be used on 'extern inline' definitions for GCC.
*/
-#if __GNUC_VERSION >= 40300
+#if __GNUC_VERSION >= 40200
#define __sun_attr___gnu_inline__ __attribute__((__gnu_inline__))
#else
#define __sun_attr___gnu_inline__
#endif
/*
+ * The function has control flow such that it may return multiple times (in
+ * the manner of setjmp or vfork)
+ */
+#if __GNUC_VERSION >= 40100
+#define __sun_attr___returns_twice__ __attribute__((__returns_twice__))
+#else
+#define __sun_attr___returns_twice__
+#endif
+
+/*
* This is an appropriate label for functions that do not
* modify their arguments, e.g. strlen()
*/
@@ -126,6 +136,7 @@ extern "C" {
#define __KVPRINTFLIKE(__n) __sun_attr__((__KVPRINTFLIKE__(__n)))
#define __NORETURN __sun_attr__((__noreturn__))
#define __GNU_INLINE __inline__ __sun_attr__((__gnu_inline__))
+#define __RETURNS_TWICE __sun_attr__((__returns_twice__))
#define __CONST __sun_attr__((__const__))
#define __PURE __sun_attr__((__pure__))
diff --git a/usr/src/uts/common/sys/cmn_err.h b/usr/src/uts/common/sys/cmn_err.h
index e710d8e5c3..736c77b9dc 100644
--- a/usr/src/uts/common/sys/cmn_err.h
+++ b/usr/src/uts/common/sys/cmn_err.h
@@ -26,17 +26,19 @@
/*
* Copyright 2004 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
+ *
+ * Copyright 2012 Nexenta Systems, Inc. All rights reserved.
*/
#ifndef _SYS_CMN_ERR_H
#define _SYS_CMN_ERR_H
-#pragma ident "%Z%%M% %I% %E% SMI"
-
#if defined(_KERNEL) && !defined(_ASM)
#include <sys/va_list.h>
#endif
+#include <sys/dditypes.h>
+
#ifdef __cplusplus
extern "C" {
#endif
@@ -56,47 +58,40 @@ extern "C" {
/*PRINTFLIKE2*/
extern void cmn_err(int, const char *, ...)
__KPRINTFLIKE(2);
-#pragma rarely_called(cmn_err)
extern void vzcmn_err(zoneid_t, int, const char *, __va_list)
__KVPRINTFLIKE(3);
-#pragma rarely_called(vzcmn_err)
+
+extern void dev_err(dev_info_t *, int, char *, ...)
+ __KPRINTFLIKE(3);
extern void vcmn_err(int, const char *, __va_list)
__KVPRINTFLIKE(2);
-#pragma rarely_called(vcmn_err)
/*PRINTFLIKE3*/
extern void zcmn_err(zoneid_t, int, const char *, ...)
__KPRINTFLIKE(3);
-#pragma rarely_called(zcmn_err)
/*PRINTFLIKE1*/
extern void printf(const char *, ...)
__KPRINTFLIKE(1);
-#pragma rarely_called(printf)
extern void vzprintf(zoneid_t, const char *, __va_list)
__KVPRINTFLIKE(2);
-#pragma rarely_called(vzprintf)
/*PRINTFLIKE2*/
extern void zprintf(zoneid_t, const char *, ...)
__KPRINTFLIKE(2);
-#pragma rarely_called(zprintf)
extern void vprintf(const char *, __va_list)
__KVPRINTFLIKE(1);
-#pragma rarely_called(vprintf)
/*PRINTFLIKE1*/
extern void uprintf(const char *, ...)
__KPRINTFLIKE(1);
-#pragma rarely_called(uprintf)
extern void vuprintf(const char *, __va_list)
__KVPRINTFLIKE(1);
-#pragma rarely_called(vuprintf)
/*PRINTFLIKE3*/
extern size_t snprintf(char *, size_t, const char *, ...)
@@ -112,11 +107,9 @@ extern char *vsprintf(char *, const char *, __va_list)
/*PRINTFLIKE1*/
extern void panic(const char *, ...)
__KPRINTFLIKE(1) __NORETURN;
-#pragma rarely_called(panic)
extern void vpanic(const char *, __va_list)
__KVPRINTFLIKE(1) __NORETURN;
-#pragma rarely_called(vpanic)
#endif /* _KERNEL */
#endif /* !_ASM */
diff --git a/usr/src/uts/common/sys/dtrace.h b/usr/src/uts/common/sys/dtrace.h
index cafa7aa653..aef639bbbf 100644
--- a/usr/src/uts/common/sys/dtrace.h
+++ b/usr/src/uts/common/sys/dtrace.h
@@ -26,6 +26,7 @@
/*
* Copyright (c) 2012, Joyent, Inc. All rights reserved.
+ * Copyright (c) 2012 by Delphix. All rights reserved.
*/
#ifndef _SYS_DTRACE_H
@@ -35,16 +36,16 @@
extern "C" {
#endif
-/*
- * DTrace Dynamic Tracing Software: Kernel Interfaces
- *
- * Note: The contents of this file are private to the implementation of the
- * Solaris system and DTrace subsystem and are subject to change at any time
- * without notice. Applications and drivers using these interfaces will fail
- * to run on future releases. These interfaces should not be used for any
- * purpose except those expressly outlined in dtrace(7D) and libdtrace(3LIB).
- * Please refer to the "Solaris Dynamic Tracing Guide" for more information.
- */
+ /*
+ * DTrace Dynamic Tracing Software: Kernel Interfaces
+ *
+ * Note: The contents of this file are private to the implementation of the
+ * Solaris system and DTrace subsystem and are subject to change at any time
+ * without notice. Applications and drivers using these interfaces will fail
+ * to run on future releases. These interfaces should not be used for any
+ * purpose except those expressly outlined in dtrace(7D) and libdtrace(3LIB).
+ * Please refer to the "Solaris Dynamic Tracing Guide" for more information.
+ */
#ifndef _ASM
@@ -56,9 +57,9 @@ extern "C" {
#include <sys/cyclic.h>
#include <sys/int_limits.h>
-/*
- * DTrace Universal Constants and Typedefs
- */
+ /*
+ * DTrace Universal Constants and Typedefs
+ */
#define DTRACE_CPUALL -1 /* all CPUs */
#define DTRACE_IDNONE 0 /* invalid probe identifier */
#define DTRACE_EPIDNONE 0 /* invalid enabled probe identifier */
@@ -74,35 +75,35 @@ extern "C" {
#define DTRACE_FUNCNAMELEN 128
#define DTRACE_NAMELEN 64
#define DTRACE_FULLNAMELEN (DTRACE_PROVNAMELEN + DTRACE_MODNAMELEN + \
- DTRACE_FUNCNAMELEN + DTRACE_NAMELEN + 4)
+ DTRACE_FUNCNAMELEN + DTRACE_NAMELEN + 4)
#define DTRACE_ARGTYPELEN 128
-typedef uint32_t dtrace_id_t; /* probe identifier */
-typedef uint32_t dtrace_epid_t; /* enabled probe identifier */
-typedef uint32_t dtrace_aggid_t; /* aggregation identifier */
-typedef int64_t dtrace_aggvarid_t; /* aggregation variable identifier */
-typedef uint16_t dtrace_actkind_t; /* action kind */
-typedef int64_t dtrace_optval_t; /* option value */
-typedef uint32_t dtrace_cacheid_t; /* predicate cache identifier */
-
-typedef enum dtrace_probespec {
- DTRACE_PROBESPEC_NONE = -1,
- DTRACE_PROBESPEC_PROVIDER = 0,
- DTRACE_PROBESPEC_MOD,
- DTRACE_PROBESPEC_FUNC,
- DTRACE_PROBESPEC_NAME
-} dtrace_probespec_t;
-
-/*
- * DTrace Intermediate Format (DIF)
- *
- * The following definitions describe the DTrace Intermediate Format (DIF), a
- * a RISC-like instruction set and program encoding used to represent
- * predicates and actions that can be bound to DTrace probes. The constants
- * below defining the number of available registers are suggested minimums; the
- * compiler should use DTRACEIOC_CONF to dynamically obtain the number of
- * registers provided by the current DTrace implementation.
- */
+ typedef uint32_t dtrace_id_t; /* probe identifier */
+ typedef uint32_t dtrace_epid_t; /* enabled probe identifier */
+ typedef uint32_t dtrace_aggid_t; /* aggregation identifier */
+ typedef int64_t dtrace_aggvarid_t; /* aggregation variable identifier */
+ typedef uint16_t dtrace_actkind_t; /* action kind */
+ typedef int64_t dtrace_optval_t; /* option value */
+ typedef uint32_t dtrace_cacheid_t; /* predicate cache identifier */
+
+ typedef enum dtrace_probespec {
+ DTRACE_PROBESPEC_NONE = -1,
+ DTRACE_PROBESPEC_PROVIDER = 0,
+ DTRACE_PROBESPEC_MOD,
+ DTRACE_PROBESPEC_FUNC,
+ DTRACE_PROBESPEC_NAME
+ } dtrace_probespec_t;
+
+ /*
+ * DTrace Intermediate Format (DIF)
+ *
+ * The following definitions describe the DTrace Intermediate Format (DIF), a
+ * a RISC-like instruction set and program encoding used to represent
+ * predicates and actions that can be bound to DTrace probes. The constants
+ * below defining the number of available registers are suggested minimums; the
+ * compiler should use DTRACEIOC_CONF to dynamically obtain the number of
+ * registers provided by the current DTrace implementation.
+ */
#define DIF_VERSION_1 1 /* DIF version 1: Solaris 10 Beta */
#define DIF_VERSION_2 2 /* DIF version 2: Solaris 10 FCS */
#define DIF_VERSION DIF_VERSION_2 /* latest DIF instruction set version */
@@ -291,7 +292,7 @@ typedef enum dtrace_probespec {
#define DIF_SUBR_MAX 46 /* max subroutine value */
-typedef uint32_t dif_instr_t;
+ typedef uint32_t dif_instr_t;
#define DIF_INSTR_OP(i) (((i) >> 24) & 0xff)
#define DIF_INSTR_R1(i) (((i) >> 16) & 0xff)
@@ -333,39 +334,39 @@ typedef uint32_t dif_instr_t;
#define DIF_REG_R0 0 /* %r0 is always set to zero */
-/*
- * A DTrace Intermediate Format Type (DIF Type) is used to represent the types
- * of variables, function and associative array arguments, and the return type
- * for each DIF object (shown below). It contains a description of the type,
- * its size in bytes, and a module identifier.
- */
-typedef struct dtrace_diftype {
- uint8_t dtdt_kind; /* type kind (see below) */
- uint8_t dtdt_ckind; /* type kind in CTF */
- uint8_t dtdt_flags; /* type flags (see below) */
- uint8_t dtdt_pad; /* reserved for future use */
- uint32_t dtdt_size; /* type size in bytes (unless string) */
-} dtrace_diftype_t;
+ /*
+ * A DTrace Intermediate Format Type (DIF Type) is used to represent the types
+ * of variables, function and associative array arguments, and the return type
+ * for each DIF object (shown below). It contains a description of the type,
+ * its size in bytes, and a module identifier.
+ */
+ typedef struct dtrace_diftype {
+ uint8_t dtdt_kind; /* type kind (see below) */
+ uint8_t dtdt_ckind; /* type kind in CTF */
+ uint8_t dtdt_flags; /* type flags (see below) */
+ uint8_t dtdt_pad; /* reserved for future use */
+ uint32_t dtdt_size; /* type size in bytes (unless string) */
+ } dtrace_diftype_t;
#define DIF_TYPE_CTF 0 /* type is a CTF type */
#define DIF_TYPE_STRING 1 /* type is a D string */
#define DIF_TF_BYREF 0x1 /* type is passed by reference */
-/*
- * A DTrace Intermediate Format variable record is used to describe each of the
- * variables referenced by a given DIF object. It contains an integer variable
- * identifier along with variable scope and properties, as shown below. The
- * size of this structure must be sizeof (int) aligned.
- */
-typedef struct dtrace_difv {
- uint32_t dtdv_name; /* variable name index in dtdo_strtab */
- uint32_t dtdv_id; /* variable reference identifier */
- uint8_t dtdv_kind; /* variable kind (see below) */
- uint8_t dtdv_scope; /* variable scope (see below) */
- uint16_t dtdv_flags; /* variable flags (see below) */
- dtrace_diftype_t dtdv_type; /* variable type (see above) */
-} dtrace_difv_t;
+ /*
+ * A DTrace Intermediate Format variable record is used to describe each of the
+ * variables referenced by a given DIF object. It contains an integer variable
+ * identifier along with variable scope and properties, as shown below. The
+ * size of this structure must be sizeof (int) aligned.
+ */
+ typedef struct dtrace_difv {
+ uint32_t dtdv_name; /* variable name index in dtdo_strtab */
+ uint32_t dtdv_id; /* variable reference identifier */
+ uint8_t dtdv_kind; /* variable kind (see below) */
+ uint8_t dtdv_scope; /* variable scope (see below) */
+ uint16_t dtdv_flags; /* variable flags (see below) */
+ dtrace_diftype_t dtdv_type; /* variable type (see above) */
+ } dtrace_difv_t;
#define DIFV_KIND_ARRAY 0 /* variable is an array of quantities */
#define DIFV_KIND_SCALAR 1 /* variable is a scalar quantity */
@@ -377,21 +378,21 @@ typedef struct dtrace_difv {
#define DIFV_F_REF 0x1 /* variable is referenced by DIFO */
#define DIFV_F_MOD 0x2 /* variable is written by DIFO */
-/*
- * DTrace Actions
- *
- * The upper byte determines the class of the action; the low bytes determines
- * the specific action within that class. The classes of actions are as
- * follows:
- *
- * [ no class ] <= May record process- or kernel-related data
- * DTRACEACT_PROC <= Only records process-related data
- * DTRACEACT_PROC_DESTRUCTIVE <= Potentially destructive to processes
- * DTRACEACT_KERNEL <= Only records kernel-related data
- * DTRACEACT_KERNEL_DESTRUCTIVE <= Potentially destructive to the kernel
- * DTRACEACT_SPECULATIVE <= Speculation-related action
- * DTRACEACT_AGGREGATION <= Aggregating action
- */
+ /*
+ * DTrace Actions
+ *
+ * The upper byte determines the class of the action; the low bytes determines
+ * the specific action within that class. The classes of actions are as
+ * follows:
+ *
+ * [ no class ] <= May record process- or kernel-related data
+ * DTRACEACT_PROC <= Only records process-related data
+ * DTRACEACT_PROC_DESTRUCTIVE <= Potentially destructive to processes
+ * DTRACEACT_KERNEL <= Only records kernel-related data
+ * DTRACEACT_KERNEL_DESTRUCTIVE <= Potentially destructive to the kernel
+ * DTRACEACT_SPECULATIVE <= Speculation-related action
+ * DTRACEACT_AGGREGATION <= Aggregating action
+ */
#define DTRACEACT_NONE 0 /* no action */
#define DTRACEACT_DIFEXPR 1 /* action is DIF expression */
#define DTRACEACT_EXIT 2 /* exit() action */
@@ -435,27 +436,27 @@ typedef struct dtrace_difv {
#define DTRACEACT_ISDESTRUCTIVE(x) \
(DTRACEACT_CLASS(x) == DTRACEACT_PROC_DESTRUCTIVE || \
- DTRACEACT_CLASS(x) == DTRACEACT_KERNEL_DESTRUCTIVE)
+ DTRACEACT_CLASS(x) == DTRACEACT_KERNEL_DESTRUCTIVE)
#define DTRACEACT_ISSPECULATIVE(x) \
(DTRACEACT_CLASS(x) == DTRACEACT_SPECULATIVE)
#define DTRACEACT_ISPRINTFLIKE(x) \
((x) == DTRACEACT_PRINTF || (x) == DTRACEACT_PRINTA || \
- (x) == DTRACEACT_SYSTEM || (x) == DTRACEACT_FREOPEN)
-
-/*
- * DTrace Aggregating Actions
- *
- * These are functions f(x) for which the following is true:
- *
- * f(f(x_0) U f(x_1) U ... U f(x_n)) = f(x_0 U x_1 U ... U x_n)
- *
- * where x_n is a set of arbitrary data. Aggregating actions are in their own
- * DTrace action class, DTTRACEACT_AGGREGATION. The macros provided here allow
- * for easier processing of the aggregation argument and data payload for a few
- * aggregating actions (notably: quantize(), lquantize(), and ustack()).
- */
+ (x) == DTRACEACT_SYSTEM || (x) == DTRACEACT_FREOPEN)
+
+ /*
+ * DTrace Aggregating Actions
+ *
+ * These are functions f(x) for which the following is true:
+ *
+ * f(f(x_0) U f(x_1) U ... U f(x_n)) = f(x_0 U x_1 U ... U x_n)
+ *
+ * where x_n is a set of arbitrary data. Aggregating actions are in their own
+ * DTrace action class, DTTRACEACT_AGGREGATION. The macros provided here allow
+ * for easier processing of the aggregation argument and data payload for a few
+ * aggregating actions (notably: quantize(), lquantize(), and ustack()).
+ */
#define DTRACEACT_AGGREGATION 0x0700
#define DTRACEAGG_COUNT (DTRACEACT_AGGREGATION + 1)
#define DTRACEAGG_MIN (DTRACEACT_AGGREGATION + 2)
@@ -477,9 +478,9 @@ typedef struct dtrace_difv {
#define DTRACE_QUANTIZE_BUCKETVAL(buck) \
(int64_t)((buck) < DTRACE_QUANTIZE_ZEROBUCKET ? \
- -(1LL << (DTRACE_QUANTIZE_ZEROBUCKET - 1 - (buck))) : \
- (buck) == DTRACE_QUANTIZE_ZEROBUCKET ? 0 : \
- 1LL << ((buck) - DTRACE_QUANTIZE_ZEROBUCKET - 1))
+ -(1LL << (DTRACE_QUANTIZE_ZEROBUCKET - 1 - (buck))) : \
+ (buck) == DTRACE_QUANTIZE_ZEROBUCKET ? 0 : \
+ 1LL << ((buck) - DTRACE_QUANTIZE_ZEROBUCKET - 1))
#define DTRACE_LQUANTIZE_STEPSHIFT 48
#define DTRACE_LQUANTIZE_STEPMASK ((uint64_t)UINT16_MAX << 48)
@@ -490,15 +491,15 @@ typedef struct dtrace_difv {
#define DTRACE_LQUANTIZE_STEP(x) \
(uint16_t)(((x) & DTRACE_LQUANTIZE_STEPMASK) >> \
- DTRACE_LQUANTIZE_STEPSHIFT)
+ DTRACE_LQUANTIZE_STEPSHIFT)
#define DTRACE_LQUANTIZE_LEVELS(x) \
(uint16_t)(((x) & DTRACE_LQUANTIZE_LEVELMASK) >> \
- DTRACE_LQUANTIZE_LEVELSHIFT)
+ DTRACE_LQUANTIZE_LEVELSHIFT)
#define DTRACE_LQUANTIZE_BASE(x) \
(int32_t)(((x) & DTRACE_LQUANTIZE_BASEMASK) >> \
- DTRACE_LQUANTIZE_BASESHIFT)
+ DTRACE_LQUANTIZE_BASESHIFT)
#define DTRACE_LLQUANTIZE_FACTORSHIFT 48
#define DTRACE_LLQUANTIZE_FACTORMASK ((uint64_t)UINT16_MAX << 48)
@@ -511,19 +512,19 @@ typedef struct dtrace_difv {
#define DTRACE_LLQUANTIZE_FACTOR(x) \
(uint16_t)(((x) & DTRACE_LLQUANTIZE_FACTORMASK) >> \
- DTRACE_LLQUANTIZE_FACTORSHIFT)
+ DTRACE_LLQUANTIZE_FACTORSHIFT)
#define DTRACE_LLQUANTIZE_LOW(x) \
(uint16_t)(((x) & DTRACE_LLQUANTIZE_LOWMASK) >> \
- DTRACE_LLQUANTIZE_LOWSHIFT)
+ DTRACE_LLQUANTIZE_LOWSHIFT)
#define DTRACE_LLQUANTIZE_HIGH(x) \
(uint16_t)(((x) & DTRACE_LLQUANTIZE_HIGHMASK) >> \
- DTRACE_LLQUANTIZE_HIGHSHIFT)
+ DTRACE_LLQUANTIZE_HIGHSHIFT)
#define DTRACE_LLQUANTIZE_NSTEP(x) \
(uint16_t)(((x) & DTRACE_LLQUANTIZE_NSTEPMASK) >> \
- DTRACE_LLQUANTIZE_NSTEPSHIFT)
+ DTRACE_LLQUANTIZE_NSTEPSHIFT)
#define DTRACE_USTACK_NFRAMES(x) (uint32_t)((x) & UINT32_MAX)
#define DTRACE_USTACK_STRSIZE(x) (uint32_t)((x) >> 32)
@@ -540,72 +541,72 @@ typedef struct dtrace_difv {
#define DTRACE_PTR(type, name) type *name
#endif
-/*
- * DTrace Object Format (DOF)
- *
- * DTrace programs can be persistently encoded in the DOF format so that they
- * may be embedded in other programs (for example, in an ELF file) or in the
- * dtrace driver configuration file for use in anonymous tracing. The DOF
- * format is versioned and extensible so that it can be revised and so that
- * internal data structures can be modified or extended compatibly. All DOF
- * structures use fixed-size types, so the 32-bit and 64-bit representations
- * are identical and consumers can use either data model transparently.
- *
- * The file layout is structured as follows:
- *
- * +---------------+-------------------+----- ... ----+---- ... ------+
- * | dof_hdr_t | dof_sec_t[ ... ] | loadable | non-loadable |
- * | (file header) | (section headers) | section data | section data |
- * +---------------+-------------------+----- ... ----+---- ... ------+
- * |<------------ dof_hdr.dofh_loadsz --------------->| |
- * |<------------ dof_hdr.dofh_filesz ------------------------------->|
- *
- * The file header stores meta-data including a magic number, data model for
- * the instrumentation, data encoding, and properties of the DIF code within.
- * The header describes its own size and the size of the section headers. By
- * convention, an array of section headers follows the file header, and then
- * the data for all loadable sections and unloadable sections. This permits
- * consumer code to easily download the headers and all loadable data into the
- * DTrace driver in one contiguous chunk, omitting other extraneous sections.
- *
- * The section headers describe the size, offset, alignment, and section type
- * for each section. Sections are described using a set of #defines that tell
- * the consumer what kind of data is expected. Sections can contain links to
- * other sections by storing a dof_secidx_t, an index into the section header
- * array, inside of the section data structures. The section header includes
- * an entry size so that sections with data arrays can grow their structures.
- *
- * The DOF data itself can contain many snippets of DIF (i.e. >1 DIFOs), which
- * are represented themselves as a collection of related DOF sections. This
- * permits us to change the set of sections associated with a DIFO over time,
- * and also permits us to encode DIFOs that contain different sets of sections.
- * When a DOF section wants to refer to a DIFO, it stores the dof_secidx_t of a
- * section of type DOF_SECT_DIFOHDR. This section's data is then an array of
- * dof_secidx_t's which in turn denote the sections associated with this DIFO.
- *
- * This loose coupling of the file structure (header and sections) to the
- * structure of the DTrace program itself (ECB descriptions, action
- * descriptions, and DIFOs) permits activities such as relocation processing
- * to occur in a single pass without having to understand D program structure.
- *
- * Finally, strings are always stored in ELF-style string tables along with a
- * string table section index and string table offset. Therefore strings in
- * DOF are always arbitrary-length and not bound to the current implementation.
- */
+ /*
+ * DTrace Object Format (DOF)
+ *
+ * DTrace programs can be persistently encoded in the DOF format so that they
+ * may be embedded in other programs (for example, in an ELF file) or in the
+ * dtrace driver configuration file for use in anonymous tracing. The DOF
+ * format is versioned and extensible so that it can be revised and so that
+ * internal data structures can be modified or extended compatibly. All DOF
+ * structures use fixed-size types, so the 32-bit and 64-bit representations
+ * are identical and consumers can use either data model transparently.
+ *
+ * The file layout is structured as follows:
+ *
+ * +---------------+-------------------+----- ... ----+---- ... ------+
+ * | dof_hdr_t | dof_sec_t[ ... ] | loadable | non-loadable |
+ * | (file header) | (section headers) | section data | section data |
+ * +---------------+-------------------+----- ... ----+---- ... ------+
+ * |<------------ dof_hdr.dofh_loadsz --------------->| |
+ * |<------------ dof_hdr.dofh_filesz ------------------------------->|
+ *
+ * The file header stores meta-data including a magic number, data model for
+ * the instrumentation, data encoding, and properties of the DIF code within.
+ * The header describes its own size and the size of the section headers. By
+ * convention, an array of section headers follows the file header, and then
+ * the data for all loadable sections and unloadable sections. This permits
+ * consumer code to easily download the headers and all loadable data into the
+ * DTrace driver in one contiguous chunk, omitting other extraneous sections.
+ *
+ * The section headers describe the size, offset, alignment, and section type
+ * for each section. Sections are described using a set of #defines that tell
+ * the consumer what kind of data is expected. Sections can contain links to
+ * other sections by storing a dof_secidx_t, an index into the section header
+ * array, inside of the section data structures. The section header includes
+ * an entry size so that sections with data arrays can grow their structures.
+ *
+ * The DOF data itself can contain many snippets of DIF (i.e. >1 DIFOs), which
+ * are represented themselves as a collection of related DOF sections. This
+ * permits us to change the set of sections associated with a DIFO over time,
+ * and also permits us to encode DIFOs that contain different sets of sections.
+ * When a DOF section wants to refer to a DIFO, it stores the dof_secidx_t of a
+ * section of type DOF_SECT_DIFOHDR. This section's data is then an array of
+ * dof_secidx_t's which in turn denote the sections associated with this DIFO.
+ *
+ * This loose coupling of the file structure (header and sections) to the
+ * structure of the DTrace program itself (ECB descriptions, action
+ * descriptions, and DIFOs) permits activities such as relocation processing
+ * to occur in a single pass without having to understand D program structure.
+ *
+ * Finally, strings are always stored in ELF-style string tables along with a
+ * string table section index and string table offset. Therefore strings in
+ * DOF are always arbitrary-length and not bound to the current implementation.
+ */
#define DOF_ID_SIZE 16 /* total size of dofh_ident[] in bytes */
-typedef struct dof_hdr {
- uint8_t dofh_ident[DOF_ID_SIZE]; /* identification bytes (see below) */
- uint32_t dofh_flags; /* file attribute flags (if any) */
- uint32_t dofh_hdrsize; /* size of file header in bytes */
- uint32_t dofh_secsize; /* size of section header in bytes */
- uint32_t dofh_secnum; /* number of section headers */
- uint64_t dofh_secoff; /* file offset of section headers */
- uint64_t dofh_loadsz; /* file size of loadable portion */
- uint64_t dofh_filesz; /* file size of entire DOF file */
- uint64_t dofh_pad; /* reserved for future use */
-} dof_hdr_t;
+ typedef struct dof_hdr {
+ uint8_t dofh_ident[DOF_ID_SIZE]; /* identification bytes (see below) */
+ uint32_t dofh_flags; /* file attribute flags (if any) */
+ uint32_t dofh_hdrsize; /* size of file header in bytes */
+ uint32_t dofh_secsize; /* size of section header in bytes */
+ uint32_t dofh_secnum; /* number of section headers */
+ uint64_t dofh_secoff; /* file offset of section headers */
+ uint64_t dofh_loadsz; /* file size of loadable portion */
+ uint64_t dofh_filesz; /* file size of entire DOF file */
+ uint64_t dofh_pad; /* reserved for future use */
+ } dof_hdr_t;
#define DOF_ID_MAG0 0 /* first byte of magic number */
#define DOF_ID_MAG1 1 /* second byte of magic number */
@@ -653,20 +654,20 @@ typedef struct dof_hdr {
#define DOF_FL_VALID 0 /* mask of all valid dofh_flags bits */
-typedef uint32_t dof_secidx_t; /* section header table index type */
-typedef uint32_t dof_stridx_t; /* string table index type */
+ typedef uint32_t dof_secidx_t; /* section header table index type */
+ typedef uint32_t dof_stridx_t; /* string table index type */
#define DOF_SECIDX_NONE (-1U) /* null value for section indices */
#define DOF_STRIDX_NONE (-1U) /* null value for string indices */
-typedef struct dof_sec {
- uint32_t dofs_type; /* section type (see below) */
- uint32_t dofs_align; /* section data memory alignment */
- uint32_t dofs_flags; /* section flags (if any) */
- uint32_t dofs_entsize; /* size of section entry (if table) */
- uint64_t dofs_offset; /* offset of section data within file */
- uint64_t dofs_size; /* size of section data in bytes */
-} dof_sec_t;
+ typedef struct dof_sec {
+ uint32_t dofs_type; /* section type (see below) */
+ uint32_t dofs_align; /* section data memory alignment */
+ uint32_t dofs_flags; /* section flags (if any) */
+ uint32_t dofs_entsize; /* size of section entry (if table) */
+ uint64_t dofs_offset; /* offset of section data within file */
+ uint64_t dofs_size; /* size of section data in bytes */
+ } dof_sec_t;
#define DOF_SECT_NONE 0 /* null section */
#define DOF_SECT_COMMENTS 1 /* compiler comments */
@@ -700,297 +701,297 @@ typedef struct dof_sec {
#define DOF_SEC_ISLOADABLE(x) \
(((x) == DOF_SECT_ECBDESC) || ((x) == DOF_SECT_PROBEDESC) || \
- ((x) == DOF_SECT_ACTDESC) || ((x) == DOF_SECT_DIFOHDR) || \
- ((x) == DOF_SECT_DIF) || ((x) == DOF_SECT_STRTAB) || \
- ((x) == DOF_SECT_VARTAB) || ((x) == DOF_SECT_RELTAB) || \
- ((x) == DOF_SECT_TYPTAB) || ((x) == DOF_SECT_URELHDR) || \
- ((x) == DOF_SECT_KRELHDR) || ((x) == DOF_SECT_OPTDESC) || \
- ((x) == DOF_SECT_PROVIDER) || ((x) == DOF_SECT_PROBES) || \
- ((x) == DOF_SECT_PRARGS) || ((x) == DOF_SECT_PROFFS) || \
- ((x) == DOF_SECT_INTTAB) || ((x) == DOF_SECT_XLTAB) || \
- ((x) == DOF_SECT_XLMEMBERS) || ((x) == DOF_SECT_XLIMPORT) || \
- ((x) == DOF_SECT_XLIMPORT) || ((x) == DOF_SECT_XLEXPORT) || \
- ((x) == DOF_SECT_PREXPORT) || ((x) == DOF_SECT_PRENOFFS))
-
-typedef struct dof_ecbdesc {
- dof_secidx_t dofe_probes; /* link to DOF_SECT_PROBEDESC */
- dof_secidx_t dofe_pred; /* link to DOF_SECT_DIFOHDR */
- dof_secidx_t dofe_actions; /* link to DOF_SECT_ACTDESC */
- uint32_t dofe_pad; /* reserved for future use */
- uint64_t dofe_uarg; /* user-supplied library argument */
-} dof_ecbdesc_t;
-
-typedef struct dof_probedesc {
- dof_secidx_t dofp_strtab; /* link to DOF_SECT_STRTAB section */
- dof_stridx_t dofp_provider; /* provider string */
- dof_stridx_t dofp_mod; /* module string */
- dof_stridx_t dofp_func; /* function string */
- dof_stridx_t dofp_name; /* name string */
- uint32_t dofp_id; /* probe identifier (or zero) */
-} dof_probedesc_t;
-
-typedef struct dof_actdesc {
- dof_secidx_t dofa_difo; /* link to DOF_SECT_DIFOHDR */
- dof_secidx_t dofa_strtab; /* link to DOF_SECT_STRTAB section */
- uint32_t dofa_kind; /* action kind (DTRACEACT_* constant) */
- uint32_t dofa_ntuple; /* number of subsequent tuple actions */
- uint64_t dofa_arg; /* kind-specific argument */
- uint64_t dofa_uarg; /* user-supplied argument */
-} dof_actdesc_t;
-
-typedef struct dof_difohdr {
- dtrace_diftype_t dofd_rtype; /* return type for this fragment */
- dof_secidx_t dofd_links[1]; /* variable length array of indices */
-} dof_difohdr_t;
-
-typedef struct dof_relohdr {
- dof_secidx_t dofr_strtab; /* link to DOF_SECT_STRTAB for names */
- dof_secidx_t dofr_relsec; /* link to DOF_SECT_RELTAB for relos */
- dof_secidx_t dofr_tgtsec; /* link to section we are relocating */
-} dof_relohdr_t;
-
-typedef struct dof_relodesc {
- dof_stridx_t dofr_name; /* string name of relocation symbol */
- uint32_t dofr_type; /* relo type (DOF_RELO_* constant) */
- uint64_t dofr_offset; /* byte offset for relocation */
- uint64_t dofr_data; /* additional type-specific data */
-} dof_relodesc_t;
+ ((x) == DOF_SECT_ACTDESC) || ((x) == DOF_SECT_DIFOHDR) || \
+ ((x) == DOF_SECT_DIF) || ((x) == DOF_SECT_STRTAB) || \
+ ((x) == DOF_SECT_VARTAB) || ((x) == DOF_SECT_RELTAB) || \
+ ((x) == DOF_SECT_TYPTAB) || ((x) == DOF_SECT_URELHDR) || \
+ ((x) == DOF_SECT_KRELHDR) || ((x) == DOF_SECT_OPTDESC) || \
+ ((x) == DOF_SECT_PROVIDER) || ((x) == DOF_SECT_PROBES) || \
+ ((x) == DOF_SECT_PRARGS) || ((x) == DOF_SECT_PROFFS) || \
+ ((x) == DOF_SECT_INTTAB) || ((x) == DOF_SECT_XLTAB) || \
+ ((x) == DOF_SECT_XLMEMBERS) || ((x) == DOF_SECT_XLIMPORT) || \
+ ((x) == DOF_SECT_XLIMPORT) || ((x) == DOF_SECT_XLEXPORT) || \
+ ((x) == DOF_SECT_PREXPORT) || ((x) == DOF_SECT_PRENOFFS))
+
+ typedef struct dof_ecbdesc {
+ dof_secidx_t dofe_probes; /* link to DOF_SECT_PROBEDESC */
+ dof_secidx_t dofe_pred; /* link to DOF_SECT_DIFOHDR */
+ dof_secidx_t dofe_actions; /* link to DOF_SECT_ACTDESC */
+ uint32_t dofe_pad; /* reserved for future use */
+ uint64_t dofe_uarg; /* user-supplied library argument */
+ } dof_ecbdesc_t;
+
+ typedef struct dof_probedesc {
+ dof_secidx_t dofp_strtab; /* link to DOF_SECT_STRTAB section */
+ dof_stridx_t dofp_provider; /* provider string */
+ dof_stridx_t dofp_mod; /* module string */
+ dof_stridx_t dofp_func; /* function string */
+ dof_stridx_t dofp_name; /* name string */
+ uint32_t dofp_id; /* probe identifier (or zero) */
+ } dof_probedesc_t;
+
+ typedef struct dof_actdesc {
+ dof_secidx_t dofa_difo; /* link to DOF_SECT_DIFOHDR */
+ dof_secidx_t dofa_strtab; /* link to DOF_SECT_STRTAB section */
+ uint32_t dofa_kind; /* action kind (DTRACEACT_* constant) */
+ uint32_t dofa_ntuple; /* number of subsequent tuple actions */
+ uint64_t dofa_arg; /* kind-specific argument */
+ uint64_t dofa_uarg; /* user-supplied argument */
+ } dof_actdesc_t;
+
+ typedef struct dof_difohdr {
+ dtrace_diftype_t dofd_rtype; /* return type for this fragment */
+ dof_secidx_t dofd_links[1]; /* variable length array of indices */
+ } dof_difohdr_t;
+
+ typedef struct dof_relohdr {
+ dof_secidx_t dofr_strtab; /* link to DOF_SECT_STRTAB for names */
+ dof_secidx_t dofr_relsec; /* link to DOF_SECT_RELTAB for relos */
+ dof_secidx_t dofr_tgtsec; /* link to section we are relocating */
+ } dof_relohdr_t;
+
+ typedef struct dof_relodesc {
+ dof_stridx_t dofr_name; /* string name of relocation symbol */
+ uint32_t dofr_type; /* relo type (DOF_RELO_* constant) */
+ uint64_t dofr_offset; /* byte offset for relocation */
+ uint64_t dofr_data; /* additional type-specific data */
+ } dof_relodesc_t;
#define DOF_RELO_NONE 0 /* empty relocation entry */
#define DOF_RELO_SETX 1 /* relocate setx value */
-typedef struct dof_optdesc {
- uint32_t dofo_option; /* option identifier */
- dof_secidx_t dofo_strtab; /* string table, if string option */
- uint64_t dofo_value; /* option value or string index */
-} dof_optdesc_t;
+ typedef struct dof_optdesc {
+ uint32_t dofo_option; /* option identifier */
+ dof_secidx_t dofo_strtab; /* string table, if string option */
+ uint64_t dofo_value; /* option value or string index */
+ } dof_optdesc_t;
-typedef uint32_t dof_attr_t; /* encoded stability attributes */
+ typedef uint32_t dof_attr_t; /* encoded stability attributes */
#define DOF_ATTR(n, d, c) (((n) << 24) | ((d) << 16) | ((c) << 8))
#define DOF_ATTR_NAME(a) (((a) >> 24) & 0xff)
#define DOF_ATTR_DATA(a) (((a) >> 16) & 0xff)
#define DOF_ATTR_CLASS(a) (((a) >> 8) & 0xff)
-typedef struct dof_provider {
- dof_secidx_t dofpv_strtab; /* link to DOF_SECT_STRTAB section */
- dof_secidx_t dofpv_probes; /* link to DOF_SECT_PROBES section */
- dof_secidx_t dofpv_prargs; /* link to DOF_SECT_PRARGS section */
- dof_secidx_t dofpv_proffs; /* link to DOF_SECT_PROFFS section */
- dof_stridx_t dofpv_name; /* provider name string */
- dof_attr_t dofpv_provattr; /* provider attributes */
- dof_attr_t dofpv_modattr; /* module attributes */
- dof_attr_t dofpv_funcattr; /* function attributes */
- dof_attr_t dofpv_nameattr; /* name attributes */
- dof_attr_t dofpv_argsattr; /* args attributes */
- dof_secidx_t dofpv_prenoffs; /* link to DOF_SECT_PRENOFFS section */
-} dof_provider_t;
-
-typedef struct dof_probe {
- uint64_t dofpr_addr; /* probe base address or offset */
- dof_stridx_t dofpr_func; /* probe function string */
- dof_stridx_t dofpr_name; /* probe name string */
- dof_stridx_t dofpr_nargv; /* native argument type strings */
- dof_stridx_t dofpr_xargv; /* translated argument type strings */
- uint32_t dofpr_argidx; /* index of first argument mapping */
- uint32_t dofpr_offidx; /* index of first offset entry */
- uint8_t dofpr_nargc; /* native argument count */
- uint8_t dofpr_xargc; /* translated argument count */
- uint16_t dofpr_noffs; /* number of offset entries for probe */
- uint32_t dofpr_enoffidx; /* index of first is-enabled offset */
- uint16_t dofpr_nenoffs; /* number of is-enabled offsets */
- uint16_t dofpr_pad1; /* reserved for future use */
- uint32_t dofpr_pad2; /* reserved for future use */
-} dof_probe_t;
-
-typedef struct dof_xlator {
- dof_secidx_t dofxl_members; /* link to DOF_SECT_XLMEMBERS section */
- dof_secidx_t dofxl_strtab; /* link to DOF_SECT_STRTAB section */
- dof_stridx_t dofxl_argv; /* input parameter type strings */
- uint32_t dofxl_argc; /* input parameter list length */
- dof_stridx_t dofxl_type; /* output type string name */
- dof_attr_t dofxl_attr; /* output stability attributes */
-} dof_xlator_t;
-
-typedef struct dof_xlmember {
- dof_secidx_t dofxm_difo; /* member link to DOF_SECT_DIFOHDR */
- dof_stridx_t dofxm_name; /* member name */
- dtrace_diftype_t dofxm_type; /* member type */
-} dof_xlmember_t;
-
-typedef struct dof_xlref {
- dof_secidx_t dofxr_xlator; /* link to DOF_SECT_XLATORS section */
- uint32_t dofxr_member; /* index of referenced dof_xlmember */
- uint32_t dofxr_argn; /* index of argument for DIF_OP_XLARG */
-} dof_xlref_t;
-
-/*
- * DTrace Intermediate Format Object (DIFO)
- *
- * A DIFO is used to store the compiled DIF for a D expression, its return
- * type, and its string and variable tables. The string table is a single
- * buffer of character data into which sets instructions and variable
- * references can reference strings using a byte offset. The variable table
- * is an array of dtrace_difv_t structures that describe the name and type of
- * each variable and the id used in the DIF code. This structure is described
- * above in the DIF section of this header file. The DIFO is used at both
- * user-level (in the library) and in the kernel, but the structure is never
- * passed between the two: the DOF structures form the only interface. As a
- * result, the definition can change depending on the presence of _KERNEL.
- */
-typedef struct dtrace_difo {
- dif_instr_t *dtdo_buf; /* instruction buffer */
- uint64_t *dtdo_inttab; /* integer table (optional) */
- char *dtdo_strtab; /* string table (optional) */
- dtrace_difv_t *dtdo_vartab; /* variable table (optional) */
- uint_t dtdo_len; /* length of instruction buffer */
- uint_t dtdo_intlen; /* length of integer table */
- uint_t dtdo_strlen; /* length of string table */
- uint_t dtdo_varlen; /* length of variable table */
- dtrace_diftype_t dtdo_rtype; /* return type */
- uint_t dtdo_refcnt; /* owner reference count */
- uint_t dtdo_destructive; /* invokes destructive subroutines */
+ typedef struct dof_provider {
+ dof_secidx_t dofpv_strtab; /* link to DOF_SECT_STRTAB section */
+ dof_secidx_t dofpv_probes; /* link to DOF_SECT_PROBES section */
+ dof_secidx_t dofpv_prargs; /* link to DOF_SECT_PRARGS section */
+ dof_secidx_t dofpv_proffs; /* link to DOF_SECT_PROFFS section */
+ dof_stridx_t dofpv_name; /* provider name string */
+ dof_attr_t dofpv_provattr; /* provider attributes */
+ dof_attr_t dofpv_modattr; /* module attributes */
+ dof_attr_t dofpv_funcattr; /* function attributes */
+ dof_attr_t dofpv_nameattr; /* name attributes */
+ dof_attr_t dofpv_argsattr; /* args attributes */
+ dof_secidx_t dofpv_prenoffs; /* link to DOF_SECT_PRENOFFS section */
+ } dof_provider_t;
+
+ typedef struct dof_probe {
+ uint64_t dofpr_addr; /* probe base address or offset */
+ dof_stridx_t dofpr_func; /* probe function string */
+ dof_stridx_t dofpr_name; /* probe name string */
+ dof_stridx_t dofpr_nargv; /* native argument type strings */
+ dof_stridx_t dofpr_xargv; /* translated argument type strings */
+ uint32_t dofpr_argidx; /* index of first argument mapping */
+ uint32_t dofpr_offidx; /* index of first offset entry */
+ uint8_t dofpr_nargc; /* native argument count */
+ uint8_t dofpr_xargc; /* translated argument count */
+ uint16_t dofpr_noffs; /* number of offset entries for probe */
+ uint32_t dofpr_enoffidx; /* index of first is-enabled offset */
+ uint16_t dofpr_nenoffs; /* number of is-enabled offsets */
+ uint16_t dofpr_pad1; /* reserved for future use */
+ uint32_t dofpr_pad2; /* reserved for future use */
+ } dof_probe_t;
+
+ typedef struct dof_xlator {
+ dof_secidx_t dofxl_members; /* link to DOF_SECT_XLMEMBERS section */
+ dof_secidx_t dofxl_strtab; /* link to DOF_SECT_STRTAB section */
+ dof_stridx_t dofxl_argv; /* input parameter type strings */
+ uint32_t dofxl_argc; /* input parameter list length */
+ dof_stridx_t dofxl_type; /* output type string name */
+ dof_attr_t dofxl_attr; /* output stability attributes */
+ } dof_xlator_t;
+
+ typedef struct dof_xlmember {
+ dof_secidx_t dofxm_difo; /* member link to DOF_SECT_DIFOHDR */
+ dof_stridx_t dofxm_name; /* member name */
+ dtrace_diftype_t dofxm_type; /* member type */
+ } dof_xlmember_t;
+
+ typedef struct dof_xlref {
+ dof_secidx_t dofxr_xlator; /* link to DOF_SECT_XLATORS section */
+ uint32_t dofxr_member; /* index of referenced dof_xlmember */
+ uint32_t dofxr_argn; /* index of argument for DIF_OP_XLARG */
+ } dof_xlref_t;
+
+ /*
+ * DTrace Intermediate Format Object (DIFO)
+ *
+ * A DIFO is used to store the compiled DIF for a D expression, its return
+ * type, and its string and variable tables. The string table is a single
+ * buffer of character data into which sets instructions and variable
+ * references can reference strings using a byte offset. The variable table
+ * is an array of dtrace_difv_t structures that describe the name and type of
+ * each variable and the id used in the DIF code. This structure is described
+ * above in the DIF section of this header file. The DIFO is used at both
+ * user-level (in the library) and in the kernel, but the structure is never
+ * passed between the two: the DOF structures form the only interface. As a
+ * result, the definition can change depending on the presence of _KERNEL.
+ */
+ typedef struct dtrace_difo {
+ dif_instr_t *dtdo_buf; /* instruction buffer */
+ uint64_t *dtdo_inttab; /* integer table (optional) */
+ char *dtdo_strtab; /* string table (optional) */
+ dtrace_difv_t *dtdo_vartab; /* variable table (optional) */
+ uint_t dtdo_len; /* length of instruction buffer */
+ uint_t dtdo_intlen; /* length of integer table */
+ uint_t dtdo_strlen; /* length of string table */
+ uint_t dtdo_varlen; /* length of variable table */
+ dtrace_diftype_t dtdo_rtype; /* return type */
+ uint_t dtdo_refcnt; /* owner reference count */
+ uint_t dtdo_destructive; /* invokes destructive subroutines */
#ifndef _KERNEL
- dof_relodesc_t *dtdo_kreltab; /* kernel relocations */
- dof_relodesc_t *dtdo_ureltab; /* user relocations */
- struct dt_node **dtdo_xlmtab; /* translator references */
- uint_t dtdo_krelen; /* length of krelo table */
- uint_t dtdo_urelen; /* length of urelo table */
- uint_t dtdo_xlmlen; /* length of translator table */
+ dof_relodesc_t *dtdo_kreltab; /* kernel relocations */
+ dof_relodesc_t *dtdo_ureltab; /* user relocations */
+ struct dt_node **dtdo_xlmtab; /* translator references */
+ uint_t dtdo_krelen; /* length of krelo table */
+ uint_t dtdo_urelen; /* length of urelo table */
+ uint_t dtdo_xlmlen; /* length of translator table */
#endif
-} dtrace_difo_t;
-
-/*
- * DTrace Enabling Description Structures
- *
- * When DTrace is tracking the description of a DTrace enabling entity (probe,
- * predicate, action, ECB, record, etc.), it does so in a description
- * structure. These structures all end in "desc", and are used at both
- * user-level and in the kernel -- but (with the exception of
- * dtrace_probedesc_t) they are never passed between them. Typically,
- * user-level will use the description structures when assembling an enabling.
- * It will then distill those description structures into a DOF object (see
- * above), and send it into the kernel. The kernel will again use the
- * description structures to create a description of the enabling as it reads
- * the DOF. When the description is complete, the enabling will be actually
- * created -- turning it into the structures that represent the enabling
- * instead of merely describing it. Not surprisingly, the description
- * structures bear a strong resemblance to the DOF structures that act as their
- * conduit.
- */
-struct dtrace_predicate;
-
-typedef struct dtrace_probedesc {
- dtrace_id_t dtpd_id; /* probe identifier */
- char dtpd_provider[DTRACE_PROVNAMELEN]; /* probe provider name */
- char dtpd_mod[DTRACE_MODNAMELEN]; /* probe module name */
- char dtpd_func[DTRACE_FUNCNAMELEN]; /* probe function name */
- char dtpd_name[DTRACE_NAMELEN]; /* probe name */
-} dtrace_probedesc_t;
-
-typedef struct dtrace_repldesc {
- dtrace_probedesc_t dtrpd_match; /* probe descr. to match */
- dtrace_probedesc_t dtrpd_create; /* probe descr. to create */
-} dtrace_repldesc_t;
-
-typedef struct dtrace_preddesc {
- dtrace_difo_t *dtpdd_difo; /* pointer to DIF object */
- struct dtrace_predicate *dtpdd_predicate; /* pointer to predicate */
-} dtrace_preddesc_t;
-
-typedef struct dtrace_actdesc {
- dtrace_difo_t *dtad_difo; /* pointer to DIF object */
- struct dtrace_actdesc *dtad_next; /* next action */
- dtrace_actkind_t dtad_kind; /* kind of action */
- uint32_t dtad_ntuple; /* number in tuple */
- uint64_t dtad_arg; /* action argument */
- uint64_t dtad_uarg; /* user argument */
- int dtad_refcnt; /* reference count */
-} dtrace_actdesc_t;
-
-typedef struct dtrace_ecbdesc {
- dtrace_actdesc_t *dted_action; /* action description(s) */
- dtrace_preddesc_t dted_pred; /* predicate description */
- dtrace_probedesc_t dted_probe; /* probe description */
- uint64_t dted_uarg; /* library argument */
- int dted_refcnt; /* reference count */
-} dtrace_ecbdesc_t;
-
-/*
- * DTrace Metadata Description Structures
- *
- * DTrace separates the trace data stream from the metadata stream. The only
- * metadata tokens placed in the data stream are enabled probe identifiers
- * (EPIDs) or (in the case of aggregations) aggregation identifiers. In order
- * to determine the structure of the data, DTrace consumers pass the token to
- * the kernel, and receive in return a corresponding description of the enabled
- * probe (via the dtrace_eprobedesc structure) or the aggregation (via the
- * dtrace_aggdesc structure). Both of these structures are expressed in terms
- * of record descriptions (via the dtrace_recdesc structure) that describe the
- * exact structure of the data. Some record descriptions may also contain a
- * format identifier; this additional bit of metadata can be retrieved from the
- * kernel, for which a format description is returned via the dtrace_fmtdesc
- * structure. Note that all four of these structures must be bitness-neutral
- * to allow for a 32-bit DTrace consumer on a 64-bit kernel.
- */
-typedef struct dtrace_recdesc {
- dtrace_actkind_t dtrd_action; /* kind of action */
- uint32_t dtrd_size; /* size of record */
- uint32_t dtrd_offset; /* offset in ECB's data */
- uint16_t dtrd_alignment; /* required alignment */
- uint16_t dtrd_format; /* format, if any */
- uint64_t dtrd_arg; /* action argument */
- uint64_t dtrd_uarg; /* user argument */
-} dtrace_recdesc_t;
-
-typedef struct dtrace_eprobedesc {
- dtrace_epid_t dtepd_epid; /* enabled probe ID */
- dtrace_id_t dtepd_probeid; /* probe ID */
- uint64_t dtepd_uarg; /* library argument */
- uint32_t dtepd_size; /* total size */
- int dtepd_nrecs; /* number of records */
- dtrace_recdesc_t dtepd_rec[1]; /* records themselves */
-} dtrace_eprobedesc_t;
-
-typedef struct dtrace_aggdesc {
- DTRACE_PTR(char, dtagd_name); /* not filled in by kernel */
- dtrace_aggvarid_t dtagd_varid; /* not filled in by kernel */
- int dtagd_flags; /* not filled in by kernel */
- dtrace_aggid_t dtagd_id; /* aggregation ID */
- dtrace_epid_t dtagd_epid; /* enabled probe ID */
- uint32_t dtagd_size; /* size in bytes */
- int dtagd_nrecs; /* number of records */
- uint32_t dtagd_pad; /* explicit padding */
- dtrace_recdesc_t dtagd_rec[1]; /* record descriptions */
-} dtrace_aggdesc_t;
-
-typedef struct dtrace_fmtdesc {
- DTRACE_PTR(char, dtfd_string); /* format string */
- int dtfd_length; /* length of format string */
- uint16_t dtfd_format; /* format identifier */
-} dtrace_fmtdesc_t;
+ } dtrace_difo_t;
+
+ /*
+ * DTrace Enabling Description Structures
+ *
+ * When DTrace is tracking the description of a DTrace enabling entity (probe,
+ * predicate, action, ECB, record, etc.), it does so in a description
+ * structure. These structures all end in "desc", and are used at both
+ * user-level and in the kernel -- but (with the exception of
+ * dtrace_probedesc_t) they are never passed between them. Typically,
+ * user-level will use the description structures when assembling an enabling.
+ * It will then distill those description structures into a DOF object (see
+ * above), and send it into the kernel. The kernel will again use the
+ * description structures to create a description of the enabling as it reads
+ * the DOF. When the description is complete, the enabling will be actually
+ * created -- turning it into the structures that represent the enabling
+ * instead of merely describing it. Not surprisingly, the description
+ * structures bear a strong resemblance to the DOF structures that act as their
+ * conduit.
+ */
+ struct dtrace_predicate;
+
+ typedef struct dtrace_probedesc {
+ dtrace_id_t dtpd_id; /* probe identifier */
+ char dtpd_provider[DTRACE_PROVNAMELEN]; /* probe provider name */
+ char dtpd_mod[DTRACE_MODNAMELEN]; /* probe module name */
+ char dtpd_func[DTRACE_FUNCNAMELEN]; /* probe function name */
+ char dtpd_name[DTRACE_NAMELEN]; /* probe name */
+ } dtrace_probedesc_t;
+
+ typedef struct dtrace_repldesc {
+ dtrace_probedesc_t dtrpd_match; /* probe descr. to match */
+ dtrace_probedesc_t dtrpd_create; /* probe descr. to create */
+ } dtrace_repldesc_t;
+
+ typedef struct dtrace_preddesc {
+ dtrace_difo_t *dtpdd_difo; /* pointer to DIF object */
+ struct dtrace_predicate *dtpdd_predicate; /* pointer to predicate */
+ } dtrace_preddesc_t;
+
+ typedef struct dtrace_actdesc {
+ dtrace_difo_t *dtad_difo; /* pointer to DIF object */
+ struct dtrace_actdesc *dtad_next; /* next action */
+ dtrace_actkind_t dtad_kind; /* kind of action */
+ uint32_t dtad_ntuple; /* number in tuple */
+ uint64_t dtad_arg; /* action argument */
+ uint64_t dtad_uarg; /* user argument */
+ int dtad_refcnt; /* reference count */
+ } dtrace_actdesc_t;
+
+ typedef struct dtrace_ecbdesc {
+ dtrace_actdesc_t *dted_action; /* action description(s) */
+ dtrace_preddesc_t dted_pred; /* predicate description */
+ dtrace_probedesc_t dted_probe; /* probe description */
+ uint64_t dted_uarg; /* library argument */
+ int dted_refcnt; /* reference count */
+ } dtrace_ecbdesc_t;
+
+ /*
+ * DTrace Metadata Description Structures
+ *
+ * DTrace separates the trace data stream from the metadata stream. The only
+ * metadata tokens placed in the data stream are the dtrace_rechdr_t (EPID +
+ * timestamp) or (in the case of aggregations) aggregation identifiers. To
+ * determine the structure of the data, DTrace consumers pass the token to the
+ * kernel, and receive in return a corresponding description of the enabled
+ * probe (via the dtrace_eprobedesc structure) or the aggregation (via the
+ * dtrace_aggdesc structure). Both of these structures are expressed in terms
+ * of record descriptions (via the dtrace_recdesc structure) that describe the
+ * exact structure of the data. Some record descriptions may also contain a
+ * format identifier; this additional bit of metadata can be retrieved from the
+ * kernel, for which a format description is returned via the dtrace_fmtdesc
+ * structure. Note that all four of these structures must be bitness-neutral
+ * to allow for a 32-bit DTrace consumer on a 64-bit kernel.
+ */
+ typedef struct dtrace_recdesc {
+ dtrace_actkind_t dtrd_action; /* kind of action */
+ uint32_t dtrd_size; /* size of record */
+ uint32_t dtrd_offset; /* offset in ECB's data */
+ uint16_t dtrd_alignment; /* required alignment */
+ uint16_t dtrd_format; /* format, if any */
+ uint64_t dtrd_arg; /* action argument */
+ uint64_t dtrd_uarg; /* user argument */
+ } dtrace_recdesc_t;
+
+ typedef struct dtrace_eprobedesc {
+ dtrace_epid_t dtepd_epid; /* enabled probe ID */
+ dtrace_id_t dtepd_probeid; /* probe ID */
+ uint64_t dtepd_uarg; /* library argument */
+ uint32_t dtepd_size; /* total size */
+ int dtepd_nrecs; /* number of records */
+ dtrace_recdesc_t dtepd_rec[1]; /* records themselves */
+ } dtrace_eprobedesc_t;
+
+ typedef struct dtrace_aggdesc {
+ DTRACE_PTR(char, dtagd_name); /* not filled in by kernel */
+ dtrace_aggvarid_t dtagd_varid; /* not filled in by kernel */
+ int dtagd_flags; /* not filled in by kernel */
+ dtrace_aggid_t dtagd_id; /* aggregation ID */
+ dtrace_epid_t dtagd_epid; /* enabled probe ID */
+ uint32_t dtagd_size; /* size in bytes */
+ int dtagd_nrecs; /* number of records */
+ uint32_t dtagd_pad; /* explicit padding */
+ dtrace_recdesc_t dtagd_rec[1]; /* record descriptions */
+ } dtrace_aggdesc_t;
+
+ typedef struct dtrace_fmtdesc {
+ DTRACE_PTR(char, dtfd_string); /* format string */
+ int dtfd_length; /* length of format string */
+ uint16_t dtfd_format; /* format identifier */
+ } dtrace_fmtdesc_t;
#define DTRACE_SIZEOF_EPROBEDESC(desc) \
(sizeof (dtrace_eprobedesc_t) + ((desc)->dtepd_nrecs ? \
- (((desc)->dtepd_nrecs - 1) * sizeof (dtrace_recdesc_t)) : 0))
+ (((desc)->dtepd_nrecs - 1) * sizeof (dtrace_recdesc_t)) : 0))
#define DTRACE_SIZEOF_AGGDESC(desc) \
(sizeof (dtrace_aggdesc_t) + ((desc)->dtagd_nrecs ? \
- (((desc)->dtagd_nrecs - 1) * sizeof (dtrace_recdesc_t)) : 0))
-
-/*
- * DTrace Option Interface
- *
- * Run-time DTrace options are set and retrieved via DOF_SECT_OPTDESC sections
- * in a DOF image. The dof_optdesc structure contains an option identifier and
- * an option value. The valid option identifiers are found below; the mapping
- * between option identifiers and option identifying strings is maintained at
- * user-level. Note that the value of DTRACEOPT_UNSET is such that all of the
- * following are potentially valid option values: all positive integers, zero
- * and negative one. Some options (notably "bufpolicy" and "bufresize") take
- * predefined tokens as their values; these are defined with
- * DTRACEOPT_{option}_{token}.
- */
+ (((desc)->dtagd_nrecs - 1) * sizeof (dtrace_recdesc_t)) : 0))
+
+ /*
+ * DTrace Option Interface
+ *
+ * Run-time DTrace options are set and retrieved via DOF_SECT_OPTDESC sections
+ * in a DOF image. The dof_optdesc structure contains an option identifier and
+ * an option value. The valid option identifiers are found below; the mapping
+ * between option identifiers and option identifying strings is maintained at
+ * user-level. Note that the value of DTRACEOPT_UNSET is such that all of the
+ * following are potentially valid option values: all positive integers, zero
+ * and negative one. Some options (notably "bufpolicy" and "bufresize") take
+ * predefined tokens as their values; these are defined with
+ * DTRACEOPT_{option}_{token}.
+ */
#define DTRACEOPT_BUFSIZE 0 /* buffer size */
#define DTRACEOPT_BUFPOLICY 1 /* buffer policy */
#define DTRACEOPT_DYNVARSIZE 2 /* dynamic variable size */
@@ -1018,8 +1019,9 @@ typedef struct dtrace_fmtdesc {
#define DTRACEOPT_AGGSORTREV 24 /* reverse-sort aggregations */
#define DTRACEOPT_AGGSORTPOS 25 /* agg. position to sort on */
#define DTRACEOPT_AGGSORTKEYPOS 26 /* agg. key position to sort on */
-#define DTRACEOPT_ZONE 27 /* zone in which to enable probes */
+#define DTRACEOPT_TEMPORAL 27 /* temporally ordered output */
#define DTRACEOPT_MAX 28 /* number of options */
+#define DTRACEOPT_ZONE 29 /* zone in which to enable probes */
#define DTRACEOPT_UNSET (dtrace_optval_t)-2 /* unset option */
@@ -1039,7 +1041,9 @@ typedef struct dtrace_fmtdesc {
* where user-level wishes the kernel to snapshot the buffer to (the
* dtbd_data field). The kernel uses the same structure to pass back some
* information regarding the buffer: the size of data actually copied out, the
- * number of drops, the number of errors, and the offset of the oldest record.
+ * number of drops, the number of errors, the offset of the oldest record,
+ * and the time of the snapshot.
+ *
* If the buffer policy is a "switch" policy, taking a snapshot of the
* principal buffer has the additional effect of switching the active and
* inactive buffers. Taking a snapshot of the aggregation buffer _always_ has
@@ -1052,9 +1056,30 @@ typedef struct dtrace_bufdesc {
uint64_t dtbd_drops; /* number of drops */
DTRACE_PTR(char, dtbd_data); /* data */
uint64_t dtbd_oldest; /* offset of oldest record */
+ uint64_t dtbd_timestamp; /* hrtime of snapshot */
} dtrace_bufdesc_t;
/*
+ * Each record in the buffer (dtbd_data) begins with a header that includes
+ * the epid and a timestamp. The timestamp is split into two 4-byte parts
+ * so that we do not require 8-byte alignment.
+ */
+typedef struct dtrace_rechdr {
+ dtrace_epid_t dtrh_epid; /* enabled probe id */
+ uint32_t dtrh_timestamp_hi; /* high bits of hrtime_t */
+ uint32_t dtrh_timestamp_lo; /* low bits of hrtime_t */
+} dtrace_rechdr_t;
+
+#define DTRACE_RECORD_LOAD_TIMESTAMP(dtrh) \
+ ((dtrh)->dtrh_timestamp_lo + \
+ ((uint64_t)(dtrh)->dtrh_timestamp_hi << 32))
+
+#define DTRACE_RECORD_STORE_TIMESTAMP(dtrh, hrtime) { \
+ (dtrh)->dtrh_timestamp_lo = (uint32_t)hrtime; \
+ (dtrh)->dtrh_timestamp_hi = hrtime >> 32; \
+}
+
+/*
* DTrace Status
*
* The status of DTrace is relayed via the dtrace_status structure. This
diff --git a/usr/src/uts/common/sys/dtrace_impl.h b/usr/src/uts/common/sys/dtrace_impl.h
index 5e892b806b..f79bf1e42e 100644
--- a/usr/src/uts/common/sys/dtrace_impl.h
+++ b/usr/src/uts/common/sys/dtrace_impl.h
@@ -26,6 +26,7 @@
/*
* Copyright (c) 2011, Joyent, Inc. All rights reserved.
+ * Copyright (c) 2012 by Delphix. All rights reserved.
*/
#ifndef _SYS_DTRACE_IMPL_H
@@ -199,15 +200,18 @@ typedef struct dtrace_hash {
* predicate is non-NULL, the DIF object is executed. If the result is
* non-zero, the action list is processed, with each action being executed
* accordingly. When the action list has been completely executed, processing
- * advances to the next ECB. processing advances to the next ECB. If the
- * result is non-zero; For each ECB, it first determines the The ECB
- * abstraction allows disjoint consumers to multiplex on single probes.
+ * advances to the next ECB. The ECB abstraction allows disjoint consumers
+ * to multiplex on single probes.
+ *
+ * Execution of the ECB results in consuming dte_size bytes in the buffer
+ * to record data. During execution, dte_needed bytes must be available in
+ * the buffer. This space is used for both recorded data and tuple data.
*/
struct dtrace_ecb {
dtrace_epid_t dte_epid; /* enabled probe ID */
uint32_t dte_alignment; /* required alignment */
- size_t dte_needed; /* bytes needed */
- size_t dte_size; /* total size of payload */
+ size_t dte_needed; /* space needed for execution */
+ size_t dte_size; /* size of recorded payload */
dtrace_predicate_t *dte_predicate; /* predicate, if any */
dtrace_action_t *dte_action; /* actions, if any */
dtrace_ecb_t *dte_next; /* next ECB on probe */
@@ -265,27 +269,30 @@ typedef struct dtrace_aggregation {
* the EPID, the consumer can determine the data layout. (The data buffer
* layout is shown schematically below.) By assuring that one can determine
* data layout from the EPID, the metadata stream can be separated from the
- * data stream -- simplifying the data stream enormously.
- *
- * base of data buffer ---> +------+--------------------+------+
- * | EPID | data | EPID |
- * +------+--------+------+----+------+
- * | data | EPID | data |
- * +---------------+------+-----------+
- * | data, cont. |
- * +------+--------------------+------+
- * | EPID | data | |
- * +------+--------------------+ |
- * | || |
- * | || |
- * | \/ |
- * : :
- * . .
- * . .
- * . .
- * : :
- * | |
- * limit of data buffer ---> +----------------------------------+
+ * data stream -- simplifying the data stream enormously. The ECB always
+ * proceeds the recorded data as part of the dtrace_rechdr_t structure that
+ * includes the EPID and a high-resolution timestamp used for output ordering
+ * consistency.
+ *
+ * base of data buffer ---> +--------+--------------------+--------+
+ * | rechdr | data | rechdr |
+ * +--------+------+--------+----+--------+
+ * | data | rechdr | data |
+ * +---------------+--------+-------------+
+ * | data, cont. |
+ * +--------+--------------------+--------+
+ * | rechdr | data | |
+ * +--------+--------------------+ |
+ * | || |
+ * | || |
+ * | \/ |
+ * : :
+ * . .
+ * . .
+ * . .
+ * : :
+ * | |
+ * limit of data buffer ---> +--------------------------------------+
*
* When evaluating an ECB, dtrace_probe() determines if the ECB's needs of the
* principal buffer (both scratch and payload) exceed the available space. If
diff --git a/usr/src/uts/common/sys/feature_tests.h b/usr/src/uts/common/sys/feature_tests.h
index 43339a83cd..e6ababd3d4 100644
--- a/usr/src/uts/common/sys/feature_tests.h
+++ b/usr/src/uts/common/sys/feature_tests.h
@@ -27,8 +27,6 @@
#ifndef _SYS_FEATURE_TESTS_H
#define _SYS_FEATURE_TESTS_H
-#pragma ident "%Z%%M% %I% %E% SMI"
-
#include <sys/ccompile.h>
#include <sys/isa_defs.h>
@@ -365,7 +363,7 @@ extern "C" {
* compiler is used. This allows for the use of single prototype
* declarations regardless of compiler version.
*/
-#if (defined(__STDC__) && defined(_STDC_C99))
+#if (defined(__STDC__) && defined(_STDC_C99)) && !defined(__cplusplus)
#define _RESTRICT_KYWD restrict
#else
#define _RESTRICT_KYWD
diff --git a/usr/src/uts/common/sys/fork.h b/usr/src/uts/common/sys/fork.h
index 414cdb2ff0..aa455b35c2 100644
--- a/usr/src/uts/common/sys/fork.h
+++ b/usr/src/uts/common/sys/fork.h
@@ -39,7 +39,7 @@ extern "C" {
extern pid_t forkx(int);
extern pid_t forkallx(int);
-extern pid_t vforkx(int);
+extern pid_t vforkx(int) __RETURNS_TWICE;
#pragma unknown_control_flow(vforkx)
diff --git a/usr/src/uts/common/sys/fs/hsfs_isospec.h b/usr/src/uts/common/sys/fs/hsfs_isospec.h
index 99fd44fc12..361dca1293 100644
--- a/usr/src/uts/common/sys/fs/hsfs_isospec.h
+++ b/usr/src/uts/common/sys/fs/hsfs_isospec.h
@@ -26,8 +26,6 @@
#ifndef _SYS_FS_HSFS_ISOSPEC_H
#define _SYS_FS_HSFS_ISOSPEC_H
-#pragma ident "%Z%%M% %I% %E% SMI"
-
/*
* ISO 9660 filesystem specification
*/
@@ -87,6 +85,7 @@ extern "C" {
enum iso_voldesc_type {
ISO_VD_BOOT = 0, ISO_VD_PVD = 1, ISO_VD_SVD = 2, ISO_VD_VPD = 3,
+ ISO_VD_UNIX = 4, /* UNIX extension */
ISO_VD_EOV = 255
};
#define ISO_ID_STRING "CD001" /* ISO_std_id field */
@@ -138,7 +137,7 @@ enum iso_voldesc_type {
#define ISO_file_struct_ver(x) (&((uchar_t *)x)[881])
/* macros to get the values of each field (strings are returned as ptrs) */
-#define ISO_DESC_TYPE(x) ((enum hs_voldesc_type)*(ISO_desc_type(x)))
+#define ISO_DESC_TYPE(x) ((enum iso_voldesc_type)*(ISO_desc_type(x)))
#define ISO_STD_ID(x) ISO_std_id(x)
#define ISO_STD_VER(x) *(ISO_std_ver(x))
#define ISO_SYS_ID(x) ISO_sys_id(x)
diff --git a/usr/src/uts/common/sys/fs/zfs.h b/usr/src/uts/common/sys/fs/zfs.h
index a523201954..8639a2b8db 100644
--- a/usr/src/uts/common/sys/fs/zfs.h
+++ b/usr/src/uts/common/sys/fs/zfs.h
@@ -23,6 +23,7 @@
* Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright (c) 2012 by Delphix. All rights reserved.
* Copyright 2011 Nexenta Systems, Inc. All rights reserved.
+ * Copyright (c) 2012, Joyent, Inc. All rights reserved.
*/
/* Portions Copyright 2010 Robert Milkowski */
@@ -51,6 +52,16 @@ typedef enum {
ZFS_TYPE_POOL = 0x8
} zfs_type_t;
+typedef enum dmu_objset_type {
+ DMU_OST_NONE,
+ DMU_OST_META,
+ DMU_OST_ZFS,
+ DMU_OST_ZVOL,
+ DMU_OST_OTHER, /* For testing only! */
+ DMU_OST_ANY, /* Be careful! */
+ DMU_OST_NUMTYPES
+} dmu_objset_type_t;
+
#define ZFS_TYPE_DATASET \
(ZFS_TYPE_FILESYSTEM | ZFS_TYPE_VOLUME | ZFS_TYPE_SNAPSHOT)
@@ -168,6 +179,7 @@ typedef enum {
ZPOOL_PROP_READONLY,
ZPOOL_PROP_COMMENT,
ZPOOL_PROP_EXPANDSZ,
+ ZPOOL_PROP_FREEING,
ZPOOL_NUM_PROPS
} zpool_prop_t;
@@ -242,6 +254,8 @@ const char *zpool_prop_to_name(zpool_prop_t);
const char *zpool_prop_default_string(zpool_prop_t);
uint64_t zpool_prop_default_numeric(zpool_prop_t);
boolean_t zpool_prop_readonly(zpool_prop_t);
+boolean_t zpool_prop_feature(const char *);
+boolean_t zpool_prop_unsupported(const char *name);
int zpool_prop_index_to_string(zpool_prop_t, uint64_t, const char **);
int zpool_prop_string_to_index(zpool_prop_t, const char *, uint64_t *);
uint64_t zpool_prop_random_value(zpool_prop_t, uint64_t seed);
@@ -349,6 +363,7 @@ typedef enum {
#define SPA_VERSION_26 26ULL
#define SPA_VERSION_27 27ULL
#define SPA_VERSION_28 28ULL
+#define SPA_VERSION_5000 5000ULL
/*
* When bumping up SPA_VERSION, make sure GRUB ZFS understands the on-disk
@@ -356,8 +371,8 @@ typedef enum {
* and do the appropriate changes. Also bump the version number in
* usr/src/grub/capability.
*/
-#define SPA_VERSION SPA_VERSION_28
-#define SPA_VERSION_STRING "28"
+#define SPA_VERSION SPA_VERSION_5000
+#define SPA_VERSION_STRING "5000"
/*
* Symbolic names for the changes that caused a SPA_VERSION switch.
@@ -408,6 +423,12 @@ typedef enum {
#define SPA_VERSION_DEADLISTS SPA_VERSION_26
#define SPA_VERSION_FAST_SNAP SPA_VERSION_27
#define SPA_VERSION_MULTI_REPLACE SPA_VERSION_28
+#define SPA_VERSION_BEFORE_FEATURES SPA_VERSION_28
+#define SPA_VERSION_FEATURES SPA_VERSION_5000
+
+#define SPA_VERSION_IS_SUPPORTED(v) \
+ (((v) >= SPA_VERSION_INITIAL && (v) <= SPA_VERSION_BEFORE_FEATURES) || \
+ ((v) >= SPA_VERSION_FEATURES && (v) <= SPA_VERSION))
/*
* ZPL version - rev'd whenever an incompatible on-disk format change
@@ -505,6 +526,12 @@ typedef struct zpool_rewind_policy {
#define ZPOOL_CONFIG_BOOTFS "bootfs" /* not stored on disk */
#define ZPOOL_CONFIG_MISSING_DEVICES "missing_vdevs" /* not stored on disk */
#define ZPOOL_CONFIG_LOAD_INFO "load_info" /* not stored on disk */
+#define ZPOOL_CONFIG_REWIND_INFO "rewind_info" /* not stored on disk */
+#define ZPOOL_CONFIG_UNSUP_FEAT "unsup_feat" /* not stored on disk */
+#define ZPOOL_CONFIG_ENABLED_FEAT "enabled_feat" /* not stored on disk */
+#define ZPOOL_CONFIG_CAN_RDONLY "can_rdonly" /* not stored on disk */
+#define ZPOOL_CONFIG_FEATURES_FOR_READ "features_for_read"
+#define ZPOOL_CONFIG_FEATURE_STATS "feature_stats" /* not stored on disk */
/*
* The persistent vdev state is stored as separate values rather than a single
* 'vdev_state' entry. This is because a device can be in multiple states, such
@@ -583,6 +610,7 @@ typedef enum vdev_aux {
VDEV_AUX_BAD_LABEL, /* the label is OK but invalid */
VDEV_AUX_VERSION_NEWER, /* on-disk version is too new */
VDEV_AUX_VERSION_OLDER, /* on-disk version is too old */
+ VDEV_AUX_UNSUP_FEAT, /* unsupported features */
VDEV_AUX_SPARED, /* hot spare used in another pool */
VDEV_AUX_ERR_EXCEEDED, /* too many errors */
VDEV_AUX_IO_FAILURE, /* experienced I/O failure */
@@ -727,10 +755,10 @@ typedef struct ddt_histogram {
/*
* /dev/zfs ioctl numbers.
*/
-#define ZFS_IOC ('Z' << 8)
-
typedef enum zfs_ioc {
- ZFS_IOC_POOL_CREATE = ZFS_IOC,
+ ZFS_IOC_FIRST = ('Z' << 8),
+ ZFS_IOC = ZFS_IOC_FIRST,
+ ZFS_IOC_POOL_CREATE = ZFS_IOC_FIRST,
ZFS_IOC_POOL_DESTROY,
ZFS_IOC_POOL_IMPORT,
ZFS_IOC_POOL_EXPORT,
@@ -789,9 +817,15 @@ typedef enum zfs_ioc {
ZFS_IOC_OBJ_TO_STATS,
ZFS_IOC_SPACE_WRITTEN,
ZFS_IOC_SPACE_SNAPS,
- ZFS_IOC_DESTROY_SNAPS_NVL,
+ ZFS_IOC_DESTROY_SNAPS,
ZFS_IOC_POOL_REGUID,
- ZFS_IOC_POOL_REOPEN
+ ZFS_IOC_POOL_REOPEN,
+ ZFS_IOC_SEND_PROGRESS,
+ ZFS_IOC_LOG_HISTORY,
+ ZFS_IOC_SEND_NEW,
+ ZFS_IOC_SEND_SPACE,
+ ZFS_IOC_CLONE,
+ ZFS_IOC_LAST
} zfs_ioc_t;
/*
@@ -828,6 +862,12 @@ typedef enum {
#define ZPOOL_HIST_TXG "history txg"
#define ZPOOL_HIST_INT_EVENT "history internal event"
#define ZPOOL_HIST_INT_STR "history internal str"
+#define ZPOOL_HIST_INT_NAME "internal_name"
+#define ZPOOL_HIST_IOCTL "ioctl"
+#define ZPOOL_HIST_INPUT_NVL "in_nvl"
+#define ZPOOL_HIST_OUTPUT_NVL "out_nvl"
+#define ZPOOL_HIST_DSNAME "dsname"
+#define ZPOOL_HIST_DSID "dsid"
/*
* Flags for ZFS_IOC_VDEV_SET_STATE
@@ -873,56 +913,6 @@ typedef enum {
#define ZFS_EV_VDEV_PATH "vdev_path"
#define ZFS_EV_VDEV_GUID "vdev_guid"
-/*
- * Note: This is encoded on-disk, so new events must be added to the
- * end, and unused events can not be removed. Be sure to edit
- * libzfs_pool.c: hist_event_table[].
- */
-typedef enum history_internal_events {
- LOG_NO_EVENT = 0,
- LOG_POOL_CREATE,
- LOG_POOL_VDEV_ADD,
- LOG_POOL_REMOVE,
- LOG_POOL_DESTROY,
- LOG_POOL_EXPORT,
- LOG_POOL_IMPORT,
- LOG_POOL_VDEV_ATTACH,
- LOG_POOL_VDEV_REPLACE,
- LOG_POOL_VDEV_DETACH,
- LOG_POOL_VDEV_ONLINE,
- LOG_POOL_VDEV_OFFLINE,
- LOG_POOL_UPGRADE,
- LOG_POOL_CLEAR,
- LOG_POOL_SCAN,
- LOG_POOL_PROPSET,
- LOG_DS_CREATE,
- LOG_DS_CLONE,
- LOG_DS_DESTROY,
- LOG_DS_DESTROY_BEGIN,
- LOG_DS_INHERIT,
- LOG_DS_PROPSET,
- LOG_DS_QUOTA,
- LOG_DS_PERM_UPDATE,
- LOG_DS_PERM_REMOVE,
- LOG_DS_PERM_WHO_REMOVE,
- LOG_DS_PROMOTE,
- LOG_DS_RECEIVE,
- LOG_DS_RENAME,
- LOG_DS_RESERVATION,
- LOG_DS_REPLAY_INC_SYNC,
- LOG_DS_REPLAY_FULL_SYNC,
- LOG_DS_ROLLBACK,
- LOG_DS_SNAPSHOT,
- LOG_DS_UPGRADE,
- LOG_DS_REFQUOTA,
- LOG_DS_REFRESERV,
- LOG_POOL_SCAN_DONE,
- LOG_DS_USER_HOLD,
- LOG_DS_USER_RELEASE,
- LOG_POOL_SPLIT,
- LOG_END
-} history_internal_events_t;
-
#ifdef __cplusplus
}
#endif
diff --git a/usr/src/uts/common/sys/ib/clients/rdsv3/rdsv3_impl.h b/usr/src/uts/common/sys/ib/clients/rdsv3/rdsv3_impl.h
index 84eb2074df..c1407bfe00 100644
--- a/usr/src/uts/common/sys/ib/clients/rdsv3/rdsv3_impl.h
+++ b/usr/src/uts/common/sys/ib/clients/rdsv3/rdsv3_impl.h
@@ -20,6 +20,7 @@
*/
/*
* Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright 2012 Nexenta Systems, Inc. All rights reserved.
*/
#ifndef _RDSV3_IMPL_H
@@ -120,9 +121,6 @@ uint_t rdsv3_one_sec_in_hz;
#define jiffies 100
#define HZ (drv_hztousec(1))
-#define container_of(m, s, name) \
- (void *)((uintptr_t)(m) - (uintptr_t)offsetof(s, name))
-#define ARRAY_SIZE(x) (sizeof (x) / sizeof (x[0]))
/* setting this to PAGESIZE throws build errors */
#define PAGE_SIZE 4096 /* xxx - fix this */
#define BITS_PER_LONG (sizeof (unsigned long) * 8)
diff --git a/usr/src/uts/common/sys/nvpair.h b/usr/src/uts/common/sys/nvpair.h
index 30ff4e0667..ad25effc29 100644
--- a/usr/src/uts/common/sys/nvpair.h
+++ b/usr/src/uts/common/sys/nvpair.h
@@ -20,12 +20,14 @@
*/
/*
* Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012 by Delphix. All rights reserved.
*/
#ifndef _SYS_NVPAIR_H
#define _SYS_NVPAIR_H
#include <sys/types.h>
+#include <sys/time.h>
#include <sys/errno.h>
#include <sys/va_list.h>
@@ -274,6 +276,73 @@ int nvpair_value_hrtime(nvpair_t *, hrtime_t *);
int nvpair_value_double(nvpair_t *, double *);
#endif
+nvlist_t *fnvlist_alloc(void);
+void fnvlist_free(nvlist_t *);
+size_t fnvlist_size(nvlist_t *);
+char *fnvlist_pack(nvlist_t *, size_t *);
+void fnvlist_pack_free(char *, size_t);
+nvlist_t *fnvlist_unpack(char *, size_t);
+nvlist_t *fnvlist_dup(nvlist_t *);
+void fnvlist_merge(nvlist_t *, nvlist_t *);
+
+void fnvlist_add_boolean(nvlist_t *, const char *);
+void fnvlist_add_boolean_value(nvlist_t *, const char *, boolean_t);
+void fnvlist_add_byte(nvlist_t *, const char *, uchar_t);
+void fnvlist_add_int8(nvlist_t *, const char *, int8_t);
+void fnvlist_add_uint8(nvlist_t *, const char *, uint8_t);
+void fnvlist_add_int16(nvlist_t *, const char *, int16_t);
+void fnvlist_add_uint16(nvlist_t *, const char *, uint16_t);
+void fnvlist_add_int32(nvlist_t *, const char *, int32_t);
+void fnvlist_add_uint32(nvlist_t *, const char *, uint32_t);
+void fnvlist_add_int64(nvlist_t *, const char *, int64_t);
+void fnvlist_add_uint64(nvlist_t *, const char *, uint64_t);
+void fnvlist_add_string(nvlist_t *, const char *, const char *);
+void fnvlist_add_nvlist(nvlist_t *, const char *, nvlist_t *);
+void fnvlist_add_nvpair(nvlist_t *, nvpair_t *);
+void fnvlist_add_boolean_array(nvlist_t *, const char *, boolean_t *, uint_t);
+void fnvlist_add_byte_array(nvlist_t *, const char *, uchar_t *, uint_t);
+void fnvlist_add_int8_array(nvlist_t *, const char *, int8_t *, uint_t);
+void fnvlist_add_uint8_array(nvlist_t *, const char *, uint8_t *, uint_t);
+void fnvlist_add_int16_array(nvlist_t *, const char *, int16_t *, uint_t);
+void fnvlist_add_uint16_array(nvlist_t *, const char *, uint16_t *, uint_t);
+void fnvlist_add_int32_array(nvlist_t *, const char *, int32_t *, uint_t);
+void fnvlist_add_uint32_array(nvlist_t *, const char *, uint32_t *, uint_t);
+void fnvlist_add_int64_array(nvlist_t *, const char *, int64_t *, uint_t);
+void fnvlist_add_uint64_array(nvlist_t *, const char *, uint64_t *, uint_t);
+void fnvlist_add_string_array(nvlist_t *, const char *, char * const *, uint_t);
+void fnvlist_add_nvlist_array(nvlist_t *, const char *, nvlist_t **, uint_t);
+
+void fnvlist_remove(nvlist_t *, const char *);
+void fnvlist_remove_nvpair(nvlist_t *, nvpair_t *);
+
+nvpair_t *fnvlist_lookup_nvpair(nvlist_t *nvl, const char *name);
+boolean_t fnvlist_lookup_boolean(nvlist_t *nvl, const char *name);
+boolean_t fnvlist_lookup_boolean_value(nvlist_t *nvl, const char *name);
+uchar_t fnvlist_lookup_byte(nvlist_t *nvl, const char *name);
+int8_t fnvlist_lookup_int8(nvlist_t *nvl, const char *name);
+int16_t fnvlist_lookup_int16(nvlist_t *nvl, const char *name);
+int32_t fnvlist_lookup_int32(nvlist_t *nvl, const char *name);
+int64_t fnvlist_lookup_int64(nvlist_t *nvl, const char *name);
+uint8_t fnvlist_lookup_uint8_t(nvlist_t *nvl, const char *name);
+uint16_t fnvlist_lookup_uint16(nvlist_t *nvl, const char *name);
+uint32_t fnvlist_lookup_uint32(nvlist_t *nvl, const char *name);
+uint64_t fnvlist_lookup_uint64(nvlist_t *nvl, const char *name);
+char *fnvlist_lookup_string(nvlist_t *nvl, const char *name);
+nvlist_t *fnvlist_lookup_nvlist(nvlist_t *nvl, const char *name);
+
+boolean_t fnvpair_value_boolean_value(nvpair_t *nvp);
+uchar_t fnvpair_value_byte(nvpair_t *nvp);
+int8_t fnvpair_value_int8(nvpair_t *nvp);
+int16_t fnvpair_value_int16(nvpair_t *nvp);
+int32_t fnvpair_value_int32(nvpair_t *nvp);
+int64_t fnvpair_value_int64(nvpair_t *nvp);
+uint8_t fnvpair_value_uint8_t(nvpair_t *nvp);
+uint16_t fnvpair_value_uint16(nvpair_t *nvp);
+uint32_t fnvpair_value_uint32(nvpair_t *nvp);
+uint64_t fnvpair_value_uint64(nvpair_t *nvp);
+char *fnvpair_value_string(nvpair_t *nvp);
+nvlist_t *fnvpair_value_nvlist(nvpair_t *nvp);
+
#ifdef __cplusplus
}
#endif
diff --git a/usr/src/uts/common/sys/ontrap.h b/usr/src/uts/common/sys/ontrap.h
index a7718848a1..3edc70d2dc 100644
--- a/usr/src/uts/common/sys/ontrap.h
+++ b/usr/src/uts/common/sys/ontrap.h
@@ -26,8 +26,6 @@
#ifndef _ONTRAP_H
#define _ONTRAP_H
-#pragma ident "%Z%%M% %I% %E% SMI"
-
#if !defined(_ASM)
#include <sys/types.h>
#endif
@@ -104,7 +102,7 @@ typedef struct on_trap_data {
#if defined(_KERNEL)
-extern int on_trap(on_trap_data_t *, uint_t);
+extern int on_trap(on_trap_data_t *, uint_t) __RETURNS_TWICE;
#pragma unknown_control_flow(on_trap)
extern void no_trap(void);
diff --git a/usr/src/uts/common/sys/scsi/adapters/mpt_sas/mptsas_var.h b/usr/src/uts/common/sys/scsi/adapters/mpt_sas/mptsas_var.h
index 7a37bcdcaa..c757299b32 100644
--- a/usr/src/uts/common/sys/scsi/adapters/mpt_sas/mptsas_var.h
+++ b/usr/src/uts/common/sys/scsi/adapters/mpt_sas/mptsas_var.h
@@ -21,6 +21,7 @@
/*
* Copyright (c) 2009, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright 2012 Nexenta Systems, Inc. All rights reserved.
*/
/*
@@ -1313,7 +1314,7 @@ void mptsas_dma_addr_destroy(ddi_dma_handle_t *, ddi_acc_handle_t *);
*/
int mptsas_ioc_wait_for_response(mptsas_t *mpt);
int mptsas_ioc_wait_for_doorbell(mptsas_t *mpt);
-int mptsas_ioc_reset(mptsas_t *mpt);
+int mptsas_ioc_reset(mptsas_t *mpt, int);
int mptsas_send_handshake_msg(mptsas_t *mpt, caddr_t memp, int numbytes,
ddi_acc_handle_t accessp);
int mptsas_get_handshake_msg(mptsas_t *mpt, caddr_t memp, int numbytes,
diff --git a/usr/src/uts/common/sys/sunddi.h b/usr/src/uts/common/sys/sunddi.h
index 1eaf3a4feb..8d1fd5e730 100644
--- a/usr/src/uts/common/sys/sunddi.h
+++ b/usr/src/uts/common/sys/sunddi.h
@@ -22,6 +22,7 @@
/*
* Copyright (c) 1990, 2010, Oracle and/or its affiliates. All rights reserved.
* Copyright 2012 Garrett D'Amore <garrett@damore.org>. All rights reserved.
+ * Copyright (c) 2012 by Delphix. All rights reserved.
*/
#ifndef _SYS_SUNDDI_H
@@ -460,6 +461,7 @@ extern char *strncat(char *, const char *, size_t);
extern size_t strlcat(char *, const char *, size_t);
extern size_t strlcpy(char *, const char *, size_t);
extern size_t strspn(const char *, const char *);
+extern size_t strcspn(const char *, const char *);
extern int bcmp(const void *, const void *, size_t) __PURE;
extern int stoi(char **);
extern void numtos(ulong_t, char *);
diff --git a/usr/src/uts/common/sys/sysmacros.h b/usr/src/uts/common/sys/sysmacros.h
index 89a672db2f..71042eba85 100644
--- a/usr/src/uts/common/sys/sysmacros.h
+++ b/usr/src/uts/common/sys/sysmacros.h
@@ -25,6 +25,8 @@
/*
* Copyright 2008 Sun Microsystems, Inc. All rights reserved.
* Use is subject to license terms.
+ *
+ * Copyright 2011, 2012 Nexenta Systems, Inc. All rights reserved.
*/
#ifndef _SYS_SYSMACROS_H
@@ -364,12 +366,18 @@ extern unsigned char bcd_to_byte[256];
#error One of _BIT_FIELDS_LTOH or _BIT_FIELDS_HTOL must be defined
#endif /* _BIT_FIELDS_LTOH */
-#if defined(_KERNEL) && !defined(_KMEMUSER) && !defined(offsetof)
-
/* avoid any possibility of clashing with <stddef.h> version */
+#if defined(_KERNEL) && !defined(_KMEMUSER)
+#if !defined(offsetof)
#define offsetof(s, m) ((size_t)(&(((s *)0)->m)))
-#endif
+#endif /* !offsetof */
+
+#define container_of(m, s, name) \
+ (void *)((uintptr_t)(m) - (uintptr_t)offsetof(s, name))
+
+#define ARRAY_SIZE(x) (sizeof (x) / sizeof (x[0]))
+#endif /* _KERNEL, !_KMEMUSER */
#ifdef __cplusplus
}
diff --git a/usr/src/uts/common/sys/systm.h b/usr/src/uts/common/sys/systm.h
index e5ee80c404..8edfd994ab 100644
--- a/usr/src/uts/common/sys/systm.h
+++ b/usr/src/uts/common/sys/systm.h
@@ -247,7 +247,7 @@ void suword64_noerr(void *, uint64_t);
#endif
#if !defined(_BOOT)
-int setjmp(label_t *);
+int setjmp(label_t *) __RETURNS_TWICE;
extern void longjmp(label_t *)
__NORETURN;
#pragma unknown_control_flow(setjmp)
@@ -260,7 +260,7 @@ void prefetch_write_many(void *);
caddr_t caller(void);
caddr_t callee(void);
int getpcstack(pc_t *, int);
-int on_fault(label_t *);
+int on_fault(label_t *) __RETURNS_TWICE;
void no_fault(void);
void halt(char *);
int scanc(size_t, uchar_t *, uchar_t *, uchar_t);
diff --git a/usr/src/uts/common/sys/usb/clients/usbser/usbftdi/uftdi_var.h b/usr/src/uts/common/sys/usb/clients/usbser/usbftdi/uftdi_var.h
index 698a9cd454..09e3c03d97 100644
--- a/usr/src/uts/common/sys/usb/clients/usbser/usbftdi/uftdi_var.h
+++ b/usr/src/uts/common/sys/usb/clients/usbser/usbftdi/uftdi_var.h
@@ -67,6 +67,7 @@ typedef struct uftdi_state {
kmutex_t uf_lock; /* structure lock */
dev_info_t *uf_dip; /* device info */
int uf_dev_flags; /* device flags */
+ int uf_hwport; /* hw port number */
int uf_port_state; /* port state */
int uf_port_flags; /* port flags */
ds_cb_t uf_cb; /* DSD callbacks */
@@ -117,6 +118,7 @@ _NOTE(DATA_READABLE_WITHOUT_LOCK(uftdi_state::{
uf_cb
uf_bulkin_ph
uf_bulkout_ph
+ uf_hwport
}))
/* port state */
diff --git a/usr/src/uts/common/sys/vmem.h b/usr/src/uts/common/sys/vmem.h
index 669f32699d..9d72797a52 100644
--- a/usr/src/uts/common/sys/vmem.h
+++ b/usr/src/uts/common/sys/vmem.h
@@ -20,6 +20,7 @@
*/
/*
* Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2012 by Delphix. All rights reserved.
*/
#ifndef _SYS_VMEM_H
@@ -142,6 +143,7 @@ extern void *vmem_add(vmem_t *, void *, size_t, int);
extern int vmem_contains(vmem_t *, void *, size_t);
extern void vmem_walk(vmem_t *, int, void (*)(void *, void *, size_t), void *);
extern size_t vmem_size(vmem_t *, int);
+extern void vmem_qcache_reap(vmem_t *vmp);
#ifdef __cplusplus
}
diff --git a/usr/src/uts/i86pc/Makefile.rules b/usr/src/uts/i86pc/Makefile.rules
index 604a2fb2c5..1942322231 100644
--- a/usr/src/uts/i86pc/Makefile.rules
+++ b/usr/src/uts/i86pc/Makefile.rules
@@ -218,6 +218,7 @@ DBOOT_MACH_32 = -D_BOOT_TARGET_i386
DBOOT_MACH_64 = -D_BOOT_TARGET_amd64
DBOOT_DEFS = -D_BOOT $(DBOOT_MACH_$(CLASS))
DBOOT_DEFS += -D_MACHDEP -D_KMEMUSER -U_KERNEL -D_I32LPx
+DBOOT_FLAGS = $(CCVERBOSE) $(CERRWARN) $(CCNOAUTOINLINE)
DBOOT_CC_INCL = -I$(SRC)/common $(INCLUDE_PATH)
DBOOT_AS_INCL = $(AS_INC_PATH)
@@ -233,16 +234,16 @@ DBOOT_LOCAL_LINTFLAGS = -c -dirout=$(DBOOT_LINTS_DIR) -I$(SRC)/common \
$(DBOOT_LINTFLAGS) $(DBOOT_LINTTAGS)
$(DBOOT_OBJS_DIR)/%.o: $(UTSBASE)/i86pc/boot/%.c
- $(i386_CC) $(CERRWARN) -O $(DBOOT_DEFS) $(DBOOT_CC_INCL) -c -o $@ $<
+ $(i386_CC) $(DBOOT_FLAGS) -O $(DBOOT_DEFS) $(DBOOT_CC_INCL) -c -o $@ $<
$(DBOOT_OBJS_DIR)/%.o: $(UTSBASE)/i86pc/dboot/%.c
- $(i386_CC) $(CERRWARN) -O $(DBOOT_DEFS) $(DBOOT_CC_INCL) -c -o $@ $<
+ $(i386_CC) $(DBOOT_FLAGS) -O $(DBOOT_DEFS) $(DBOOT_CC_INCL) -c -o $@ $<
$(DBOOT_OBJS_DIR)/%.o: $(UTSBASE)/intel/ia32/%.s
$(DBOOT_AS) -P -D_ASM $(DBOOT_DEFS) $(DBOOT_AS_INCL) -o $@ $<
$(DBOOT_OBJS_DIR)/%.o: $(COMMONBASE)/util/%.c
- $(i386_CC) $(CERRWARN) -O $(DBOOT_DEFS) $(DBOOT_CC_INCL) -c -o $@ $<
+ $(i386_CC) $(DBOOT_FLAGS) -O $(DBOOT_DEFS) $(DBOOT_CC_INCL) -c -o $@ $<
$(DBOOT_OBJS_DIR)/%.o: $(COMMONBASE)/util/i386/%.s
$(DBOOT_AS) -P -D_ASM $(DBOOT_DEFS) $(DBOOT_AS_INCL) -o $@ $<
diff --git a/usr/src/uts/i86xpv/Makefile.rules b/usr/src/uts/i86xpv/Makefile.rules
index a93bd026c3..90a4323620 100644
--- a/usr/src/uts/i86xpv/Makefile.rules
+++ b/usr/src/uts/i86xpv/Makefile.rules
@@ -184,7 +184,7 @@ DBOOT_OBJS_DIR= dboot/$(OBJS_DIR)
DBOOT_XARCH_32 = $(i386_XARCH)
DBOOT_XARCH_64 = $(amd64_XARCH)
-DBOOT_CFLAGS = $(DBOOT_XARCH_$(CLASS)) $(CERRWARN) -O
+DBOOT_CFLAGS = $(DBOOT_XARCH_$(CLASS)) $(CERRWARN) $(CCNOAUTOINLINE) -O
DBOOT_AS_XARCH_32 = $(i386_AS_XARCH)
DBOOT_AS_XARCH_64 = $(amd64_AS_XARCH)
diff --git a/usr/src/uts/sparc/Makefile.sparc.shared b/usr/src/uts/sparc/Makefile.sparc.shared
index c10ecd8952..5973079ae5 100644
--- a/usr/src/uts/sparc/Makefile.sparc.shared
+++ b/usr/src/uts/sparc/Makefile.sparc.shared
@@ -137,6 +137,8 @@ CFLAGS += $(CTF_FLAGS)
CFLAGS += $(C99MODE)
CFLAGS += $(CCUNBOUND)
CFLAGS += $(CCSTATICSYM)
+CFLAGS += $(CC32BITCALLERS)
+CFLAGS += $(CCNOAUTOINLINE)
CFLAGS += $(IROPTFLAG)
CFLAGS += $(CGLOBALSTATIC)
CFLAGS += -xregs=no%float
diff --git a/usr/src/uts/sun4u/Makefile.sun4u.shared b/usr/src/uts/sun4u/Makefile.sun4u.shared
index 79ba49d205..ad79ac45d4 100644
--- a/usr/src/uts/sun4u/Makefile.sun4u.shared
+++ b/usr/src/uts/sun4u/Makefile.sun4u.shared
@@ -208,7 +208,9 @@ CFLAGS += $(CERRWARN)
CFLAGS += $(CTF_FLAGS)
CFLAGS += $(C99MODE)
CFLAGS += $(CCUNBOUND)
+CFLAGS += $(CCNOAUTOINLINE)
CFLAGS += $(CCSTATICSYM)
+CFLAGS += $(CC32BITCALLERS)
CFLAGS += $(IROPTFLAG)
CFLAGS += $(CGLOBALSTATIC)
CFLAGS += -xregs=no%float
diff --git a/usr/src/uts/sun4v/Makefile.sun4v.shared b/usr/src/uts/sun4v/Makefile.sun4v.shared
index 8a90237234..7bf359290f 100644
--- a/usr/src/uts/sun4v/Makefile.sun4v.shared
+++ b/usr/src/uts/sun4v/Makefile.sun4v.shared
@@ -182,7 +182,9 @@ CFLAGS += $(CERRWARN)
CFLAGS += $(CTF_FLAGS)
CFLAGS += $(C99MODE)
CFLAGS += $(CCUNBOUND)
+CFLAGS += $(CCNOAUTOINLINE)
CFLAGS += $(CCSTATICSYM)
+CFLAGS += $(CC32BITCALLERS)
CFLAGS += $(IROPTFLAG)
CFLAGS += $(CGLOBALSTATIC)
CFLAGS += -xregs=no%float